Module: RootInsurance::Api::Policyholder
- Included in:
- Client
- Defined in:
- lib/root_insurance/api/policyholder.rb
Instance Method Summary collapse
-
#create_policyholder(id:, first_name:, last_name:, email: nil, date_of_birth: nil, cellphone: nil, app_data: nil) ⇒ Hash
Create a policy holder.
-
#get_policyholder(id:, included_objects: nil) ⇒ Hash
Get a policy holder.
-
#list_policyholder_events(id:) ⇒ Array<Hash>
List all the events which are applicable to this policy holder.
-
#list_policyholders(id_number: nil, included_objects: nil) ⇒ Array<Hash>
List policy holders.
-
#update_policyholder(id:, email: nil, cellphone: nil, app_data: nil) ⇒ Hash
Update a policy holder.
Instance Method Details
#create_policyholder(id:, first_name:, last_name:, email: nil, date_of_birth: nil, cellphone: nil, app_data: nil) ⇒ Hash
Create a policy holder
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.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/root_insurance/api/policyholder.rb', line 32 def create_policyholder(id:, first_name:, last_name:, email: nil, date_of_birth: nil, cellphone: nil, app_data: 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, date_of_birth: date_of_birth, email: email, cellphone: cellphone, app_data: app_data }.reject { |key, value| value.nil? } post(:policyholders, data) end |
#get_policyholder(id:, included_objects: nil) ⇒ Hash
Get a policy holder
74 75 76 77 78 79 80 |
# File 'lib/root_insurance/api/policyholder.rb', line 74 def get_policyholder(id:, included_objects: nil) query = { include: format_included_objects(included_objects), }.reject { |_, v| v.nil? } get("policyholders/#{id}", query) end |
#list_policyholder_events(id:) ⇒ Array<Hash>
List all the events which are applicable to this policy holder.
118 119 120 |
# File 'lib/root_insurance/api/policyholder.rb', line 118 def list_policyholder_events(id:) get("policyholders/#{id}/events") end |
#list_policyholders(id_number: nil, included_objects: nil) ⇒ Array<Hash>
List policy holders
56 57 58 59 60 61 62 63 |
# File 'lib/root_insurance/api/policyholder.rb', line 56 def list_policyholders(id_number: nil, included_objects: nil) query = { include: format_included_objects(included_objects), id_number: id_number }.reject { |_, v| v.nil? } get(:policyholders, query) end |
#update_policyholder(id:, email: nil, cellphone: nil, app_data: nil) ⇒ Hash
Update a policy holder
Cellphone
- number (string)
-
The cellphone number
- country (string)
-
The ISO Alpha-2 country code of the country of the cellphone number.
100 101 102 103 104 105 106 107 108 |
# File 'lib/root_insurance/api/policyholder.rb', line 100 def update_policyholder(id:, email: nil, cellphone: nil, app_data: nil) data = { email: email, cellphone: cellphone, app_data: app_data }.reject { |key, value| value.nil? } patch("policyholders/#{id}", data) end |