root_insurance 1.9.0 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -0
- data/CHANGELOG.md +4 -0
- data/lib/root_insurance.rb +0 -1
- data/lib/root_insurance/api/application.rb +40 -38
- data/lib/root_insurance/api/call.rb +33 -31
- data/lib/root_insurance/api/claim.rb +227 -225
- data/lib/root_insurance/api/payment.rb +63 -61
- data/lib/root_insurance/api/policy.rb +163 -161
- data/lib/root_insurance/api/policyholder.rb +120 -118
- data/lib/root_insurance/api/quote.rb +84 -83
- data/lib/root_insurance/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 43f2f4cfd0a00e352d6bac7655f2540d05f99267de17f176480e75af8066224a
|
4
|
+
data.tar.gz: c5f51cfd206b9c2ff52e05a97971a6cfa7795214cc8bc1eeda4a1aaf034adc21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 220a4a92e4c53322581fdfd5a65b5c720d2387ef816b567e7c3b1c4692fa5ace284417985ba0b9d3b1a6c12c31d610faf64d26d4d95336b091fcf34563d2e806
|
7
|
+
data.tar.gz: c32163c099e0e2ab01286b137b2b630aff9171aade7053264a1a7ccdcfa3df3ebb511b771fd03486643781096143b9e1d2801f1fad6c0f8b95394c6d9125cbdd
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/root_insurance.rb
CHANGED
@@ -1,44 +1,46 @@
|
|
1
|
-
module RootInsurance
|
2
|
-
module
|
1
|
+
module RootInsurance
|
2
|
+
module Api
|
3
|
+
module Application
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
5
|
+
# Create an application
|
6
|
+
#
|
7
|
+
# @param [String] policyholder_id The policy holder id
|
8
|
+
# @param [String] quote_package_id The quote package id
|
9
|
+
# @param [Integer] monthly_premium The monthly premium (in cents)
|
10
|
+
# @param [String] serial_number The device to insure's serial number. (for the gadgets module)
|
11
|
+
# @param [String] spouse_id SA ID number of the policyholder's spouse. Required if has_spouse is true on the quote.
|
12
|
+
# @param [Array<String>] children_ids SA ID numbers of the policyholder's children. Required if +number_of_children+ is greater than 0 on the quote. All children must be younger than 21.
|
13
|
+
# @param [Array<String>] extended_famliy_ids SA ID number of the policyholder's extended family members. Required if the length of +extended_family_ages+ is greater than 0 on the quote. The ages inferred from the ID numbers must match the ages given in the quote step.
|
14
|
+
# @return [Hash]
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# client.create_application(
|
18
|
+
# policyholder_id: "bf1ada91-eecb-4f47-9bfa-1258bb1e0055",
|
19
|
+
# quote_package_id: "f4397823-db4a-4d6a-a06b-08e1a2a3172c",
|
20
|
+
# monthly_premium: 50000,
|
21
|
+
# serial_number: "1234567890")
|
22
|
+
def create_application(policyholder_id:, quote_package_id:, monthly_premium:,
|
23
|
+
serial_number: nil, spouse_id: nil, children_ids: nil, extended_famliy_ids: nil)
|
24
|
+
data = {
|
25
|
+
policyholder_id: policyholder_id,
|
26
|
+
quote_package_id: quote_package_id,
|
27
|
+
monthly_premium: monthly_premium
|
28
|
+
}
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
30
|
+
module_data = if serial_number
|
31
|
+
{serial_number: serial_number}
|
32
|
+
elsif spouse_id || children_ids || extended_famliy_ids
|
33
|
+
{
|
34
|
+
spouse_id: spouse_id,
|
35
|
+
children_ids: children_ids,
|
36
|
+
extended_famliy_ids: extended_famliy_ids
|
37
|
+
}.reject { |key, value| value.nil? }
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
+
data = module_data ? data.merge(module_data) : data
|
40
41
|
|
41
|
-
|
42
|
+
post(:applications, data)
|
43
|
+
end
|
42
44
|
end
|
43
45
|
end
|
44
|
-
end
|
46
|
+
end
|
@@ -1,35 +1,37 @@
|
|
1
|
-
module RootInsurance
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
module RootInsurance
|
2
|
+
module Api
|
3
|
+
module Call
|
4
|
+
# List all the logged calls
|
5
|
+
#
|
6
|
+
# @return [Hash]
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# client.list_calls
|
10
|
+
def list_calls
|
11
|
+
get(:calls)
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
# Get a specific call
|
15
|
+
#
|
16
|
+
# @param [String] id The unique identifier of the call
|
17
|
+
# @return [Hash]
|
18
|
+
#
|
19
|
+
# @example
|
20
|
+
# client.get_call(id: 'd3d13c48-4dc3-4816-8d01-de3215878225')
|
21
|
+
def get_call(id:)
|
22
|
+
get("calls/#{id}")
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
# List a call's events
|
26
|
+
#
|
27
|
+
# @param [String] id The unique identifier of the call
|
28
|
+
# @return [Hash]
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# client.list_call_events(id: 'd3d13c48-4dc3-4816-8d01-de3215878225')
|
32
|
+
def list_call_events(id:)
|
33
|
+
get("calls/#{id}/events")
|
34
|
+
end
|
33
35
|
end
|
34
36
|
end
|
35
|
-
end
|
37
|
+
end
|
@@ -1,230 +1,232 @@
|
|
1
1
|
require 'mimemagic'
|
2
2
|
|
3
|
-
module RootInsurance
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
3
|
+
module RootInsurance
|
4
|
+
module Api
|
5
|
+
module Claim
|
6
|
+
|
7
|
+
# List all claims
|
8
|
+
#
|
9
|
+
# @param [String, Symbol] status Either +:open+, +:closed+, +:finalized+, +:acknowledged+ or +:all+. If omitted defaults to +:all+
|
10
|
+
# @param [String, Symbol] approval Either +:approved+, +:repudiated+, +:'ex-gratia'+, +:'no-claim'+, +:pending+ or +:all+. If omitted defaults to +:all+
|
11
|
+
# @return [Array<Hash>]
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# client.list_claims(status: :open)
|
15
|
+
#
|
16
|
+
def list_claims(status: nil, approval: nil)
|
17
|
+
query = {
|
18
|
+
claim_status: status,
|
19
|
+
approval_status: approval
|
20
|
+
}.reject { |key, value| value.nil? }
|
21
|
+
|
22
|
+
get(:claims, query)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Get a specific claim
|
26
|
+
#
|
27
|
+
# @param [String] id The claim's id
|
28
|
+
# @return [Hash]
|
29
|
+
# @example
|
30
|
+
# client.get_claim(id: 'd3d13c48-4dc3-4816-8d01-de3215878225')
|
31
|
+
#
|
32
|
+
def get_claim(id:)
|
33
|
+
get("claims/#{id}")
|
34
|
+
end
|
35
|
+
|
36
|
+
# Open a claim
|
37
|
+
#
|
38
|
+
# @param [String] policy_id The ID of the policy under which the claim is being made. (optional)
|
39
|
+
# @param [String] policyholder_id The ID of the policyholder for whom the claim is being made. (optional)
|
40
|
+
# @param [String] incident_type A description of the incident type. (optional)
|
41
|
+
# @param [String] incident_cause A description of the cause of the incident. (optional)
|
42
|
+
# @param [String] incident_date The date on the which the incident occured. (optional)
|
43
|
+
# @param [String] app_data An object containing additional custom data for the claim. (optional)
|
44
|
+
# @param [String] claimant Object containing claimants's first name, last name, email and/or cellphone. See below for details. (optional)
|
45
|
+
# @param [String] requested_amount The requested payout amount (in cents) for the claim. (optional)
|
46
|
+
# @return [Hash]
|
47
|
+
#
|
48
|
+
## == Claimant
|
49
|
+
# [first_name (string)] The name of the claimant
|
50
|
+
# [last_name (string)] The last name of the claimant
|
51
|
+
# [email (string)] The claimant's email address
|
52
|
+
# [cellphone (string)] The claimant's cellphone number
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
# client.open_claim(
|
56
|
+
# policy_id: "8349345c-a6c5-4bf9-8ebb-6bbfc1628715",
|
57
|
+
# incident_type: "Theft",
|
58
|
+
# incident_cause: "Device stolen during burglary",
|
59
|
+
# incident_date: "2017-10-16T10:12:02.872Z",
|
60
|
+
# requested_amount: 13000000,
|
61
|
+
# app_data: {
|
62
|
+
# key1: "value 1"
|
63
|
+
# key2: "value 2"})
|
64
|
+
#
|
65
|
+
def open_claim(policy_id: nil, policyholder_id: nil, incident_type: nil, incident_cause: nil,
|
66
|
+
incident_date: nil, app_data: nil, claimant: nil, requested_amount: nil)
|
67
|
+
data = {
|
68
|
+
policy_id: policy_id,
|
69
|
+
policyholder_id: policyholder_id,
|
70
|
+
incident_type: incident_type,
|
71
|
+
incident_cause: incident_cause,
|
72
|
+
incident_date: incident_date,
|
73
|
+
app_data: app_data,
|
74
|
+
claimant: claimant,
|
75
|
+
requested_amount: requested_amount
|
76
|
+
}.reject { |key, value| value.nil? }
|
77
|
+
|
78
|
+
post(:claims, data)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Update a claim
|
82
|
+
#
|
83
|
+
# @param [String] claim_id The unique identifier of the claim.
|
84
|
+
# @param [String] incident_type A description of the incident type. (optional)
|
85
|
+
# @param [String] incident_cause A description of the cause of the incident. (optional)
|
86
|
+
# @param [String] incident_date The date on the which the incident occured. (optional)
|
87
|
+
# @param [String] app_data An object containing additional custom data for the claim. (optional)
|
88
|
+
# @param [String] requested_amount The requested payout amount (in cents) for the claim. (optional)
|
89
|
+
# @return [Hash]
|
90
|
+
#
|
91
|
+
# @example
|
92
|
+
# client.update_claim(
|
93
|
+
# claim_id: "d3d13c48-4dc3-4816-8d01-de3215878225",
|
94
|
+
# incident_type: "Theft",
|
95
|
+
# incident_cause: "Device stolen during burglary",
|
96
|
+
# incident_date: "2017-10-16T10:12:02.872Z",
|
97
|
+
# app_data: {key3: "value 3"},
|
98
|
+
# requested_amount: 13000000)
|
99
|
+
#
|
100
|
+
def update_claim(claim_id:, incident_type: nil, incident_cause: nil, incident_date: nil,
|
101
|
+
app_data: nil, requested_amount: nil)
|
102
|
+
data = {
|
103
|
+
incident_type: incident_type,
|
104
|
+
incident_cause: incident_cause,
|
105
|
+
incident_date: incident_date,
|
106
|
+
app_data: app_data,
|
107
|
+
requested_amount: requested_amount
|
108
|
+
}.reject { |key, value| value.nil? }
|
109
|
+
|
110
|
+
patch("claims/#{claim_id}", data)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Link a claim and a policy
|
114
|
+
#
|
115
|
+
# @param [String] claim_id The unique identifier of the claim.
|
116
|
+
# @param [String] policy_id The unique identifier of the policy.
|
117
|
+
# @return [Hash]
|
118
|
+
#
|
119
|
+
# @example
|
120
|
+
# client.link_policy_to_claim(claim_id: "d3d13c48-4dc3-4816-8d01-de3215878225", policy_id: "8349345c-a6c5-4bf9-8ebb-6bbfc1628715")
|
121
|
+
#
|
122
|
+
def link_policy_to_claim(claim_id:, policy_id:)
|
123
|
+
data = {policy_id: policy_id}
|
124
|
+
|
125
|
+
post("claims/#{claim_id}/policy", data)
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
# Link a claim and a policy holder
|
130
|
+
#
|
131
|
+
# @param [String] claim_id The unique identifier of the claim.
|
132
|
+
# @param [String] policyholder_id The unique identifier of the policy holder.
|
133
|
+
# @return [Hash]
|
134
|
+
#
|
135
|
+
# @example
|
136
|
+
# client.link_policyholder_to_claim(claim_id: "d3d13c48-4dc3-4816-8d01-de3215878225", policyholder_id: "808f75dc-cb8a-4808-93e9-e13f8eea84de")
|
137
|
+
#
|
138
|
+
def link_policyholder_to_claim(claim_id:, policyholder_id:)
|
139
|
+
data = {policyholder_id: policyholder_id}
|
140
|
+
|
141
|
+
post("claims/#{claim_id}/policyholder", data)
|
142
|
+
end
|
143
|
+
|
144
|
+
# List all claim events
|
145
|
+
#
|
146
|
+
# @param [String] claim_id The unique identifier of the claim.
|
147
|
+
# @return [Array<Hash>]
|
148
|
+
#
|
149
|
+
# @example
|
150
|
+
# client.list_claim_events(claim_id: "d3d13c48-4dc3-4816-8d01-de3215878225")
|
151
|
+
#
|
152
|
+
def list_claim_events(id: nil, claim_id: nil)
|
153
|
+
claim_id = claim_id || id
|
154
|
+
get("claims/#{claim_id}/events")
|
155
|
+
end
|
156
|
+
|
157
|
+
# Create a claim attachment
|
158
|
+
#
|
159
|
+
# The file data can be passed using either +path+, +file+, +bytes+ or +base64+.
|
160
|
+
#
|
161
|
+
# @param [String] claim_id The unique identifier of the claim
|
162
|
+
# @param [String] path The full path to the file's location
|
163
|
+
# @param [File] file instance of a File object
|
164
|
+
# @param [String] bytes The raw butes of the file
|
165
|
+
# @param [String] base64 The base64 encoded file
|
166
|
+
# @param [String] file_name The file's name (only required when not using +path+ or +file+)
|
167
|
+
# @param [String] file_type The file's mime type (only required when using +base64+)
|
168
|
+
# @param [String] description A description of the file
|
169
|
+
# @return [Hash]
|
170
|
+
#
|
171
|
+
def create_claim_attachment(claim_id:, path: nil, file: nil, bytes: nil, base64: nil, file_name: nil, file_type: nil, description: '')
|
172
|
+
data = if path
|
173
|
+
claim_attachment_from_path(path)
|
174
|
+
elsif file
|
175
|
+
claim_attachment_from_file(file)
|
176
|
+
elsif bytes
|
177
|
+
raise ArgumentError.new("file_name is required when supplying bytes") unless file_name
|
178
|
+
claim_attachment_from_bytes(bytes, file_name, file_type)
|
179
|
+
elsif base64
|
180
|
+
raise ArgumentError.new("file_name is required when supplying base64") unless file_name
|
181
|
+
raise ArgumentError.new("file_type is required when supplying base64") unless file_type
|
182
|
+
claim_attachment_from_base46(base64, file_name, file_type)
|
183
|
+
else
|
184
|
+
{}
|
185
|
+
end.merge({description: description})
|
186
|
+
|
187
|
+
post("claims/#{claim_id}/attachments", data)
|
188
|
+
end
|
189
|
+
|
190
|
+
private
|
191
|
+
def claim_attachment_from_path(path)
|
192
|
+
encoded_data = Base64.encode64(File.binread(path))
|
193
|
+
file_name = File.basename(path)
|
194
|
+
|
195
|
+
{
|
196
|
+
file_base64: encoded_data,
|
197
|
+
file_name: file_name,
|
198
|
+
file_type: MimeMagic.by_magic(File.open(path)).type
|
199
|
+
}
|
200
|
+
end
|
201
|
+
|
202
|
+
def claim_attachment_from_file(file)
|
203
|
+
encoded_data = Base64.encode64(file.read)
|
204
|
+
|
205
|
+
{
|
206
|
+
file_base64: encoded_data,
|
207
|
+
file_name: File.basename(file.path),
|
208
|
+
file_type: MimeMagic.by_magic(file).type
|
209
|
+
}
|
210
|
+
end
|
211
|
+
|
212
|
+
def claim_attachment_from_bytes(bytes, file_name, file_type)
|
213
|
+
encoded_data = Base64.encode64(bytes)
|
214
|
+
|
215
|
+
{
|
216
|
+
file_base64: encoded_data,
|
217
|
+
file_name: file_name,
|
218
|
+
file_type: file_type || MimeMagic.by_magic(bytes).type
|
219
|
+
}
|
220
|
+
end
|
221
|
+
|
222
|
+
def claim_attachment_from_base46(base64, file_name, file_type)
|
223
|
+
{
|
224
|
+
file_base64: base64,
|
225
|
+
file_name: file_name,
|
226
|
+
file_type: file_type
|
227
|
+
}
|
228
|
+
end
|
111
229
|
|
112
|
-
# Link a claim and a policy
|
113
|
-
#
|
114
|
-
# @param [String] claim_id The unique identifier of the claim.
|
115
|
-
# @param [String] policy_id The unique identifier of the policy.
|
116
|
-
# @return [Hash]
|
117
|
-
#
|
118
|
-
# @example
|
119
|
-
# client.link_policy_to_claim(claim_id: "d3d13c48-4dc3-4816-8d01-de3215878225", policy_id: "8349345c-a6c5-4bf9-8ebb-6bbfc1628715")
|
120
|
-
#
|
121
|
-
def link_policy_to_claim(claim_id:, policy_id:)
|
122
|
-
data = {policy_id: policy_id}
|
123
|
-
|
124
|
-
post("claims/#{claim_id}/policy", data)
|
125
230
|
end
|
126
|
-
|
127
|
-
|
128
|
-
# Link a claim and a policy holder
|
129
|
-
#
|
130
|
-
# @param [String] claim_id The unique identifier of the claim.
|
131
|
-
# @param [String] policyholder_id The unique identifier of the policy holder.
|
132
|
-
# @return [Hash]
|
133
|
-
#
|
134
|
-
# @example
|
135
|
-
# client.link_policyholder_to_claim(claim_id: "d3d13c48-4dc3-4816-8d01-de3215878225", policyholder_id: "808f75dc-cb8a-4808-93e9-e13f8eea84de")
|
136
|
-
#
|
137
|
-
def link_policyholder_to_claim(claim_id:, policyholder_id:)
|
138
|
-
data = {policyholder_id: policyholder_id}
|
139
|
-
|
140
|
-
post("claims/#{claim_id}/policyholder", data)
|
141
|
-
end
|
142
|
-
|
143
|
-
# List all claim events
|
144
|
-
#
|
145
|
-
# @param [String] claim_id The unique identifier of the claim.
|
146
|
-
# @return [Array<Hash>]
|
147
|
-
#
|
148
|
-
# @example
|
149
|
-
# client.list_claim_events(claim_id: "d3d13c48-4dc3-4816-8d01-de3215878225")
|
150
|
-
#
|
151
|
-
def list_claim_events(id: nil, claim_id: nil)
|
152
|
-
claim_id = claim_id || id
|
153
|
-
get("claims/#{claim_id}/events")
|
154
|
-
end
|
155
|
-
|
156
|
-
# Create a claim attachment
|
157
|
-
#
|
158
|
-
# The file data can be passed using either +path+, +file+, +bytes+ or +base64+.
|
159
|
-
#
|
160
|
-
# @param [String] claim_id The unique identifier of the claim
|
161
|
-
# @param [String] path The full path to the file's location
|
162
|
-
# @param [File] file instance of a File object
|
163
|
-
# @param [String] bytes The raw butes of the file
|
164
|
-
# @param [String] base64 The base64 encoded file
|
165
|
-
# @param [String] file_name The file's name (only required when not using +path+ or +file+)
|
166
|
-
# @param [String] file_type The file's mime type (only required when using +base64+)
|
167
|
-
# @param [String] description A description of the file
|
168
|
-
# @return [Hash]
|
169
|
-
#
|
170
|
-
def create_claim_attachment(claim_id:, path: nil, file: nil, bytes: nil, base64: nil, file_name: nil, file_type: nil, description: '')
|
171
|
-
data = if path
|
172
|
-
claim_attachment_from_path(path)
|
173
|
-
elsif file
|
174
|
-
claim_attachment_from_file(file)
|
175
|
-
elsif bytes
|
176
|
-
raise ArgumentError.new("file_name is required when supplying bytes") unless file_name
|
177
|
-
claim_attachment_from_bytes(bytes, file_name, file_type)
|
178
|
-
elsif base64
|
179
|
-
raise ArgumentError.new("file_name is required when supplying base64") unless file_name
|
180
|
-
raise ArgumentError.new("file_type is required when supplying base64") unless file_type
|
181
|
-
claim_attachment_from_base46(base64, file_name, file_type)
|
182
|
-
else
|
183
|
-
{}
|
184
|
-
end.merge({description: description})
|
185
|
-
|
186
|
-
post("claims/#{claim_id}/attachments", data)
|
187
|
-
end
|
188
|
-
|
189
|
-
private
|
190
|
-
def claim_attachment_from_path(path)
|
191
|
-
encoded_data = Base64.encode64(File.binread(path))
|
192
|
-
file_name = File.basename(path)
|
193
|
-
|
194
|
-
{
|
195
|
-
file_base64: encoded_data,
|
196
|
-
file_name: file_name,
|
197
|
-
file_type: MimeMagic.by_magic(File.open(path)).type
|
198
|
-
}
|
199
|
-
end
|
200
|
-
|
201
|
-
def claim_attachment_from_file(file)
|
202
|
-
encoded_data = Base64.encode64(file.read)
|
203
|
-
|
204
|
-
{
|
205
|
-
file_base64: encoded_data,
|
206
|
-
file_name: File.basename(file.path),
|
207
|
-
file_type: MimeMagic.by_magic(file).type
|
208
|
-
}
|
209
|
-
end
|
210
|
-
|
211
|
-
def claim_attachment_from_bytes(bytes, file_name, file_type)
|
212
|
-
encoded_data = Base64.encode64(bytes)
|
213
|
-
|
214
|
-
{
|
215
|
-
file_base64: encoded_data,
|
216
|
-
file_name: file_name,
|
217
|
-
file_type: file_type || MimeMagic.by_magic(bytes).type
|
218
|
-
}
|
219
|
-
end
|
220
|
-
|
221
|
-
def claim_attachment_from_base46(base64, file_name, file_type)
|
222
|
-
{
|
223
|
-
file_base64: base64,
|
224
|
-
file_name: file_name,
|
225
|
-
file_type: file_type
|
226
|
-
}
|
227
|
-
end
|
228
|
-
|
229
231
|
end
|
230
|
-
end
|
232
|
+
end
|