Class: Candid::ImportInvoice::V1::Client
- Inherits:
-
Object
- Object
- Candid::ImportInvoice::V1::Client
- Defined in:
- lib/candid/import_invoice/v_1/client.rb
Instance Method Summary collapse
-
#get(request_options: {}, **params) ⇒ Candid::ImportInvoice::V1::Types::ImportInvoice
Retrieve and view an import invoice.
-
#get_multi(request_options: {}, **params) ⇒ Candid::ImportInvoice::V1::Types::ImportInvoicesPage
Returns all Invoices for the authenticated user’s organziation with all filters applied.
-
#import_invoice(request_options: {}, **params) ⇒ Candid::ImportInvoice::V1::Types::ImportInvoice
Import an existing invoice from a third party service to reflect state in Candid.
- #initialize(client:, base_url: nil, environment: nil) ⇒ void constructor
-
#update(request_options: {}, **params) ⇒ Candid::ImportInvoice::V1::Types::ImportInvoice
Update the information on the imported invoice.
Constructor Details
#initialize(client:, base_url: nil, environment: nil) ⇒ void
12 13 14 15 16 |
# File 'lib/candid/import_invoice/v_1/client.rb', line 12 def initialize(client:, base_url: nil, environment: nil) @client = client @base_url = base_url @environment = environment end |
Instance Method Details
#get(request_options: {}, **params) ⇒ Candid::ImportInvoice::V1::Types::ImportInvoice
Retrieve and view an import invoice
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/candid/import_invoice/v_1/client.rb', line 122 def get(request_options: {}, **params) params = Candid::Internal::Types::Utils.normalize_keys(params) request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || @base_url || @environment&.dig(:candid_api), method: "GET", path: "/api/import-invoice/v1/#{params[:invoice_id]}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Candid::ImportInvoice::V1::Types::ImportInvoice.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_multi(request_options: {}, **params) ⇒ Candid::ImportInvoice::V1::Types::ImportInvoicesPage
Returns all Invoices for the authenticated user’s organziation with all filters applied.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/candid/import_invoice/v_1/client.rb', line 73 def get_multi(request_options: {}, **params) params = Candid::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[patient_external_id encounter_external_id note due_date_before due_date_after status limit sort sort_direction page_token] query_params = {} query_params["patient_external_id"] = params[:patient_external_id] if params.key?(:patient_external_id) query_params["encounter_external_id"] = params[:encounter_external_id] if params.key?(:encounter_external_id) query_params["note"] = params[:note] if params.key?(:note) query_params["due_date_before"] = params[:due_date_before] if params.key?(:due_date_before) query_params["due_date_after"] = params[:due_date_after] if params.key?(:due_date_after) query_params["status"] = params[:status] if params.key?(:status) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["sort"] = params[:sort] if params.key?(:sort) query_params["sort_direction"] = params[:sort_direction] if params.key?(:sort_direction) query_params["page_token"] = params[:page_token] if params.key?(:page_token) params.except(*query_param_names) request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || @base_url || @environment&.dig(:candid_api), method: "GET", path: "/api/import-invoice/v1", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Candid::ImportInvoice::V1::Types::ImportInvoicesPage.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#import_invoice(request_options: {}, **params) ⇒ Candid::ImportInvoice::V1::Types::ImportInvoice
Import an existing invoice from a third party service to reflect state in Candid.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/candid/import_invoice/v_1/client.rb', line 29 def import_invoice(request_options: {}, **params) params = Candid::Internal::Types::Utils.normalize_keys(params) request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || @base_url || @environment&.dig(:candid_api), method: "POST", path: "/api/import-invoice/v1", body: Candid::ImportInvoice::V1::Types::CreateImportInvoiceRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Candid::ImportInvoice::V1::Types::ImportInvoice.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update(request_options: {}, **params) ⇒ Candid::ImportInvoice::V1::Types::ImportInvoice
Update the information on the imported invoice
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/candid/import_invoice/v_1/client.rb', line 156 def update(request_options: {}, **params) params = Candid::Internal::Types::Utils.normalize_keys(params) request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || @base_url || @environment&.dig(:candid_api), method: "PATCH", path: "/api/import-invoice/v1/#{params[:invoice_id]}", body: Candid::ImportInvoice::V1::Types::ImportInvoiceUpdateRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Candid::ImportInvoice::V1::Types::ImportInvoice.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |