starkinfra 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcode_preview/brcode_preview.rb +22 -4
  3. data/lib/brcode_preview/subscription.rb +2 -2
  4. data/lib/business_account_request/business_account_request.rb +276 -0
  5. data/lib/{individual_document → business_account_request}/log.rb +35 -35
  6. data/lib/business_attachment/business_attachment.rb +6 -3
  7. data/lib/business_identity/business_identity.rb +7 -4
  8. data/lib/credit_holmes/credit_holmes.rb +2 -1
  9. data/lib/credit_holmes/log.rb +125 -0
  10. data/lib/credit_note/credit_note.rb +42 -5
  11. data/lib/credit_note/rule.rb +9 -0
  12. data/lib/credit_note/transfer.rb +1 -1
  13. data/lib/credit_preview/credit_note_preview.rb +10 -2
  14. data/lib/credit_preview/credit_preview.rb +2 -1
  15. data/lib/credit_signer/credit_signer.rb +27 -2
  16. data/lib/dynamic_brcode/dynamic_brcode.rb +5 -2
  17. data/lib/event/event.rb +2 -2
  18. data/lib/individual_account_attachment/individual_account_attachment.rb +178 -0
  19. data/lib/individual_account_attachment/log.rb +124 -0
  20. data/lib/individual_account_request/individual_account_request.rb +271 -0
  21. data/lib/individual_account_request/log.rb +124 -0
  22. data/lib/individual_identity/individual_identity.rb +4 -7
  23. data/lib/issuing_card/issuing_card.rb +5 -4
  24. data/lib/issuing_design/issuing_design.rb +9 -0
  25. data/lib/issuing_embossing_request/issuing_embossing_request.rb +3 -2
  26. data/lib/issuing_holder/issuing_holder.rb +6 -5
  27. data/lib/issuing_product/issuing_product.rb +2 -2
  28. data/lib/issuing_purchase/issuing_purchase.rb +25 -1
  29. data/lib/issuing_restock/issuing_restock.rb +3 -2
  30. data/lib/issuing_rule/issuing_rule.rb +36 -0
  31. data/lib/issuing_stock_rule/issuing_stock_rule.rb +6 -5
  32. data/lib/issuing_token/issuing_token.rb +2 -2
  33. data/lib/issuing_token/log.rb +127 -0
  34. data/lib/issuing_token_activation/issuing_token_activation.rb +62 -0
  35. data/lib/issuing_token_request/issuing_token_request.rb +1 -1
  36. data/lib/issuing_withdrawal/issuing_withdrawal.rb +2 -2
  37. data/lib/ledger/ledger.rb +175 -0
  38. data/lib/ledger/log.rb +122 -0
  39. data/lib/ledger/rule.rb +55 -0
  40. data/lib/ledger_transaction/ledger_transaction.rb +179 -0
  41. data/lib/pix_balance/pix_balance.rb +1 -1
  42. data/lib/pix_chargeback/pix_chargeback.rb +10 -7
  43. data/lib/pix_claim/pix_claim.rb +14 -6
  44. data/lib/pix_director/pix_director.rb +1 -1
  45. data/lib/pix_dispute/pix_dispute.rb +1 -1
  46. data/lib/pix_dispute/transaction.rb +4 -4
  47. data/lib/pix_fraud/pix_fraud.rb +1 -1
  48. data/lib/pix_infraction/pix_infraction.rb +21 -5
  49. data/lib/pix_internal_transaction_report/pix_internal_transaction_report.rb +1 -1
  50. data/lib/pix_key/pix_key.rb +1 -1
  51. data/lib/pix_key_holmes/log.rb +129 -0
  52. data/lib/pix_key_holmes/pix_key_holmes.rb +19 -2
  53. data/lib/pix_pull_request/pix_pull_request.rb +6 -3
  54. data/lib/pix_pull_subscription/pix_pull_subscription.rb +31 -5
  55. data/lib/pix_request/pix_request.rb +13 -7
  56. data/lib/pix_reversal/pix_reversal.rb +14 -8
  57. data/lib/pix_statement/pix_statement.rb +11 -5
  58. data/lib/pix_user/pix_user.rb +52 -0
  59. data/lib/pix_user/statistics.rb +64 -0
  60. data/lib/starkinfra.rb +20 -3
  61. data/lib/static_brcode/static_brcode.rb +8 -4
  62. data/lib/utils/bacen_id.rb +27 -0
  63. data/lib/utils/end_to_end_id.rb +20 -0
  64. data/lib/utils/pix_subscription_bacen_id.rb +21 -0
  65. data/lib/utils/return_id.rb +1 -4
  66. data/lib/webhook/webhook.rb +2 -2
  67. metadata +21 -4
  68. data/lib/individual_document/individual_document.rb +0 -164
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+ require_relative('individual_account_attachment')
6
+
7
+ module StarkInfra
8
+ class IndividualAccountAttachment
9
+ # # IndividualAccountAttachment::Log object
10
+ #
11
+ # Every time an IndividualAccountAttachment entity is modified, a corresponding IndividualAccountAttachment::Log
12
+ # is generated for the entity. This Log is never generated by the user, but it can be retrieved to check
13
+ # additional information on the IndividualAccountAttachment.
14
+ #
15
+ # ## Attributes (return-only):
16
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
17
+ # - attachment [IndividualAccountAttachment]: IndividualAccountAttachment entity to which the log refers to.
18
+ # - errors [list of strings]: list of errors linked to this IndividualAccountAttachment event.
19
+ # - type [string]: type of the IndividualAccountAttachment event which triggered the log creation. Options: 'created', 'success', 'failed', 'deleted'
20
+ # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
21
+ class Log < StarkCore::Utils::Resource
22
+ attr_reader :id, :attachment, :errors, :type, :created
23
+ def initialize(id: nil, attachment: nil, errors: nil, type: nil, created: nil)
24
+ super(id)
25
+ @attachment = attachment
26
+ @errors = errors
27
+ @type = type
28
+ @created = StarkCore::Utils::Checks.check_datetime(created)
29
+ end
30
+
31
+ # # Retrieve a specific IndividualAccountAttachment::Log
32
+ #
33
+ # Receive a single IndividualAccountAttachment::Log object previously created by the Stark Infra API by passing its id
34
+ #
35
+ # ## Parameters (required):
36
+ # - id [string]: object unique id. ex: '5656565656565656'
37
+ #
38
+ # ## Parameters (optional):
39
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
40
+ #
41
+ # ## Return:
42
+ # - IndividualAccountAttachment::Log object with updated attributes
43
+ def self.get(id, user: nil)
44
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
45
+ end
46
+
47
+ # # Retrieve IndividualAccountAttachment::Logs
48
+ #
49
+ # Receive a generator of IndividualAccountAttachment::Log objects previously created in the Stark Infra API
50
+ #
51
+ # ## Parameters (optional):
52
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
53
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
54
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
55
+ # - types [list of strings, default nil]: filter for log event types. Options: 'created', 'success', 'failed', 'deleted'
56
+ # - attachment_ids [list of strings, default nil]: list of IndividualAccountAttachment ids to filter logs. ex: ['5656565656565656', '4545454545454545']
57
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
58
+ #
59
+ # ## Return:
60
+ # - generator of IndividualAccountAttachment::Log objects with updated attributes
61
+ def self.query(limit: nil, after: nil, before: nil, types: nil, attachment_ids: nil, user: nil)
62
+ after = StarkCore::Utils::Checks.check_date(after)
63
+ before = StarkCore::Utils::Checks.check_date(before)
64
+ StarkInfra::Utils::Rest.get_stream(
65
+ limit: limit,
66
+ after: after,
67
+ before: before,
68
+ types: types,
69
+ attachment_ids: attachment_ids,
70
+ user: user,
71
+ **resource
72
+ )
73
+ end
74
+
75
+ # # Retrieve paged IndividualAccountAttachment::Logs
76
+ #
77
+ # Receive a list of up to 100 IndividualAccountAttachment::Log objects previously created in the Stark Infra API and the cursor to the next page.
78
+ # Use this function instead of query if you want to manually page your requests.
79
+ #
80
+ # ## Parameters (optional):
81
+ # - cursor [string, default nil]: cursor returned on the previous page function call
82
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
83
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
84
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
85
+ # - types [list of strings, default nil]: filter for log event types. Options: 'created', 'success', 'failed', 'deleted'
86
+ # - attachment_ids [list of strings, default nil]: list of IndividualAccountAttachment ids to filter logs. ex: ['5656565656565656', '4545454545454545']
87
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
88
+ #
89
+ # ## Return:
90
+ # - list of IndividualAccountAttachment::Log objects with updated attributes
91
+ # - cursor to retrieve the next page of Log objects
92
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, attachment_ids: nil, user: nil)
93
+ after = StarkCore::Utils::Checks.check_date(after)
94
+ before = StarkCore::Utils::Checks.check_date(before)
95
+ StarkInfra::Utils::Rest.get_page(
96
+ cursor: cursor,
97
+ limit: limit,
98
+ after: after,
99
+ before: before,
100
+ types: types,
101
+ attachment_ids: attachment_ids,
102
+ user: user,
103
+ **resource
104
+ )
105
+ end
106
+
107
+ def self.resource
108
+ attachment_maker = StarkInfra::IndividualAccountAttachment.resource[:resource_maker]
109
+ {
110
+ resource_name: 'IndividualAccountAttachmentLog',
111
+ resource_maker: proc { |json|
112
+ Log.new(
113
+ id: json['id'],
114
+ attachment: StarkCore::Utils::API.from_api_json(attachment_maker, json['attachment']),
115
+ errors: json['errors'],
116
+ type: json['type'],
117
+ created: json['created']
118
+ )
119
+ }
120
+ }
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,271 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+
6
+ module StarkInfra
7
+ # # IndividualAccountRequest object
8
+ #
9
+ # Request to open a Stark Infra account for an individual. The caller submits the individual's
10
+ # identifying data and income, and the API runs the approval flow asynchronously. Supporting
11
+ # documents are uploaded as IndividualAccountAttachment objects referencing this request.
12
+ #
13
+ # When you initialize an IndividualAccountRequest, the entity will not be automatically
14
+ # created in the Stark Infra API. The 'create' function sends the objects
15
+ # to the Stark Infra API and returns the list of created objects.
16
+ #
17
+ # ## Parameters (required):
18
+ # - name [string]: full legal name of the individual. ex: 'Tony Stark'
19
+ # - tax_id [string]: individual's Brazilian CPF. ex: '012.345.678-90' or '01234567890'
20
+ # - address [IndividualAccountRequest::Address object]: structured residential address.
21
+ # - income [integer]: monthly income in cents. Must be >= 0. ex: 1000000 (= R$ 10,000.00)
22
+ #
23
+ # ## Parameters (optional):
24
+ # - birth_date [Date or string, default nil]: individual's birth date. Returned as nil when not informed. ex: Date.new(2012, 3, 6) or '2012-03-06'
25
+ # - tags [list of strings, default nil]: list of strings for reference when searching for IndividualAccountRequests. ex: ['employees', 'monthly']
26
+ #
27
+ # ## Attributes (return-only):
28
+ # - id [string]: unique id returned when the IndividualAccountRequest is created. ex: '5656565656565656'
29
+ # - status [string]: current status of the IndividualAccountRequest. Options: 'created', 'processing', 'approved', 'denied', 'failed'
30
+ # - account_type [string]: account type of the request. Always 'individual' for this resource. ex: 'individual'
31
+ # - flags [list of hashes]: flags raised by the KYC pipeline, populated when the request is denied. Each flag has a code and a message. ex: [{ 'code' => 'bureauValidation', 'message' => '...' }]
32
+ # - validator_link [string]: webview link to be delivered to the taker to complete biometrics and document capture.
33
+ # - created [DateTime]: creation datetime for the IndividualAccountRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
34
+ # - updated [DateTime]: latest update datetime for the IndividualAccountRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
35
+ class IndividualAccountRequest < StarkCore::Utils::Resource
36
+ attr_reader :name, :tax_id, :address, :income, :birth_date, :tags, :id, :status, :account_type, :flags, :validator_link, :created, :updated
37
+ def initialize(
38
+ name:, tax_id:, address:, income:, birth_date: nil, tags: nil,
39
+ id: nil, status: nil, account_type: nil, flags: nil, validator_link: nil, created: nil, updated: nil
40
+ )
41
+ super(id)
42
+ @name = name
43
+ @tax_id = tax_id
44
+ @address = IndividualAccountRequest::Address.parse_address(address)
45
+ @income = income
46
+ @birth_date = birth_date.to_s.empty? ? nil : StarkCore::Utils::Checks.check_date(birth_date)
47
+ @tags = tags
48
+ @status = status
49
+ @account_type = account_type
50
+ @flags = flags
51
+ @validator_link = validator_link
52
+ @created = StarkCore::Utils::Checks.check_datetime(created)
53
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
54
+ end
55
+
56
+ # # Create IndividualAccountRequests
57
+ #
58
+ # Send a list of IndividualAccountRequest objects for creation at the Stark Infra API
59
+ #
60
+ # ## Parameters (required):
61
+ # - requests [list of IndividualAccountRequest objects]: list of IndividualAccountRequest objects to be created in the API.
62
+ #
63
+ # ## Parameters (optional):
64
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
65
+ #
66
+ # ## Return:
67
+ # - list of IndividualAccountRequest objects with updated attributes
68
+ def self.create(requests, user: nil)
69
+ # Output-only fields (id, status, account_type, flags, created, updated) are
70
+ # rejected by the API on POST with "Unknown parameters in JSON: ...". Strip
71
+ # them from a shallow dup so the caller's objects are unmodified. The core
72
+ # serializer (StarkCore::Utils::API.build_entity_hash) skips nil ivars.
73
+ stripped = requests.map do |req|
74
+ copy = req.dup
75
+ %i[@id @status @account_type @flags @created @updated].each do |ivar|
76
+ copy.instance_variable_set(ivar, nil)
77
+ end
78
+ copy
79
+ end
80
+ StarkInfra::Utils::Rest.post(entities: stripped, user: user, **resource)
81
+ end
82
+
83
+ # # Retrieve a specific IndividualAccountRequest
84
+ #
85
+ # Receive a single IndividualAccountRequest object previously created in the Stark Infra API by its id
86
+ #
87
+ # ## Parameters (required):
88
+ # - id [string]: object unique id. ex: '5656565656565656'
89
+ #
90
+ # ## Parameters (optional):
91
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
92
+ #
93
+ # ## Return:
94
+ # - IndividualAccountRequest object with updated attributes
95
+ def self.get(id, user: nil)
96
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
97
+ end
98
+
99
+ # # Retrieve IndividualAccountRequests
100
+ #
101
+ # Receive a generator of IndividualAccountRequest objects previously created in the Stark Infra API
102
+ #
103
+ # ## Parameters (optional):
104
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
105
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
106
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
107
+ # - status [string, default nil]: filter for status of retrieved objects. ex: 'created'
108
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
109
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
110
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
111
+ #
112
+ # ## Return:
113
+ # - generator of IndividualAccountRequest objects with updated attributes
114
+ def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
115
+ after = StarkCore::Utils::Checks.check_date(after)
116
+ before = StarkCore::Utils::Checks.check_date(before)
117
+ StarkInfra::Utils::Rest.get_stream(
118
+ limit: limit,
119
+ after: after,
120
+ before: before,
121
+ status: status,
122
+ tags: tags,
123
+ ids: ids,
124
+ user: user,
125
+ **resource
126
+ )
127
+ end
128
+
129
+ # # Retrieve paged IndividualAccountRequests
130
+ #
131
+ # Receive a list of up to 100 IndividualAccountRequest objects previously created in the Stark Infra API and the cursor to the next page.
132
+ # Use this function instead of query if you want to manually page your requests.
133
+ #
134
+ # ## Parameters (optional):
135
+ # - cursor [string, default nil]: cursor returned on the previous page function call
136
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex 35
137
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
138
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
139
+ # - status [string, default nil]: filter for status of retrieved objects. ex: 'created'
140
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
141
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
142
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
143
+ #
144
+ # ## Return:
145
+ # - list of IndividualAccountRequest objects with updated attributes
146
+ # - cursor to retrieve the next page of IndividualAccountRequest objects
147
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
148
+ after = StarkCore::Utils::Checks.check_date(after)
149
+ before = StarkCore::Utils::Checks.check_date(before)
150
+ StarkInfra::Utils::Rest.get_page(
151
+ cursor: cursor,
152
+ limit: limit,
153
+ after: after,
154
+ before: before,
155
+ status: status,
156
+ tags: tags,
157
+ ids: ids,
158
+ user: user,
159
+ **resource
160
+ )
161
+ end
162
+
163
+ # # Update an IndividualAccountRequest entity
164
+ #
165
+ # Update an IndividualAccountRequest by passing its id.
166
+ #
167
+ # ## Parameters (required):
168
+ # - id [string]: IndividualAccountRequest unique id. ex: '5656565656565656'
169
+ #
170
+ # ## Parameters (optional):
171
+ # - name [string, default nil]: replace the legal name. ex: 'Tony Stark'
172
+ # - tax_id [string, default nil]: replace the CPF. ex: '012.345.678-90'
173
+ # - address [IndividualAccountRequest::Address object, default nil]: replace the address as a whole object.
174
+ # - income [integer, default nil]: replace monthly income in cents. ex: 1000000
175
+ # - birth_date [Date or string, default nil]: replace the birth date. ex: '2012-03-06'
176
+ # - status [string, default nil]: manual state transition. ex: 'processing'
177
+ # - tags [list of strings, default nil]: replace tag list. ex: ['employees', 'monthly']
178
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
179
+ #
180
+ # ## Return:
181
+ # - target IndividualAccountRequest with updated attributes
182
+ def self.update(id, name: nil, tax_id: nil, address: nil, income: nil, birth_date: nil, status: nil, tags: nil, user: nil)
183
+ StarkInfra::Utils::Rest.patch_id(
184
+ id: id,
185
+ name: name,
186
+ tax_id: tax_id,
187
+ address: address,
188
+ income: income,
189
+ birth_date: birth_date.to_s.empty? ? nil : StarkCore::Utils::Checks.check_date(birth_date),
190
+ status: status,
191
+ tags: tags,
192
+ user: user,
193
+ **resource
194
+ )
195
+ end
196
+
197
+ def self.resource
198
+ {
199
+ resource_name: 'IndividualAccountRequest',
200
+ resource_maker: proc { |json|
201
+ IndividualAccountRequest.new(
202
+ id: json['id'],
203
+ name: json['name'],
204
+ tax_id: json['tax_id'],
205
+ address: json['address'],
206
+ income: json['income'],
207
+ birth_date: json['birth_date'],
208
+ tags: json['tags'],
209
+ status: json['status'],
210
+ account_type: json['account_type'],
211
+ flags: json['flags'],
212
+ validator_link: json['validator_link'],
213
+ created: json['created'],
214
+ updated: json['updated']
215
+ )
216
+ }
217
+ }
218
+ end
219
+
220
+ # # IndividualAccountRequest::Address object
221
+ #
222
+ # Structured residential address embedded as the `address` field on an IndividualAccountRequest.
223
+ # Serialized as a nested JSON object on the wire (never flattened).
224
+ #
225
+ # ## Parameters (required):
226
+ # - street [string]: street name. ex: 'Rua do Estilo Barroco'
227
+ # - number [string]: street number. ex: '648'
228
+ # - neighborhood [string]: neighborhood / district. ex: 'Santo Amaro'
229
+ # - city [string]: city. ex: 'SP'
230
+ # - state [string]: state (BR 2-letter code). ex: 'SP'
231
+ # - zip_code [string]: ZIP code (BR CEP). ex: '05724005'
232
+ #
233
+ # ## Parameters (optional):
234
+ # - complement [string, default nil]: address complement. ex: 'Apto. 123'
235
+ class Address < StarkCore::Utils::SubResource
236
+ attr_reader :street, :number, :neighborhood, :city, :state, :zip_code, :complement
237
+ def initialize(street: nil, number: nil, neighborhood: nil, city: nil, state: nil, zip_code: nil, complement: nil)
238
+ @street = street
239
+ @number = number
240
+ @neighborhood = neighborhood
241
+ @city = city
242
+ @state = state
243
+ @zip_code = zip_code
244
+ @complement = complement
245
+ end
246
+
247
+ def self.parse_address(address)
248
+ return address if address.nil? || address.is_a?(IndividualAccountRequest::Address)
249
+
250
+ StarkCore::Utils::API.from_api_json(resource[:resource_maker], address)
251
+ end
252
+
253
+ def self.resource
254
+ {
255
+ resource_name: 'Address',
256
+ resource_maker: proc { |json|
257
+ Address.new(
258
+ street: json['street'],
259
+ number: json['number'],
260
+ neighborhood: json['neighborhood'],
261
+ city: json['city'],
262
+ state: json['state'],
263
+ zip_code: json['zip_code'],
264
+ complement: json['complement']
265
+ )
266
+ }
267
+ }
268
+ end
269
+ end
270
+ end
271
+ end
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+ require_relative('individual_account_request')
6
+
7
+ module StarkInfra
8
+ class IndividualAccountRequest
9
+ # # IndividualAccountRequest::Log object
10
+ #
11
+ # Every time an IndividualAccountRequest entity is modified, a corresponding IndividualAccountRequest::Log
12
+ # is generated for the entity. This Log is never generated by the user, but it can be retrieved to check
13
+ # additional information on the IndividualAccountRequest.
14
+ #
15
+ # ## Attributes (return-only):
16
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
17
+ # - request [IndividualAccountRequest]: IndividualAccountRequest entity to which the log refers to.
18
+ # - errors [list of strings]: list of errors linked to this IndividualAccountRequest event.
19
+ # - type [string]: type of the IndividualAccountRequest event which triggered the log creation. Options: 'approved', 'created', 'denied', 'processing', 'updated'
20
+ # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
21
+ class Log < StarkCore::Utils::Resource
22
+ attr_reader :id, :request, :errors, :type, :created
23
+ def initialize(id: nil, request: nil, errors: nil, type: nil, created: nil)
24
+ super(id)
25
+ @request = request
26
+ @errors = errors
27
+ @type = type
28
+ @created = StarkCore::Utils::Checks.check_datetime(created)
29
+ end
30
+
31
+ # # Retrieve a specific IndividualAccountRequest::Log
32
+ #
33
+ # Receive a single IndividualAccountRequest::Log object previously created by the Stark Infra API by passing its id
34
+ #
35
+ # ## Parameters (required):
36
+ # - id [string]: object unique id. ex: '5656565656565656'
37
+ #
38
+ # ## Parameters (optional):
39
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
40
+ #
41
+ # ## Return:
42
+ # - IndividualAccountRequest::Log object with updated attributes
43
+ def self.get(id, user: nil)
44
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
45
+ end
46
+
47
+ # # Retrieve IndividualAccountRequest::Logs
48
+ #
49
+ # Receive a generator of IndividualAccountRequest::Log objects previously created in the Stark Infra API
50
+ #
51
+ # ## Parameters (optional):
52
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
53
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
54
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
55
+ # - types [list of strings, default nil]: filter for log event types. Options: 'approved', 'created', 'denied', 'processing', 'updated'
56
+ # - account_request_ids [list of strings, default nil]: list of IndividualAccountRequest ids to filter logs. ex: ['5656565656565656', '4545454545454545']
57
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
58
+ #
59
+ # ## Return:
60
+ # - generator of IndividualAccountRequest::Log objects with updated attributes
61
+ def self.query(limit: nil, after: nil, before: nil, types: nil, account_request_ids: nil, user: nil)
62
+ after = StarkCore::Utils::Checks.check_date(after)
63
+ before = StarkCore::Utils::Checks.check_date(before)
64
+ StarkInfra::Utils::Rest.get_stream(
65
+ limit: limit,
66
+ after: after,
67
+ before: before,
68
+ types: types,
69
+ account_request_ids: account_request_ids,
70
+ user: user,
71
+ **resource
72
+ )
73
+ end
74
+
75
+ # # Retrieve paged IndividualAccountRequest::Logs
76
+ #
77
+ # Receive a list of up to 100 IndividualAccountRequest::Log objects previously created in the Stark Infra API and the cursor to the next page.
78
+ # Use this function instead of query if you want to manually page your requests.
79
+ #
80
+ # ## Parameters (optional):
81
+ # - cursor [string, default nil]: cursor returned on the previous page function call
82
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
83
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
84
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
85
+ # - types [list of strings, default nil]: filter for log event types. Options: 'approved', 'created', 'denied', 'processing', 'updated'
86
+ # - account_request_ids [list of strings, default nil]: list of IndividualAccountRequest ids to filter logs. ex: ['5656565656565656', '4545454545454545']
87
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
88
+ #
89
+ # ## Return:
90
+ # - list of IndividualAccountRequest::Log objects with updated attributes
91
+ # - cursor to retrieve the next page of Log objects
92
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, account_request_ids: nil, user: nil)
93
+ after = StarkCore::Utils::Checks.check_date(after)
94
+ before = StarkCore::Utils::Checks.check_date(before)
95
+ StarkInfra::Utils::Rest.get_page(
96
+ cursor: cursor,
97
+ limit: limit,
98
+ after: after,
99
+ before: before,
100
+ types: types,
101
+ account_request_ids: account_request_ids,
102
+ user: user,
103
+ **resource
104
+ )
105
+ end
106
+
107
+ def self.resource
108
+ request_maker = StarkInfra::IndividualAccountRequest.resource[:resource_maker]
109
+ {
110
+ resource_name: 'IndividualAccountRequestLog',
111
+ resource_maker: proc { |json|
112
+ Log.new(
113
+ id: json['id'],
114
+ request: StarkCore::Utils::API.from_api_json(request_maker, json['request']),
115
+ errors: json['errors'],
116
+ type: json['type'],
117
+ created: json['created']
118
+ )
119
+ }
120
+ }
121
+ end
122
+ end
123
+ end
124
+ end
@@ -7,11 +7,8 @@ require_relative('../utils/parse')
7
7
  module StarkInfra
8
8
  # # IndividualIdentity object
9
9
  #
10
- # An IndividualDocument represents an individual to be validated. It can have several individual documents attached
11
- # to it, which are used to validate the identity of the individual. Once an individual identity is created, individual
12
- # documents must be attached to it using the created method of the individual document resource. When all the required
13
- # individual documents are attached to an individual identity it can be sent to validation by patching its status to
14
- # processing.
10
+ # An IndividualIdentity represents an individual to be validated. Once an individual identity is created,
11
+ # it can be sent to validation by patching its status to processing.
15
12
  #
16
13
  # When you initialize a IndividualIdentity, the entity will not be automatically
17
14
  # created in the Stark Infra API. The 'create' function sends the objects
@@ -26,7 +23,7 @@ module StarkInfra
26
23
  #
27
24
  # ## Attributes (return-only):
28
25
  # - id [string]: unique id returned when the IndividualIdentity is created. ex: "5656565656565656"
29
- # - status [string]: current status of the IndividualIdentity. Options: "created", "canceled", "processing", "failed", "success"
26
+ # - status [string]: current status of the IndividualIdentity. Options: "created", "processing", "pending", "success", "failed" — there is no "canceled" value; canceling an identity moves it to "failed".
30
27
  # - created [DateTime]: creation datetime for the IndividualIdentity. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
31
28
  class IndividualIdentity < StarkCore::Utils::Resource
32
29
  attr_reader :name, :tax_id, :tags, :id, :status, :created
@@ -141,7 +138,7 @@ module StarkInfra
141
138
  #
142
139
  # ## Parameters (required):
143
140
  # - id [string]: IndividualIdentity unique id. ex: '5656565656565656'
144
- # - status [string]: You may send IndividualDocuments to validation by passing 'processing' in the status
141
+ # - status [string]: You may send an IndividualIdentity to validation by passing 'processing' in the status
145
142
  #
146
143
  # ## Parameters (optional):
147
144
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
@@ -25,11 +25,11 @@ module StarkInfra
25
25
  # - city [string, default sub-issuer city]: card holder address city. ex: 'Rio de Janeiro'
26
26
  # - state_code [string, default sub-issuer state code]: card holder address state. ex: 'GO'
27
27
  # - zip_code [string, default sub-issuer zip code]: card holder address zip code. ex: '01311-200'
28
+ # - type [string, default 'virtual']: card type, settable on creation. Options: 'virtual', 'physical'. ex: 'virtual'
28
29
  #
29
30
  # ## Attributes (return-only):
30
31
  # - id [string]: unique id returned when IssuingCard is created. ex: '5656565656565656'
31
32
  # - holder_id [string]: card holder unique id. ex: '5656565656565656'
32
- # - type [string]: card type. ex: 'virtual'
33
33
  # - status [string]: current IssuingCard status. ex: 'active', 'blocked', 'canceled', 'expired'.
34
34
  # - is_pin_defined [boolean]: Whether the card has a PIN defined. Returned only when "expand=isPinDefined" is informed in the request
35
35
  # - number [string]: [EXPANDABLE] masked card number. Expand to unmask the value. ex: '123'.
@@ -74,7 +74,8 @@ module StarkInfra
74
74
 
75
75
  # # Create IssuingCards
76
76
  #
77
- # Send a list of IssuingCard objects for creation in the Stark Infra API
77
+ # Send a list of IssuingCard objects for creation in the Stark Infra API. Use this method to create up
78
+ # to 100 new IssuingCards at a time.
78
79
  #
79
80
  # ## Parameters (required):
80
81
  # - cards [list of IssuingCard objects]: list of IssuingCard objects to be created in the API
@@ -192,7 +193,7 @@ module StarkInfra
192
193
  #
193
194
  # ## Parameters (optional):
194
195
  # - status [string, default nil]: You may block the IssuingCard by passing 'blocked' or activate by passing 'active' in the status
195
- # - pin [string, default nil]: You may unlock your physical card by passing its PIN. This is also the PIN you use to authorize a purhcase.
196
+ # - pin [string, default nil]: numeric string of 4 to 6 digits, used to unlock a physical card and authorize purchases. Write-only — never returned; check expand: ['isPinDefined'] to see whether a PIN is set. A pending physical card must also receive this PIN to be activated: passing it alone activates the card, and setting status to 'active' on a pending physical card without a PIN is rejected.
196
197
  # - display_name [string, default nil]: card displayed name
197
198
  # - rules [list of IssuingRule objects, default nil]: [EXPANDABLE] list of card spending rules.
198
199
  # - tags [list of strings, default nil]: list of strings for tagging
@@ -215,7 +216,7 @@ module StarkInfra
215
216
 
216
217
  # # Cancel an IssuingCard entity
217
218
  #
218
- # Cancel an IssuingCard entity previously created in the Stark Infra API
219
+ # Cancel an IssuingCard entity previously created in the Stark Infra API. This action is irreversible.
219
220
  #
220
221
  # ## Parameters (required):
221
222
  # - id [string]: IssuingCard unique id. ex: '5656565656565656'
@@ -104,6 +104,15 @@ module StarkInfra
104
104
  StarkInfra::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'pdf', **resource)
105
105
  end
106
106
 
107
+ # # Parse IssuingDesigns
108
+ #
109
+ # Converts a list of hashes into a list of IssuingDesign objects.
110
+ #
111
+ # ## Parameters (required):
112
+ # - designs [list of hashes]: list to be parsed.
113
+ #
114
+ # ## Return:
115
+ # - list of parsed IssuingDesign objects
107
116
  def self.parse_designs(designs)
108
117
  resource_maker = StarkInfra::IssuingDesign.resource[:resource_maker]
109
118
  return designs if designs.nil?
@@ -18,7 +18,7 @@ module StarkInfra
18
18
  # - shipping_state_code [string]: shipping state code. ex: "NY"
19
19
  # - shipping_street_line_1 [string]: shipping main address. ex: "AVENUE OF THE AMERICAS"
20
20
  # - shipping_street_line_2 [string]: shipping address complement. ex: "Apt. 6"
21
- # - shipping_service [string]: shipping service. ex: "loggi"
21
+ # - shipping_service [string]: shipping service. Options: 'loggi', 'conveyor'.
22
22
  # - shipping_tracking_number [string]: shipping tracking number. ex: "5656565656565656"
23
23
  # - shipping_zip_code [string]: shipping zip code. ex: "12345-678"
24
24
  #
@@ -73,7 +73,8 @@ module StarkInfra
73
73
 
74
74
  # # Create IssuingEmbossingRequests
75
75
  #
76
- # Send a list of IssuingEmbossingRequest objects for creation in the Stark Infra API
76
+ # Send a list of IssuingEmbossingRequest objects for creation in the Stark Infra API. Use this method to
77
+ # create up to 100 new IssuingEmbossingRequests at a time.
77
78
  #
78
79
  # ## Parameters (required):
79
80
  # - requests [list of IssuingEmbossingRequest objects]: list of IssuingEmbossingRequest objects to be created in the API