Class: CandidApiClient::Guarantor::V1::V1Client

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::V1Client

Parameters:



18
19
20
# File 'lib/candidhealth/guarantor/v_1/client.rb', line 18

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientCandidApiClient::RequestClient (readonly)



14
15
16
# File 'lib/candidhealth/guarantor/v_1/client.rb', line 14

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:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/candidhealth/guarantor/v_1/client.rb', line 46

def create(encounter_id:, request:, request_options: nil)
  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

#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:



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/candidhealth/guarantor/v_1/client.rb', line 70

def get(guarantor_id:, request_options: nil)
  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

#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:



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/candidhealth/guarantor/v_1/client.rb', line 109

def update(guarantor_id:, request:, request_options: nil)
  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