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
@@ -1,131 +1,133 @@
|
|
1
|
-
module RootInsurance
|
2
|
-
module
|
3
|
-
|
4
|
-
|
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
|
-
|
1
|
+
module RootInsurance
|
2
|
+
module Api
|
3
|
+
module Policyholder
|
4
|
+
# Create a policy holder
|
5
|
+
#
|
6
|
+
# @param [Hash] id Hash containing policyholder's identification number, type and country. See below for details.
|
7
|
+
# @param [String] first_name Policyholder's legal first name.
|
8
|
+
# @param [String] last_name Policyholder's legal last name.
|
9
|
+
# @param [String] email Policyholder's contact email address. (Optional)
|
10
|
+
# @param [String] date_of_birth The policyholder's date of birth in the format YYYYMMDD. This field may be omitted if the policyholder's id type is +id+.
|
11
|
+
# @param [Hash] cellphone Hash containing policyholder's cellphone number and country. See below for details. (Optional)
|
12
|
+
# @param [Hash] app_data A hash containing additional custom data for the policy holder.
|
13
|
+
# @return [Hash]
|
14
|
+
#
|
15
|
+
## == ID
|
16
|
+
# [type (string or symbol)] Either +:id+ or +:passport+
|
17
|
+
# [number (string)] The id or passport number
|
18
|
+
# [country (string)] The ISO Alpha-2 country code of the country of the id/passport number.
|
19
|
+
#
|
20
|
+
## == Cellphone
|
21
|
+
# [number (string)] The cellphone number
|
22
|
+
# [country (string)] The ISO Alpha-2 country code of the country of the cellphone number.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# client.create_policy_holder(
|
26
|
+
# id: {type: :id, number: "6801015800084", country: "ZA"},
|
27
|
+
# first_name: 'Erlich',
|
28
|
+
# last_name: 'Bachman',
|
29
|
+
# email: 'erlich@avaito.com',
|
30
|
+
# app_data: {company: 'Aviato'})
|
31
|
+
#
|
32
|
+
def create_policyholder(id:, first_name:, last_name:, email: nil, date_of_birth: nil, cellphone: nil, app_data: nil)
|
33
|
+
raise ArgumentError.new('id needs to be a hash') unless id.is_a? Hash
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
data = {
|
36
|
+
id: id,
|
37
|
+
first_name: first_name,
|
38
|
+
last_name: last_name,
|
39
|
+
date_of_birth: date_of_birth,
|
40
|
+
email: email,
|
41
|
+
cellphone: cellphone,
|
42
|
+
app_data: app_data
|
43
|
+
}.reject { |key, value| value.nil? }
|
43
44
|
|
44
|
-
|
45
|
-
|
45
|
+
post(:policyholders, data)
|
46
|
+
end
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
48
|
+
# List policy holders
|
49
|
+
#
|
50
|
+
# @param [Hash] id_number An optional ID or passport number to filter by.
|
51
|
+
# @param [Array<String, Symbol>, String, Symbol] included_objects An optional list, or single item, of underlying objects to include, e.g. +?include=policies+. Currently, only +policies+ is supported, which will include all policies owned by the policyholder.
|
52
|
+
# @return [Array<Hash>]
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
# client.list_policyholders(id_number: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e", included_objects: :policies)
|
56
|
+
def list_policyholders(id_number: nil, included_objects: nil)
|
57
|
+
query = {
|
58
|
+
include: format_included_objects(included_objects),
|
59
|
+
id_number: id_number
|
60
|
+
}.reject { |_, v| v.nil? }
|
60
61
|
|
61
|
-
|
62
|
-
|
62
|
+
get(:policyholders, query)
|
63
|
+
end
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
65
|
+
# Get a policy holder
|
66
|
+
#
|
67
|
+
# @param [String] id The unique identifier of the policy holder
|
68
|
+
# @param [Array<String, Symbol>, String, Symbol] included_objects An optional list, or single item, of underlying objects to include, e.g. +?include=policies+. Currently, only +policies+ is supported, which will include all policies owned by the policyholder.
|
69
|
+
# @return [Hash]
|
70
|
+
#
|
71
|
+
# @example
|
72
|
+
# client.get_policyholder(id: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e", included_objects: :policies)
|
73
|
+
#
|
74
|
+
def get_policyholder(id:, included_objects: nil)
|
75
|
+
query = {
|
76
|
+
include: format_included_objects(included_objects),
|
77
|
+
}.reject { |_, v| v.nil? }
|
77
78
|
|
78
|
-
|
79
|
-
|
79
|
+
get("policyholders/#{id}", query)
|
80
|
+
end
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
82
|
+
# Update a policy holder
|
83
|
+
#
|
84
|
+
# @param [String] id The unique identifier of the policy holder
|
85
|
+
# @param [String] email Policyholder's contact email address. (Optional)
|
86
|
+
# @param [Hash] cellphone Hash containing policyholder's cellphone number and country. See below for details. (Optional)
|
87
|
+
# @param [Hash] app_data A hash containing additional custom data for the policy holder.
|
88
|
+
# @return [Hash]
|
89
|
+
#
|
90
|
+
## == Cellphone
|
91
|
+
# [number (string)] The cellphone number
|
92
|
+
# [country (string)] The ISO Alpha-2 country code of the country of the cellphone number.
|
93
|
+
#
|
94
|
+
# @example
|
95
|
+
# client.update_policyholders(
|
96
|
+
# id: 'bf1ada91-eecb-4f47-9bfa-1258bb1e0055',
|
97
|
+
# cellphone: {number: '07741011337', country: 'ZA'},
|
98
|
+
# app_data: {company: 'Pied Piper'})
|
99
|
+
#
|
100
|
+
def update_policyholder(id:, email: nil, cellphone: nil, app_data: nil)
|
101
|
+
data = {
|
102
|
+
email: email,
|
103
|
+
cellphone: cellphone,
|
104
|
+
app_data: app_data
|
105
|
+
}.reject { |key, value| value.nil? }
|
105
106
|
|
106
|
-
|
107
|
-
|
107
|
+
patch("policyholders/#{id}", data)
|
108
|
+
end
|
108
109
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
110
|
+
# List all the events which are applicable to this policy holder.
|
111
|
+
#
|
112
|
+
# @param [String] id The unique identifier of the policy holder
|
113
|
+
# @return [Array<Hash>]
|
114
|
+
#
|
115
|
+
# @example
|
116
|
+
# client.list_policyholder_events(id: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e")
|
117
|
+
#
|
118
|
+
def list_policyholder_events(id:)
|
119
|
+
get("policyholders/#{id}/events")
|
120
|
+
end
|
120
121
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
122
|
+
private
|
123
|
+
def format_included_objects(included_objects)
|
124
|
+
case included_objects
|
125
|
+
when String, Symbol
|
126
|
+
included_objects
|
127
|
+
when Array
|
128
|
+
included_objects.join(",")
|
129
|
+
end
|
128
130
|
end
|
129
131
|
end
|
130
132
|
end
|
131
|
-
end
|
133
|
+
end
|
@@ -1,94 +1,95 @@
|
|
1
|
-
module RootInsurance
|
2
|
-
module
|
3
|
-
|
4
|
-
|
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
|
-
|
1
|
+
module RootInsurance
|
2
|
+
module Api
|
3
|
+
module Quote
|
4
|
+
# Create a quote
|
5
|
+
#
|
6
|
+
# @param [Hash] opts The quote details. Depending on +:type+, different options are available. Available types are: +:root_gadgets+, +:root_term+ and +:root_funeral+ See below for details
|
7
|
+
# @return [Hash]
|
8
|
+
#
|
9
|
+
## == +:root_gadgets+
|
10
|
+
# [model_name (String)] The model name of the gadget
|
11
|
+
#
|
12
|
+
## == +:root_term+
|
13
|
+
# [cover_amount (Integer)] Amount to cover, in cents. Should be between R100 000 and R5 000 000, inclusive.
|
14
|
+
# [cover_period (String or Symbol)] Duration to cover: +:1_year+, +:2_years+, +:5_years+, +:10_years+, +:15_years+, +:20_years+ or +:whole_life+.
|
15
|
+
# [basic_income_per_month (Integer)] Policyholder's basic monthly income, in cents.
|
16
|
+
# [education_status (String or Symbol)] Policyholder’s education class: +:grade_12_no_matric+, +:grade_12_matric+, +:diploma_or_btech+, +:undergraduate_degree+ or +:professional_degree+
|
17
|
+
# [smoker (Boolean)] Is the policyholder a smoker.
|
18
|
+
# [gender (String or Symbol)] Gender of policyholder. Should be either +:male+ or +:female+.
|
19
|
+
# [age (Integer)] Age of policyholder. Should be between 18 and 63, inclusive.
|
20
|
+
#
|
21
|
+
# == +:root_funeral+
|
22
|
+
# [cover_amount (Integer)] Amount to cover, in cents. Should be between R10k and R50k, inclusive.
|
23
|
+
# [has_spouse (Boolean)] Should a spouse also be covered.
|
24
|
+
# [number_of_children (Integer)] Number of children to include in the policy. Should be between 0 and 8, inclusive
|
25
|
+
# [extended_family_ages (Array<Integer>)] Ages of extended family members to cover.
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
# client.create_quote(
|
29
|
+
# type: :root_gadgets,
|
30
|
+
# model_name: 'iPhone 6s 64GB LTE')
|
31
|
+
#
|
32
|
+
def create_quote(opts={})
|
33
|
+
type = opts[:type]
|
34
|
+
case type.to_sym
|
35
|
+
when :root_gadgets
|
36
|
+
create_gadget_quote(opts)
|
37
|
+
when :root_term
|
38
|
+
create_term_quote(opts)
|
39
|
+
when :root_funeral
|
40
|
+
create_funeral_quote(opts)
|
41
|
+
else
|
42
|
+
raise ArgumentError("Unknown quote type: #{type}")
|
43
|
+
end
|
43
44
|
end
|
44
|
-
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
46
|
+
# List available gadget models
|
47
|
+
#
|
48
|
+
# @return [Array<Hash>]
|
49
|
+
#
|
50
|
+
# @example
|
51
|
+
# client.list_gadget_models
|
52
|
+
#
|
53
|
+
def list_gadget_models
|
54
|
+
get('gadgets/models')
|
55
|
+
end
|
56
56
|
|
57
|
-
|
58
|
-
def create_gadget_quote(opts)
|
59
|
-
data = {
|
60
|
-
type: :root_gadgets,
|
61
|
-
model_name: opts[:model_name]
|
62
|
-
}
|
57
|
+
private
|
63
58
|
|
64
|
-
|
65
|
-
|
59
|
+
def create_gadget_quote(opts)
|
60
|
+
data = {
|
61
|
+
type: :root_gadgets,
|
62
|
+
model_name: opts[:model_name]
|
63
|
+
}
|
66
64
|
|
67
|
-
|
68
|
-
|
69
|
-
type: :root_term,
|
70
|
-
cover_amount: opts[:cover_amount],
|
71
|
-
cover_period: opts[:cover_period],
|
72
|
-
education_status: opts[:education_status],
|
73
|
-
smoker: opts[:smoker],
|
74
|
-
gender: opts[:gender],
|
75
|
-
age: opts[:age],
|
76
|
-
basic_income_per_month: opts[:basic_income_per_month],
|
77
|
-
}
|
65
|
+
post(:quotes, data)
|
66
|
+
end
|
78
67
|
|
79
|
-
|
80
|
-
|
68
|
+
def create_term_quote(opts)
|
69
|
+
data = {
|
70
|
+
type: :root_term,
|
71
|
+
cover_amount: opts[:cover_amount],
|
72
|
+
cover_period: opts[:cover_period],
|
73
|
+
education_status: opts[:education_status],
|
74
|
+
smoker: opts[:smoker],
|
75
|
+
gender: opts[:gender],
|
76
|
+
age: opts[:age],
|
77
|
+
basic_income_per_month: opts[:basic_income_per_month],
|
78
|
+
}
|
81
79
|
|
82
|
-
|
83
|
-
|
84
|
-
type: :root_funeral,
|
85
|
-
cover_amount: opts[:cover_amount],
|
86
|
-
has_spouse: opts[:has_spouse],
|
87
|
-
number_of_children: opts[:number_of_children],
|
88
|
-
extended_family_ages: opts[:extended_family_ages]
|
89
|
-
}
|
80
|
+
post(:quotes, data)
|
81
|
+
end
|
90
82
|
|
91
|
-
|
83
|
+
def create_funeral_quote(opts)
|
84
|
+
data = {
|
85
|
+
type: :root_funeral,
|
86
|
+
cover_amount: opts[:cover_amount],
|
87
|
+
has_spouse: opts[:has_spouse],
|
88
|
+
number_of_children: opts[:number_of_children],
|
89
|
+
extended_family_ages: opts[:extended_family_ages]
|
90
|
+
}
|
91
|
+
post(:quotes, data)
|
92
|
+
end
|
92
93
|
end
|
93
94
|
end
|
94
95
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: root_insurance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Root Wealth
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
version: '0'
|
171
171
|
requirements: []
|
172
172
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.
|
173
|
+
rubygems_version: 2.7.7
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: Root Insurance API client
|