Module: RootInsurance::Api::Policy
- Included in:
- Client
- Defined in:
- lib/root_insurance/api/policy.rb
Instance Method Summary collapse
-
#add_policy_beneficiary(policy_id:, id:, first_name:, last_name:, percentage:, cellphone: nil) ⇒ Hash
Add a benificiary to a policy.
-
#cancel_policy(id:, reason:) ⇒ Hash
Cancel a policy.
-
#get_policy(id:) ⇒ Hash
Get a policy.
-
#issue_policy(application_id:, app_data: nil) ⇒ Hash
Issue a policy.
-
#list_policies(id_number: nil) ⇒ Array<Hash>
List policies.
-
#list_policy_beneficiaries(id:) ⇒ Array<Hash>
List a policy’s bebeficiaries.
-
#list_policy_events(id:) ⇒ Array<Hash>
List all the events which are applicable to this policy.
-
#update_policy(id:, app_data:) ⇒ Hash
Update a policy.
-
#update_policy_billing_amount(id:, billing_amount:) ⇒ Hash
Update a policy’s billing amount.
Instance Method Details
#add_policy_beneficiary(policy_id:, id:, first_name:, last_name:, percentage:, cellphone: nil) ⇒ Hash
Add a benificiary to a policy
ID
- type (string or symbol)
-
Either
:id
or:passport
- number (string)
-
The id or passport number
- country (string)
-
The ISO Alpha-2 country code of the country of the id/passport number.
Cellphone
- number (string)
-
The cellphone number
- country (string)
-
The ISO Alpha-2 country code of the country of the cellphone number.
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/root_insurance/api/policy.rb', line 53 def add_policy_beneficiary(policy_id:, id:, first_name:, last_name:, percentage:, cellphone: nil) raise ArgumentError.new('id needs to be a hash') unless id.is_a? Hash data = { id: id, first_name: first_name, last_name: last_name, percentage: percentage, cellphone: cellphone }.reject { |k, v| v.nil? } put("policies/#{policy_id}/beneficiaries", data) end |
#cancel_policy(id:, reason:) ⇒ Hash
Cancel a policy
102 103 104 105 106 |
# File 'lib/root_insurance/api/policy.rb', line 102 def cancel_policy(id:, reason:) data = {reason: reason} post("policies/#{id}/cancel", data) end |
#get_policy(id:) ⇒ Hash
Get a policy
89 90 91 |
# File 'lib/root_insurance/api/policy.rb', line 89 def get_policy(id:) get("policies/#{id}") end |
#issue_policy(application_id:, app_data: nil) ⇒ Hash
Issue a policy
16 17 18 19 20 21 22 23 24 |
# File 'lib/root_insurance/api/policy.rb', line 16 def issue_policy(application_id:, app_data: nil) data = { application_id: application_id, } data.merge!(app_data: app_data) if app_data post(:policies, data) end |
#list_policies(id_number: nil) ⇒ Array<Hash>
List policies
75 76 77 78 79 |
# File 'lib/root_insurance/api/policy.rb', line 75 def list_policies(id_number: nil) query = id_number ? {id_number: id_number} : nil get(:policies, query) end |
#list_policy_beneficiaries(id:) ⇒ Array<Hash>
List a policy’s bebeficiaries
148 149 150 |
# File 'lib/root_insurance/api/policy.rb', line 148 def list_policy_beneficiaries(id:) get("policies/#{id}/beneficiaries") end |
#list_policy_events(id:) ⇒ Array<Hash>
List all the events which are applicable to this policy.
160 161 162 |
# File 'lib/root_insurance/api/policy.rb', line 160 def list_policy_events(id:) get("policies/#{id}/events") end |
#update_policy(id:, app_data:) ⇒ Hash
Update a policy. Currently, only updating the app_data object is supported
119 120 121 122 123 |
# File 'lib/root_insurance/api/policy.rb', line 119 def update_policy(id:, app_data:) data = {app_data: app_data} patch("policies/#{id}", data) end |
#update_policy_billing_amount(id:, billing_amount:) ⇒ Hash
Update a policy’s billing amount.
134 135 136 137 138 |
# File 'lib/root_insurance/api/policy.rb', line 134 def update_policy_billing_amount(id:, billing_amount:) data = {billing_amount: billing_amount} post("policies/#{id}/billing_amount", data) end |