Class: CandidApiClient::EncounterAttachments::V1::V1Client

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/encounter_attachments/v_1/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ CandidApiClient::EncounterAttachments::V1::V1Client

Parameters:



19
20
21
# File 'lib/candidhealth/encounter_attachments/v_1/client.rb', line 19

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientCandidApiClient::RequestClient (readonly)



15
16
17
# File 'lib/candidhealth/encounter_attachments/v_1/client.rb', line 15

def request_client
  @request_client
end

Instance Method Details

#create(encounter_id:, attachment_file:, attachment_type:, request_options: nil) ⇒ String

Uploads a file to the encounter. The file will be stored in the

encounter's attachments.

Parameters:

Returns:

  • (String)


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/candidhealth/encounter_attachments/v_1/client.rb', line 56

def create(encounter_id:, attachment_file:, attachment_type:, request_options: nil)
  response = @request_client.conn.put do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.body = {
      **(request_options&.additional_body_parameters || {}),
      attachment_file: CandidApiClient::FileUtilities.as_faraday_multipart(file_like: attachment_file),
      attachment_type: attachment_type
    }.compact
    req.url "#{@request_client.get_url(environment: CandidApi,
                                       request_options: request_options)}/api/encounter-attachments/v1/#{encounter_id}"
  end
  JSON.parse(response.body)
end

#delete(encounter_id:, attachment_id:, request_options: nil) ⇒ Void

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.encounter_attachments.v_1.delete(encounter_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", attachment_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")

Parameters:

Returns:

  • (Void)


83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/candidhealth/encounter_attachments/v_1/client.rb', line 83

def delete(encounter_id:, attachment_id:, request_options: nil)
  @request_client.conn.delete do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.body = { **(request_options&.additional_body_parameters || {}), attachment_id: attachment_id }.compact
    req.url "#{@request_client.get_url(environment: CandidApi,
                                       request_options: request_options)}/api/encounter-attachments/v1/#{encounter_id}"
  end
end

#get(encounter_id:, request_options: nil) ⇒ Array<CandidApiClient::EncounterAttachments::V1::Types::EncounterAttachment>

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.encounter_attachments.v_1.get(encounter_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")

Parameters:

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/candidhealth/encounter_attachments/v_1/client.rb', line 29

def get(encounter_id:, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.url "#{@request_client.get_url(environment: CandidApi,
                                       request_options: request_options)}/api/encounter-attachments/v1/#{encounter_id}"
  end
  parsed_json = JSON.parse(response.body)
  parsed_json&.map do |item|
    item = item.to_json
    CandidApiClient::EncounterAttachments::V1::Types::EncounterAttachment.from_json(json_object: item)
  end
end