root_insurance 1.7.4 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75e3ae3ca5078705c6a87fa245c3acefad9dcfca
4
- data.tar.gz: 8f4d396c8d8d09d664807f94c1c96b0dd838c114
3
+ metadata.gz: 38199c8ed87d9e97b257db82410699f7ad6e4d1e
4
+ data.tar.gz: c9dc7652916e3f573f88362cb1444043c84eb043
5
5
  SHA512:
6
- metadata.gz: ec930d343623b1626cb5bbadce8149aa25e33a50c24d9b73e3fe771b48d95dd5b747a1aa5cbd494868e0e3e5d5f86ed9b8b0d94bad3c363ba44953ae6eaa9a5d
7
- data.tar.gz: aa96a45de85da0eaf866d8c9088c501fd30f3b35a380280a2057e2bfb23d2b7fd94dddd938fbf4d6e7504fd57e78b102d0ee6c93f29de43db761d1f7a4d10552
6
+ metadata.gz: 19350f52a045b3ebf508c34c11f74d9e68ee25241a4e672930a290c377f50b5a7ce0190a5c0e25b06b9f61cf68fc26a88df8e9793663332e09eedd112c48becc
7
+ data.tar.gz: 5b55dffc3ea93c055f3e0bf86e44ed6bb5179d34df4bd96a2474bc9e317ace06c4f5d0f5ccc58132e03532df96855bccd05f13555b12c11df7df68286de72d5f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ # 1.8.0 - Release date: 2018-17-05
4
+ * Removed old replace_policy method
5
+ * Add support to filter on id number when listing policy holders
6
+ * Added support to include oblects when getting a list of policy holders and a individual policy holder
7
+ * Added more documentation
8
+
9
+
3
10
  # 1.7.4 - Release date: 2018-16-05
4
11
  * Added claim and call documentation
5
12
 
data/README.md CHANGED
@@ -22,11 +22,18 @@ gem 'root_insurance'
22
22
 
23
23
  And then execute:
24
24
 
25
- $ bundle
25
+ ```bash
26
+ bundle
27
+ ```
26
28
 
27
- ## Usage
29
+ ## Quick start
30
+ 1. Create an instance of `RootInsurance::Client`
31
+ ```ruby
32
+ client = RootInsurance::Client.new("test_key_tYILz1640w9q5n5kNQUZ", '', :sandbox)
33
+ ```
28
34
 
29
- See the [wiki](https://github.com/root-community/root-insurance-ruby/wiki).
35
+ 2. Use the api
36
+ See the documentation [here](https://www.rubydoc.info/gems/root_insurance/).
30
37
 
31
38
  ## Contributing
32
39
  If you wish to contribute to this repository, please fork it and send a PR our way.
@@ -1,5 +1,32 @@
1
1
  module RootInsurance::Api
2
2
  module Payment
3
+
4
+ # Create a payment method
5
+ #
6
+ # @param [String] policy_holder_id The unique identifier of the policy holder.
7
+ # @param [String] type The payment method type. Curently only +'debit_order'+ is supported. If omitted, defaults to +'debit_order'+ (optional)
8
+ # @param [Hash] bank_details Bank details to use for the debit order. See below for details.
9
+ # @param [String] policy_ids The date on the which the incident occured. (optional)
10
+ # @return [Hash]
11
+ #
12
+ ## == Bank details
13
+ # [account_holder (string)] Name of account holder.
14
+ # [bank (string)] Bank name - one of [+absa+, +capitec+, +fnb+, +investec+, +nedbank+, +postbank+, +standard_bank+]
15
+ # [branch_code (string)] Branch code for bank account
16
+ # [account_number (string)] Bank account number
17
+ #
18
+ # @example
19
+ # bank_details = {
20
+ # first_name: "Erlich",
21
+ # last_name: "Bachman",
22
+ # bank: "absa",
23
+ # branch_code: "12345",
24
+ # account_number: "123456789"
25
+ # }
26
+ # client.create_payment_method(
27
+ # policy_holder_id: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e",
28
+ # bank_details: bank_details)
29
+ #
3
30
  def create_payment_method(policy_holder_id:, type: 'debit_order', bank_details: {}, policy_ids: nil)
4
31
  validate_bank_details(bank_details)
5
32
 
@@ -17,6 +44,16 @@ module RootInsurance::Api
17
44
  post("policyholders/#{policy_holder_id}/payment-methods", data)
18
45
  end
19
46
 
47
+ # Link a payment method to a policy
48
+ #
49
+ # @param [String] policy_id The unique identifier of the policy.
50
+ # @param [String] payment_method_id The unique identifier of the payment method.
51
+ #
52
+ # @example
53
+ # client.link_payment_method(
54
+ # policy_id: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e",
55
+ # payment_method_id: "e0b7b222-772f-47ac-b08d-c7ba38aa1b25")
56
+ #
20
57
  def link_payment_method(policy_id:, payment_method_id:)
21
58
  data = {payment_method_id: payment_method_id}
22
59
 
@@ -1,5 +1,17 @@
1
1
  module RootInsurance::Api
2
2
  module Policy
3
+
4
+ # Issue a policy
5
+ #
6
+ # @param [String] application_id The unique identifier of the application.
7
+ # @param [Hash, nil] app_data An object containing additional custom data for the policy.
8
+ # @return [Hash]
9
+ #
10
+ # @example
11
+ # client.issue_policy(
12
+ # application_id: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e",
13
+ # app_data: {gadget_colour: "Space Grey"})
14
+ #
3
15
  def issue_policy(application_id:, app_data: nil)
4
16
  data = {
5
17
  application_id: application_id,
@@ -10,57 +22,140 @@ module RootInsurance::Api
10
22
  post(:policies, data)
11
23
  end
12
24
 
13
- def add_policy_beneficiary(policy_id:, id:, first_name:, last_name:, percentage:)
25
+ # Add a benificiary to a policy
26
+ #
27
+ # @param [String] policy_id The unique identifier of the policy.
28
+ # @param [String] first_name The beneficiary's first name
29
+ # @param [String] last_name The beneficiary's last name
30
+ # @param [Hash] id An hash containing the beneficiary's identification number, type and country. See below.
31
+ # @param [Integer] percentage An integer representing the percentage of a claim payout that the beneficiary should receive.
32
+ # @param [String] cellphone Hash containing beneficiary's cellphone number and country. See below for details. (optional)
33
+ # @return [Hash]
34
+ #
35
+ ## == ID
36
+ # [type (string or symbol)] Either +:id+ or +:passport+
37
+ # [number (string)] The id or passport number
38
+ # [country (string)] The ISO Alpha-2 country code of the country of the id/passport number.
39
+ #
40
+ ## == Cellphone
41
+ # [number (string)] The cellphone number
42
+ # [country (string)] The ISO Alpha-2 country code of the country of the cellphone number.
43
+ #
44
+ # @example
45
+ # client.add_policy_beneficiary(
46
+ # policy_id: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e",
47
+ # first_name: "Jared"
48
+ # last_name: "Dunn",
49
+ # id: {type: :id, number: "8704094800082", country: "ZA"},
50
+ # percentage: 100)
51
+ #
52
+ def add_policy_beneficiary(policy_id:, id:, first_name:, last_name:, percentage:, cellphone: nil)
14
53
  raise ArgumentError.new('id needs to be a hash') unless id.is_a? Hash
15
54
 
16
55
  data = {
17
56
  id: id,
18
57
  first_name: first_name,
19
58
  last_name: last_name,
20
- percentage: percentage
21
- }
59
+ percentage: percentage,
60
+ cellphone: cellphone
61
+ }.reject { |k, v| v.nil? }
22
62
 
23
63
  put("policies/#{policy_id}/beneficiaries", data)
24
64
  end
25
65
 
66
+ # List policies
67
+ #
68
+ # @param [String] id_number The National ID Number of the policyholder (optional)
69
+ # @return [Array<Hash>]
70
+ #
71
+ # @example
72
+ # client.list_policies(id_number: "8704094800082")
73
+ #
26
74
  def list_policies(id_number: nil)
27
75
  query = id_number ? {id_number: id_number} : nil
28
76
 
29
77
  get(:policies, query)
30
78
  end
31
79
 
80
+ # Get a policy
81
+ #
82
+ # @param [String] id The unique identifier of the policy
83
+ # @return [Hash]
84
+ #
85
+ # @example
86
+ # client.get_policy(id: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e")
87
+ #
32
88
  def get_policy(id:)
33
89
  get("policies/#{id}")
34
90
  end
35
91
 
92
+ # Cancel a policy
93
+ #
94
+ # @param [String] id The unique identifier of the policy
95
+ # @param [String] reason A reason for why this policy is being cancelled.
96
+ # @return [Hash]
97
+ #
98
+ # @example
99
+ # client.cancel_policy(id: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e", reason: "Not needed anymore")
100
+ #
36
101
  def cancel_policy(id:, reason:)
37
102
  data = {reason: reason}
38
103
 
39
104
  post("policies/#{id}/cancel", data)
40
105
  end
41
106
 
107
+ # Update a policy.
108
+ # Currently, only updating the app_data object is supported
109
+ #
110
+ # @param [String] id The unique identifier of the policy
111
+ # @param [Hash] app_data An object containing additional custom data for the policy.
112
+ # @return [Hash]
113
+ #
114
+ # @example
115
+ # app_data = {gadget_color: "Space Grey", has_screen_cover: true}
116
+ # client.update_policy(id: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e", app_data: app_data)
117
+ #
42
118
  def update_policy(id:, app_data:)
43
119
  data = {app_data: app_data}
44
120
 
45
121
  patch("policies/#{id}", data)
46
122
  end
47
123
 
48
- def replace_policy(id:, quote_package_id:)
49
- data = {quote_package_id: quote_package_id}
50
-
51
- post("policies/#{id}/replace", data)
52
- end
53
-
124
+ # Update a policy's billing amount.
125
+ #
126
+ # @param [String] id The unique identifier of the policy
127
+ # @param [Integer] billing_amount The billing amount to be set on the policy in cents.
128
+ # @return [Hash]
129
+ #
130
+ # @example
131
+ # client.update_policy_billing_amount(id: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e", billing_amount: 45000)
132
+ #
54
133
  def update_policy_billing_amount(id:, billing_amount:)
55
134
  data = {billing_amount: billing_amount}
56
135
 
57
136
  post("policies/#{id}/billing_amount", data)
58
137
  end
59
138
 
139
+ # List a policy's bebeficiaries
140
+ #
141
+ # @param [String] id The unique identifier of the policy
142
+ # @return [Array<Hash>]
143
+ #
144
+ # @example
145
+ # client.list_policy_beneficiaries(id: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e")
146
+ #
60
147
  def list_policy_beneficiaries(id:)
61
148
  get("policies/#{id}/beneficiaries")
62
149
  end
63
150
 
151
+ # List all the events which are applicable to this policy.
152
+ #
153
+ # @param [String] id The unique identifier of the policy
154
+ # @return [Array<Hash>]
155
+ #
156
+ # @example
157
+ # client.list_policy_events(id: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e")
158
+ #
64
159
  def list_policy_events(id:)
65
160
  get("policies/#{id}/events")
66
161
  end
@@ -1,5 +1,33 @@
1
1
  module RootInsurance::Api
2
2
  module PolicyHolder
3
+ # Create a policy holder
4
+ #
5
+ # @param [Hash] id Hash containing policyholder's identification number, type and country. See below for details.
6
+ # @param [String] first_name Policyholder's legal first name.
7
+ # @param [String] last_name Policyholder's legal last name.
8
+ # @param [String] email Policyholder's contact email address. (Optional)
9
+ # @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+.
10
+ # @param [Hash] cellphone Hash containing policyholder's cellphone number and country. See below for details. (Optional)
11
+ # @param [Hash] app_data A hash containing additional custom data for the policy holder.
12
+ # @return [Hash]
13
+ #
14
+ ## == ID
15
+ # [type (string or symbol)] Either +:id+ or +:passport+
16
+ # [number (string)] The id or passport number
17
+ # [country (string)] The ISO Alpha-2 country code of the country of the id/passport number.
18
+ #
19
+ ## == Cellphone
20
+ # [number (string)] The cellphone number
21
+ # [country (string)] The ISO Alpha-2 country code of the country of the cellphone number.
22
+ #
23
+ # @example
24
+ # client.create_policy_holder(
25
+ # id: {type: :id, number: "6801015800084", country: "ZA"},
26
+ # first_name: 'Erlich',
27
+ # last_name: 'Bachman',
28
+ # email: 'erlich@avaito.com',
29
+ # app_data: {company: 'Aviato'})
30
+ #
3
31
  def create_policy_holder(id:, first_name:, last_name:, email: nil, date_of_birth: nil, cellphone: nil, app_data: nil)
4
32
  raise ArgumentError.new('id needs to be a hash') unless id.is_a? Hash
5
33
 
@@ -16,14 +44,58 @@ module RootInsurance::Api
16
44
  post(:policyholders, data)
17
45
  end
18
46
 
19
- def list_policy_holders
20
- get(:policyholders)
47
+ # List policy holders
48
+ #
49
+ # @param [Hash] id_number An optional ID or passport number to filter by.
50
+ # @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.
51
+ # @return [Array<Hash>]
52
+ #
53
+ # @example
54
+ # client.list_policy_holders(id_number: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e", included_objects: :policies)
55
+ def list_policy_holders(id_number: nil, included_objects: nil)
56
+ query = {
57
+ include: format_included_objects(included_objects),
58
+ id_number: id_number
59
+ }.reject { |_, v| v.nil? }
60
+
61
+ get(:policyholders, query)
21
62
  end
22
63
 
23
- def get_policy_holder(id:)
24
- get("policyholders/#{id}")
64
+ # Get a policy holder
65
+ #
66
+ # @param [String] id The unique identifier of the policy holder
67
+ # @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.
68
+ # @return [Hash]
69
+ #
70
+ # @example
71
+ # client.get_policy_holder(id: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e", included_objects: :policies)
72
+ #
73
+ def get_policy_holder(id:, included_objects: nil)
74
+ query = {
75
+ include: format_included_objects(included_objects),
76
+ }.reject { |_, v| v.nil? }
77
+
78
+ get("policyholders/#{id}", query)
25
79
  end
26
80
 
81
+ # Update a policy holder
82
+ #
83
+ # @param [String] id The unique identifier of the policy holder
84
+ # @param [String] email Policyholder's contact email address. (Optional)
85
+ # @param [Hash] cellphone Hash containing policyholder's cellphone number and country. See below for details. (Optional)
86
+ # @param [Hash] app_data A hash containing additional custom data for the policy holder.
87
+ # @return [Hash]
88
+ #
89
+ ## == Cellphone
90
+ # [number (string)] The cellphone number
91
+ # [country (string)] The ISO Alpha-2 country code of the country of the cellphone number.
92
+ #
93
+ # @example
94
+ # client.update_policy_holders(
95
+ # id: 'bf1ada91-eecb-4f47-9bfa-1258bb1e0055',
96
+ # cellphone: {number: '07741011337', country: 'ZA'},
97
+ # app_data: {company: 'Pied Piper'})
98
+ #
27
99
  def update_policy_holder(id:, email: nil, cellphone: nil, app_data: nil)
28
100
  data = {
29
101
  email: email,
@@ -34,8 +106,26 @@ module RootInsurance::Api
34
106
  patch("policyholders/#{id}", data)
35
107
  end
36
108
 
109
+ # List all the events which are applicable to this policy holder.
110
+ #
111
+ # @param [String] id The unique identifier of the policy holder
112
+ # @return [Array<Hash>]
113
+ #
114
+ # @example
115
+ # client.list_policy_holder_events(id: "128ba0c0-3f6a-4f8b-9b40-e2066b02b59e")
116
+ #
37
117
  def list_policy_holder_events(id:)
38
118
  get("policyholders/#{id}/events")
39
119
  end
120
+
121
+ private
122
+ def format_included_objects(included_objects)
123
+ case included_objects
124
+ when String, Symbol
125
+ included_objects
126
+ when Array
127
+ included_objects.join(",")
128
+ end
129
+ end
40
130
  end
41
131
  end
@@ -1,5 +1,33 @@
1
1
  module RootInsurance::Api
2
2
  module Quote
3
+ # Create a quote
4
+ #
5
+ # @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
6
+ # @return [Hash]
7
+ #
8
+ ## == +:root_gadgets+
9
+ # [model_name (String)] The model name of the gadget
10
+ #
11
+ ## == +:root_term+
12
+ # [cover_amount (Integer)] Amount to cover, in cents. Should be between R100 000 and R5 000 000, inclusive.
13
+ # [cover_period (String or Symbol)] Duration to cover: +:1_year+, +:2_years+, +:5_years+, +:10_years+, +:15_years+, +:20_years+ or +:whole_life+.
14
+ # [basic_income_per_month (Integer)] Policyholder's basic monthly income, in cents.
15
+ # [education_status (String or Symbol)] Policyholder’s education class: +:grade_12_no_matric+, +:grade_12_matric+, +:diploma_or_btech+, +:undergraduate_degree+ or +:professional_degree+
16
+ # [smoker (Boolean)] Is the policyholder a smoker.
17
+ # [gender (String or Symbol)] Gender of policyholder. Should be either +:male+ or +:female+.
18
+ # [age (Integer)] Age of policyholder. Should be between 18 and 63, inclusive.
19
+ #
20
+ # == +:root_funeral+
21
+ # [cover_amount (Integer)] Amount to cover, in cents. Should be between R10k and R50k, inclusive.
22
+ # [has_spouse (Boolean)] Should a spouse also be covered.
23
+ # [number_of_children (Integer)] Number of children to include in the policy. Should be between 0 and 8, inclusive
24
+ # [extended_family_ages (Array<Integer>)] Ages of extended family members to cover.
25
+ #
26
+ # @example
27
+ # client.create_quote(
28
+ # type: :root_gadgets,
29
+ # model_name: 'iPhone 6s 64GB LTE')
30
+ #
3
31
  def create_quote(opts={})
4
32
  type = opts[:type]
5
33
 
@@ -15,6 +43,13 @@ module RootInsurance::Api
15
43
  end
16
44
  end
17
45
 
46
+ # List available gadget models
47
+ #
48
+ # @return [Array<Hash>]
49
+ #
50
+ # @example
51
+ # client.list_gadget_models
52
+ #
18
53
  def list_gadget_models
19
54
  get('gadgets/models')
20
55
  end
@@ -1,3 +1,3 @@
1
1
  module RootInsurance
2
- VERSION = "1.7.4"
2
+ VERSION = "1.8.0"
3
3
  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.7.4
4
+ version: 1.8.0
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-05-16 00:00:00.000000000 Z
11
+ date: 2018-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty