Sha256: 1c722a95059068c8a2b3a6cc347f690f63e01360c2fe1c64649a36883da32d1a

Contents?: true

Size: 697 Bytes

Versions: 2

Compression:

Stored size: 697 Bytes

Contents

module LifenFhir
  class Binary < Base

    attribute :uuid, String

    def fhir_payload
      {
        contentReference: {
          reference: reference
        }
      }
    end

    def download
      application_client.get("fhir/#{reference}", { accept: "application/pdf" })
    end

    def attributes_from_json(json)
      first_binary = Array(json).first

      reference = first_binary["contentReference"]["reference"]

      self.uuid = reference.gsub('Binary/', '')

      self
    end

    private

      def application_client
        @application_client ||= AppAuthenticatedClient.new
      end

      def reference
        LifenFhir::Reference.new(self).to_s
      end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lifen_fhir-0.4.1 lib/lifen_fhir/binary.rb
lifen_fhir-0.4.0 lib/lifen_fhir/binary.rb