Class: Candid::InsuranceRefunds::V1::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/candid/insurance_refunds/v_1/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:, base_url: nil, environment: nil) ⇒ void

Parameters:



12
13
14
15
16
# File 'lib/candid/insurance_refunds/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

#create(request_options: {}, **params) ⇒ Candid::InsuranceRefunds::V1::Types::InsuranceRefund

Creates a new insurance refund record and returns the newly created ‘InsuranceRefund` object. The allocations can describe whether the refund is being applied toward a specific service line, claim, or billing provider.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/candid/insurance_refunds/v_1/client.rb', line 121

def create(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || @base_url || @environment&.dig(:candid_api),
    method: "POST",
    path: "/api/insurance-refunds/v1",
    body: Candid::InsuranceRefunds::V1::Types::InsuranceRefundCreate.new(params).to_h,
    request_options: 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::InsuranceRefunds::V1::Types::InsuranceRefund.load(response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#delete(request_options: {}, **params) ⇒ untyped

Deletes the insurance refund record matching the provided ‘insurance_refund_id`. If the matching record’s organization_id does not match the authenticated user’s current organization_id, then a response code of ‘403` will be returned.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:

  • (untyped)

Raises:

  • (error_class)


198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/candid/insurance_refunds/v_1/client.rb', line 198

def delete(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || @base_url || @environment&.dig(:candid_api),
    method: "DELETE",
    path: "/api/insurance-refunds/v1/#{params[:insurance_refund_id]}",
    request_options: request_options
  )
  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::InsuranceRefunds::V1::Types::InsuranceRefund

Retrieves a previously created insurance refund by its ‘insurance_refund_id`. If the refund does not exist, a `403` will be thrown.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/candid/insurance_refunds/v_1/client.rb', line 86

def get(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || @base_url || @environment&.dig(:candid_api),
    method: "GET",
    path: "/api/insurance-refunds/v1/#{params[:insurance_refund_id]}",
    request_options: 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::InsuranceRefunds::V1::Types::InsuranceRefund.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::InsuranceRefunds::V1::Types::InsuranceRefundsPage

Returns all insurance refunds satisfying the search criteria AND whose organization_id matches the current organization_id of the authenticated user.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



38
39
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
65
66
67
68
69
70
71
# File 'lib/candid/insurance_refunds/v_1/client.rb', line 38

def get_multi(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[limit payer_uuid claim_id service_line_id billing_provider_id sort sort_direction page_token]
  query_params = {}
  query_params["limit"] = params[:limit] if params.key?(:limit)
  query_params["payer_uuid"] = params[:payer_uuid] if params.key?(:payer_uuid)
  query_params["claim_id"] = params[:claim_id] if params.key?(:claim_id)
  query_params["service_line_id"] = params[:service_line_id] if params.key?(:service_line_id)
  query_params["billing_provider_id"] = params[:billing_provider_id] if params.key?(:billing_provider_id)
  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: request_options[:base_url] || @base_url || @environment&.dig(:candid_api),
    method: "GET",
    path: "/api/insurance-refunds/v1",
    query: query_params,
    request_options: 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::InsuranceRefunds::V1::Types::InsuranceRefundsPage.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::InsuranceRefunds::V1::Types::InsuranceRefund

Updates the patient refund record matching the provided insurance_refund_id. If updating the refund amount, then the allocations must be appropriately updated as well.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/candid/insurance_refunds/v_1/client.rb', line 157

def update(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  request_data = Candid::InsuranceRefunds::V1::Types::InsuranceRefundUpdate.new(params).to_h
  non_body_param_names = ["insurance_refund_id"]
  body = request_data.except(*non_body_param_names)

  request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || @base_url || @environment&.dig(:candid_api),
    method: "PATCH",
    path: "/api/insurance-refunds/v1/#{params[:insurance_refund_id]}",
    body: body,
    request_options: 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::InsuranceRefunds::V1::Types::InsuranceRefund.load(response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end