Class: Candid::PreEncounter::Appointments::V1::Client
- Inherits:
-
Object
- Object
- Candid::PreEncounter::Appointments::V1::Client
- Defined in:
- lib/candid/pre_encounter/appointments/v_1/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::Appointment
Adds an appointment.
-
#deactivate(request_options: {}, **params) ⇒ untyped
Sets an appointment as deactivated.
-
#get(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::Appointment
Gets an appointment.
-
#get_history(request_options: {}, **params) ⇒ Array[Candid::PreEncounter::Appointments::V1::Types::Appointment]
Gets an appointment along with it’s full history.
-
#get_visits(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::VisitsPage
Gets all Visits within a given time range.
- #initialize(client:) ⇒ Candid::PreEncounter::Appointments::V1::Client constructor
-
#scan(request_options: {}, **params) ⇒ Array[Candid::PreEncounter::Appointments::V1::Types::Appointment]
Scans up to 100 appointment updates.
-
#update(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::Appointment
Updates an appointment.
Constructor Details
#initialize(client:) ⇒ Candid::PreEncounter::Appointments::V1::Client
9 10 11 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::Appointment
Adds an appointment. VersionConflictError is returned when the placer_appointment_id is already in use.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 16 def create(request_options: {}, **params) _request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || Candid::Environment::PRODUCTION, method: "POST", path: "/appointments/v1", body: Candid::PreEncounter::Appointments::V1::Types::MutableAppointment.new(params).to_h ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Candid::PreEncounter::Appointments::V1::Types::Appointment.load(_response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#deactivate(request_options: {}, **params) ⇒ untyped
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.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 164 def deactivate(request_options: {}, **params) _request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || Candid::Environment::PRODUCTION, method: "DELETE", path: "/appointments/v1/#{params[:id]}/#{params[:version]}" ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = _response.code.to_i return if code.between?(200, 299) error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end |
#get(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::Appointment
Gets an appointment.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 69 def get(request_options: {}, **params) _request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || Candid::Environment::PRODUCTION, method: "GET", path: "/appointments/v1/#{params[:id]}" ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Candid::PreEncounter::Appointments::V1::Types::Appointment.load(_response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#get_history(request_options: {}, **params) ⇒ Array[Candid::PreEncounter::Appointments::V1::Types::Appointment]
Gets an appointment along with it’s full history. The return list is ordered by version ascending.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 92 def get_history(request_options: {}, **params) _request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || Candid::Environment::PRODUCTION, method: "GET", path: "/appointments/v1/#{params[:id]}/history" ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = _response.code.to_i return if code.between?(200, 299) error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end |
#get_visits(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::VisitsPage
Gets all Visits within a given time range. The return list is ordered by start_time ascending.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 40 def get_visits(request_options: {}, **params) params = Candid::Internal::Types::Utils.symbolize_keys(params) _query_param_names = %i[page_token limit sort_field sort_direction filters] _query = params.slice(*_query_param_names) params.except(*_query_param_names) _request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || Candid::Environment::PRODUCTION, method: "GET", path: "/appointments/v1/visits", query: _query ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Candid::PreEncounter::Appointments::V1::Types::VisitsPage.load(_response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#scan(request_options: {}, **params) ⇒ Array[Candid::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.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 137 def scan(request_options: {}, **params) params = Candid::Internal::Types::Utils.symbolize_keys(params) _query_param_names = %i[since] _query = params.slice(*_query_param_names) params.except(*_query_param_names) _request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || Candid::Environment::PRODUCTION, method: "GET", path: "/appointments/v1/updates/scan", query: _query ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = _response.code.to_i return if code.between?(200, 299) error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end |
#update(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::Appointment
Updates an appointment. The path must contain the next version number to prevent race conditions. For example, if the current version of the appointment is n, you will need to send a request to this endpoint with ‘/id/n+1` to update the appointment. Updating historic versions is not supported.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 113 def update(request_options: {}, **params) _request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || Candid::Environment::PRODUCTION, method: "PUT", path: "/appointments/v1/#{params[:id]}/#{params[:version]}", body: Candid::PreEncounter::Appointments::V1::Types::MutableAppointment.new(params).to_h ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Candid::PreEncounter::Appointments::V1::Types::Appointment.load(_response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |