Class: CandidApiClient::Guarantor::V1::AsyncV1Client

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/guarantor/v_1/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ CandidApiClient::Guarantor::V1::AsyncV1Client

Parameters:



132
133
134
# File 'lib/candidhealth/guarantor/v_1/client.rb', line 132

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientCandidApiClient::AsyncRequestClient (readonly)



128
129
130
# File 'lib/candidhealth/guarantor/v_1/client.rb', line 128

def request_client
  @request_client
end

Instance Method Details

#create(encounter_id:, request:, request_options: nil) ⇒ CandidApiClient::Guarantor::V1::Types::Guarantor

Creates a new guarantor and returns the newly created Guarantor object.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.guarantor.v_1.create(encounter_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", request: { phone_numbers: [{ number: "1234567890", type: HOME }], phone_consent: true, email: "[email protected]", email_consent: true, first_name: "string", last_name: "string", external_id: "string", date_of_birth: DateTime.parse(2023-01-15), address: { address_1: "123 Main St", address_2: "Apt 1", city: "New York", state: NY, zip_code: "10001", zip_plus_four_code: "1234" } })

Parameters:

  • encounter_id (String)
  • request (Hash)

    Request of type CandidApiClient::Guarantor::V1::Types::GuarantorCreate, as a Hash

    • :phone_numbers (Array<CandidApiClient::Commons::Types::PhoneNumber>)

    • :phone_consent (Boolean)

    • :email (String)

    • :email_consent (Boolean)

    • :first_name (String)

    • :last_name (String)

    • :external_id (String)

    • :date_of_birth (Date)

    • :address (Hash)

      • :zip_plus_four_code (String)

      • :address_1 (String)

      • :address_2 (String)

      • :city (String)

      • :state (CandidApiClient::Commons::Types::State)

      • :zip_code (String)

  • request_options (CandidApiClient::RequestOptions) (defaults to: nil)

Returns:



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/candidhealth/guarantor/v_1/client.rb', line 160

def create(encounter_id:, request:, request_options: nil)
  Async do
    response = @request_client.conn.post do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
      req.url "#{@request_client.get_url(environment: CandidApi,
                                         request_options: request_options)}/api/guarantors/v1/#{encounter_id}"
    end
    CandidApiClient::Guarantor::V1::Types::Guarantor.from_json(json_object: response.body)
  end
end

#get(guarantor_id:, request_options: nil) ⇒ CandidApiClient::Guarantor::V1::Types::Guarantor

Retrieves a guarantor by its ‘guarantor_id`.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.guarantor.v_1.get(guarantor_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")

Parameters:

Returns:



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/candidhealth/guarantor/v_1/client.rb', line 186

def get(guarantor_id:, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.url "#{@request_client.get_url(environment: CandidApi,
                                         request_options: request_options)}/api/guarantors/v1/#{guarantor_id}"
    end
    CandidApiClient::Guarantor::V1::Types::Guarantor.from_json(json_object: response.body)
  end
end

#update(guarantor_id:, request:, request_options: nil) ⇒ CandidApiClient::Guarantor::V1::Types::Guarantor

Updates a guarantor by its ‘guarantor_id`.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.guarantor.v_1.update(guarantor_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", request: { first_name: "string", last_name: "string", external_id: "string", date_of_birth: DateTime.parse(2023-01-15), address: { address_1: "123 Main St", address_2: "Apt 1", city: "New York", state: NY, zip_code: "10001", zip_plus_four_code: "1234" }, phone_numbers: [{ number: "1234567890", type: HOME }], phone_consent: true, email: "[email protected]", email_consent: true })

Parameters:

  • guarantor_id (String)
  • request (Hash)

    Request of type CandidApiClient::Guarantor::V1::Types::GuarantorUpdate, as a Hash

    • :first_name (String)

    • :last_name (String)

    • :external_id (String)

    • :date_of_birth (Date)

    • :address (Hash)

      • :zip_plus_four_code (String)

      • :address_1 (String)

      • :address_2 (String)

      • :city (String)

      • :state (CandidApiClient::Commons::Types::State)

      • :zip_code (String)

    • :phone_numbers (Array<CandidApiClient::Commons::Types::PhoneNumber>)

    • :phone_consent (Boolean)

    • :email (String)

    • :email_consent (Boolean)

  • request_options (CandidApiClient::RequestOptions) (defaults to: nil)

Returns:



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/candidhealth/guarantor/v_1/client.rb', line 227

def update(guarantor_id:, request:, request_options: nil)
  Async do
    response = @request_client.conn.patch do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
      req.url "#{@request_client.get_url(environment: CandidApi,
                                         request_options: request_options)}/api/guarantors/v1/#{guarantor_id}"
    end
    CandidApiClient::Guarantor::V1::Types::Guarantor.from_json(json_object: response.body)
  end
end