Module: RootInsurance::Api::Claim
- Included in:
- Client
- Defined in:
- lib/root_insurance/api/claim.rb
Instance Method Summary collapse
-
#create_claim_attachment(claim_id:, path: nil, file: nil, bytes: nil, base64: nil, file_name: nil, file_type: nil, description: '') ⇒ Hash
Create a claim attachment.
-
#get_claim(id:) ⇒ Hash
Get a specific claim.
-
#link_policy_to_claim(claim_id:, policy_id:) ⇒ Hash
Link a claim and a policy.
-
#link_policyholder_to_claim(claim_id:, policyholder_id:) ⇒ Hash
Link a claim and a policy holder.
-
#list_claim_events(id: nil, claim_id: nil) ⇒ Array<Hash>
List all claim events.
-
#list_claims(status: nil, approval: nil) ⇒ Array<Hash>
List all claims.
-
#open_claim(policy_id: nil, policyholder_id: nil, incident_type: nil, incident_cause: nil, incident_date: nil, app_data: nil, claimant: nil, requested_amount: nil) ⇒ Hash
Open a claim.
-
#update_claim(claim_id:, incident_type: nil, incident_cause: nil, incident_date: nil, app_data: nil, requested_amount: nil) ⇒ Hash
Update a claim.
Instance Method Details
#create_claim_attachment(claim_id:, path: nil, file: nil, bytes: nil, base64: nil, file_name: nil, file_type: nil, description: '') ⇒ Hash
Create a claim attachment
The file data can be passed using either path, file, bytes or base64.
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/root_insurance/api/claim.rb', line 170 def (claim_id:, path: nil, file: nil, bytes: nil, base64: nil, file_name: nil, file_type: nil, description: '') data = if path (path) elsif file (file) elsif bytes raise ArgumentError.new("file_name is required when supplying bytes") unless file_name (bytes, file_name, file_type) elsif base64 raise ArgumentError.new("file_name is required when supplying base64") unless file_name raise ArgumentError.new("file_type is required when supplying base64") unless file_type (base64, file_name, file_type) else {} end.merge({description: description}) post("claims/#{claim_id}/attachments", data) end |
#get_claim(id:) ⇒ Hash
Get a specific claim
31 32 33 |
# File 'lib/root_insurance/api/claim.rb', line 31 def get_claim(id:) get("claims/#{id}") end |
#link_policy_to_claim(claim_id:, policy_id:) ⇒ Hash
Link a claim and a policy
121 122 123 124 125 |
# File 'lib/root_insurance/api/claim.rb', line 121 def link_policy_to_claim(claim_id:, policy_id:) data = {policy_id: policy_id} post("claims/#{claim_id}/policy", data) end |
#link_policyholder_to_claim(claim_id:, policyholder_id:) ⇒ Hash
Link a claim and a policy holder
137 138 139 140 141 |
# File 'lib/root_insurance/api/claim.rb', line 137 def link_policyholder_to_claim(claim_id:, policyholder_id:) data = {policyholder_id: policyholder_id} post("claims/#{claim_id}/policyholder", data) end |
#list_claim_events(id: nil, claim_id: nil) ⇒ Array<Hash>
List all claim events
151 152 153 154 |
# File 'lib/root_insurance/api/claim.rb', line 151 def list_claim_events(id: nil, claim_id: nil) claim_id = claim_id || id get("claims/#{claim_id}/events") end |
#list_claims(status: nil, approval: nil) ⇒ Array<Hash>
List all claims
15 16 17 18 19 20 21 22 |
# File 'lib/root_insurance/api/claim.rb', line 15 def list_claims(status: nil, approval: nil) query = { claim_status: status, approval_status: approval }.reject { |key, value| value.nil? } get(:claims, query) end |
#open_claim(policy_id: nil, policyholder_id: nil, incident_type: nil, incident_cause: nil, incident_date: nil, app_data: nil, claimant: nil, requested_amount: nil) ⇒ Hash
Open a claim
Claimant
- first_name (string)
-
The name of the claimant
- last_name (string)
-
The last name of the claimant
- email (string)
-
The claimant’s email address
- cellphone (string)
-
The claimant’s cellphone number
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/root_insurance/api/claim.rb', line 64 def open_claim(policy_id: nil, policyholder_id: nil, incident_type: nil, incident_cause: nil, incident_date: nil, app_data: nil, claimant: nil, requested_amount: nil) data = { policy_id: policy_id, policyholder_id: policyholder_id, incident_type: incident_type, incident_cause: incident_cause, incident_date: incident_date, app_data: app_data, claimant: claimant, requested_amount: requested_amount }.reject { |key, value| value.nil? } post(:claims, data) end |
#update_claim(claim_id:, incident_type: nil, incident_cause: nil, incident_date: nil, app_data: nil, requested_amount: nil) ⇒ Hash
Update a claim
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/root_insurance/api/claim.rb', line 99 def update_claim(claim_id:, incident_type: nil, incident_cause: nil, incident_date: nil, app_data: nil, requested_amount: nil) data = { incident_type: incident_type, incident_cause: incident_cause, incident_date: incident_date, app_data: app_data, requested_amount: requested_amount }.reject { |key, value| value.nil? } patch("claims/#{claim_id}", data) end |