Class: CandidApiClient::PreEncounter::Appointments::V1::V1Client
- Inherits:
-
Object
- Object
- CandidApiClient::PreEncounter::Appointments::V1::V1Client
- Defined in:
- lib/candidhealth/pre_encounter/appointments/v_1/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(request:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment
Adds an appointment.
-
#deactivate(id:, version:, request_options: nil) ⇒ Void
Sets an appointment as deactivated.
-
#get(id:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment
Gets an appointment.
-
#get_history(id:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment>
Gets an appointment along with it’s full history.
- #initialize(request_client:) ⇒ CandidApiClient::PreEncounter::Appointments::V1::V1Client constructor
-
#scan(since:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment>
Scans up to 100 appointment updates.
-
#update(id:, version:, request:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment
Updates an appointment.
Constructor Details
#initialize(request_client:) ⇒ CandidApiClient::PreEncounter::Appointments::V1::V1Client
20 21 22 |
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 20 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ CandidApiClient::RequestClient (readonly)
16 17 18 |
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 16 def request_client @request_client end |
Instance Method Details
#create(request:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment
Adds an appointment. VersionConflictError is returned when the
placer_appointment_id is already in use.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 63 def create(request:, request_options: nil) response = @request_client.conn.post 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 = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/appointments/v1" end CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment.from_json(json_object: response.body) end |
#deactivate(id:, version:, request_options: nil) ⇒ Void
Sets an appointment as deactivated. The path must contain the most recent
version to prevent race conditions. Deactivating historic versions is not
supported. Subsequent updates via PUT to the appointment will "reactivate" the
appointment and set the deactivated flag to false.
232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 232 def deactivate(id:, version:, request_options: nil) @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.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/appointments/v1/#{id}/#{version}" end end |
#get(id:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment
Gets an appointment.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 87 def get(id:, request_options: nil) 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: PreEncounter, request_options: )}/appointments/v1/#{id}" end CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment.from_json(json_object: response.body) end |
#get_history(id:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment>
Gets an appointment along with it’s full history. The return list is ordered by
version ascending.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 111 def get_history(id:, request_options: nil) 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: PreEncounter, request_options: )}/appointments/v1/#{id}/history" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment.from_json(json_object: item) end end |
#scan(since:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment>
Scans up to 100 appointment updates. The since query parameter is inclusive, and
the result list is ordered by updatedAt ascending.
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 200 def scan(since:, request_options: nil) 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.params = { **(&.additional_query_parameters || {}), "since": since }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/appointments/v1/updates/scan" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment.from_json(json_object: item) end end |
#update(id:, version:, request:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment
Updates an appointment. The path must contain the most recent version to prevent
race conditions. Updating historic versions is not supported.
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 175 def update(id:, version:, request:, request_options: nil) 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 = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/appointments/v1/#{id}/#{version}" end CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment.from_json(json_object: response.body) end |