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.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/root_insurance/api/claim.rb', line 171 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
32 33 34 |
# File 'lib/root_insurance/api/claim.rb', line 32 def get_claim(id:) get("claims/#{id}") end |
#link_policy_to_claim(claim_id:, policy_id:) ⇒ Hash
Link a claim and a policy
122 123 124 125 126 |
# File 'lib/root_insurance/api/claim.rb', line 122 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
138 139 140 141 142 |
# File 'lib/root_insurance/api/claim.rb', line 138 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
152 153 154 155 |
# File 'lib/root_insurance/api/claim.rb', line 152 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
16 17 18 19 20 21 22 23 |
# File 'lib/root_insurance/api/claim.rb', line 16 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
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/root_insurance/api/claim.rb', line 65 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
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/root_insurance/api/claim.rb', line 100 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 |