Class: CandidApiClient::EncounterAttachments::V1::AsyncV1Client

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::AsyncV1Client

Parameters:



105
106
107
# File 'lib/candidhealth/encounter_attachments/v_1/client.rb', line 105

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientCandidApiClient::AsyncRequestClient (readonly)



101
102
103
# File 'lib/candidhealth/encounter_attachments/v_1/client.rb', line 101

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)


144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/candidhealth/encounter_attachments/v_1/client.rb', line 144

def create(encounter_id:, attachment_file:, attachment_type:, request_options: nil)
  Async do
    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
    parsed_json = JSON.parse(response.body)
    parsed_json
  end
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)


174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/candidhealth/encounter_attachments/v_1/client.rb', line 174

def delete(encounter_id:, attachment_id:, request_options: nil)
  Async do
    @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
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:



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/candidhealth/encounter_attachments/v_1/client.rb', line 115

def get(encounter_id:, request_options: nil)
  Async do
    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
end