Class: CandidApiClient::EncounterAttachments::V1::AsyncV1Client
- Inherits:
-
Object
- Object
- CandidApiClient::EncounterAttachments::V1::AsyncV1Client
- Defined in:
- lib/candidhealth/encounter_attachments/v_1/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(encounter_id:, attachment_file:, attachment_type:, request_options: nil) ⇒ String
Uploads a file to the encounter.
- #delete(encounter_id:, attachment_id:, request_options: nil) ⇒ Void
- #get(encounter_id:, request_options: nil) ⇒ Array<CandidApiClient::EncounterAttachments::V1::Types::EncounterAttachment>
- #initialize(request_client:) ⇒ CandidApiClient::EncounterAttachments::V1::AsyncV1Client constructor
Constructor Details
#initialize(request_client:) ⇒ CandidApiClient::EncounterAttachments::V1::AsyncV1Client
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_client ⇒ CandidApiClient::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.
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..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.body = { **(&.additional_body_parameters || {}), attachment_file: CandidApiClient::FileUtilities.as_faraday_multipart(file_like: ), 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
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..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.body = { **(&.additional_body_parameters || {}), 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>
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..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.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 |