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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61eb746142fdcedb5bb2668292aaee6995c898114b0abea9a545e49593a005ac
4
- data.tar.gz: '04082c73ccc17fd54b98b81d3ff05672c05a9d674fc5585745167eafcbda2153'
3
+ metadata.gz: de90969ab57cda69ca0b44cfc730e700c09eb6946aa4a910c83e746a22d1352c
4
+ data.tar.gz: 215ddb0ea963f80ea88b68be867ea8df47cc123db8c7b7a81861ce23a165b12a
5
5
  SHA512:
6
- metadata.gz: d61b4d1ab3e1569d5dd4ab63f18c94fe7f566cdb1486f4601d64e87be2f848026b1bcf7573592cefed3e73bc786fd11da776e0a860618f86b25456e4aaac8939
7
- data.tar.gz: b57a0caaeb2a8c7c26330f18bca61a8e073186ffff1f83d95888c704bcc57919d76aa1a4a6c29d02a87c462a3e5bf41151802d52a5da80ee12584d449974c4ca
6
+ metadata.gz: 8b6abd55509addd3e4d07c155d3d679f0acfd681147b256771f9ed8ec785a1f05ebac12ea5ca97feb5fcefa4c9e15066a78fbabeb6e4d3c79eafde2938d55ee5
7
+ data.tar.gz: a5428b140f33babeb4f0d5e35fc98b8322770247ed9a30ac68a997d168d644a2dc924c89a543e01919e2f60fc311915e2cf30c9d80b163682dd2e346e72b6e78
@@ -13,12 +13,13 @@ module StarkInfra
13
13
  #
14
14
  # Parameters (optional):
15
15
  # - end_to_end_id [string]: central bank's unique transaction ID. ex: "E79457883202101262140HHX553UPqeq"
16
+ # - scheduled [Date or string, default nil]: date the payment is scheduled to be processed. Affects the preview values for due dynamic QR codes. ex: Date.new(2022, 1, 31)
16
17
  #
17
18
  # Attributes (return-only):
18
19
  # - account_number [string]: Payment receiver account number. ex: '1234567'
19
20
  # - account_type [string]: Payment receiver account type. ex: 'checking'
20
21
  # - amount [integer]: Value in cents that this payment is expecting to receive. If 0, any value is accepted. ex: 123 (= R$1,23)
21
- # - amount_type [string]: amount type of the BR Code. If the amount type is 'custom' the BR Code's amount can be changed by the sender at the moment of payment. Options: 'fixed' or 'custom'
22
+ # - amount_type [string]: amount type of the BR Code. Options: 'fixed' or 'minimum'. ex: 'fixed'
22
23
  # - bank_code [string]: Payment receiver bank code. ex: '20018183'
23
24
  # - branch_code [string]: Payment receiver branch code. ex: '0001'
24
25
  # - cash_amount [integer]: Amount to be withdrawn from the cashier in cents. ex: 1000 (= R$ 10.00)
@@ -36,15 +37,22 @@ module StarkInfra
36
37
  # - status [string]: Payment status. ex: 'active', 'paid', 'canceled' or 'unknown'
37
38
  # - subscription [BrcodePreview::Subscription, default nil]: snapshot of the recurring-debit subscription attached to the BR Code, when present. Nil for one-shot BR Codes.
38
39
  # - tax_id [string]: Payment receiver tax ID. ex: '012.345.678-90'
40
+ # - data [list of hashes]: additional data of the dynamic QR code, in key/value pairs. ex: [{'key' => 'additional-info', 'value' => 'order #12345'}]
41
+ # - description [string]: description of the payment.
42
+ # - due [DateTime]: due date and time for payment of the dynamic QR code. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
43
+ # - expired [DateTime]: date and time after which the dynamic QR code is considered expired. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
44
+ # - jws [string]: JWS of the dynamic QR code. Returned only when 'jws' is passed in the expand query parameter. ex: 'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9...'
39
45
  class BrcodePreview < StarkCore::Utils::Resource
40
46
  attr_reader :id, :payer_id, :end_to_end_id, :account_number, :account_type, :amount, :amount_type, :bank_code, :branch_code, :cash_amount,
41
47
  :cashier_bank_code, :cashier_type, :discount_amount, :fine_amount, :key_id, :interest_amount, :name,
42
- :nominal_amount, :reconciliation_id, :reduction_amount, :scheduled, :status, :subscription, :tax_id
48
+ :nominal_amount, :reconciliation_id, :reduction_amount, :scheduled, :status, :subscription, :tax_id,
49
+ :data, :description, :due, :expired, :jws
43
50
  def initialize(
44
51
  id:, payer_id:, end_to_end_id: nil, account_number: nil, account_type: nil, amount: nil, amount_type: nil, bank_code: nil,
45
52
  branch_code: nil, cash_amount: nil, cashier_bank_code:nil, cashier_type:nil, discount_amount: nil,
46
53
  fine_amount: nil, key_id: nil, interest_amount: nil, name: nil, nominal_amount: nil,
47
- reconciliation_id: nil, reduction_amount: nil, scheduled: nil, status: nil, subscription: nil, tax_id: nil
54
+ reconciliation_id: nil, reduction_amount: nil, scheduled: nil, status: nil, subscription: nil, tax_id: nil,
55
+ data: nil, description: nil, due: nil, expired: nil, jws: nil
48
56
  )
49
57
  super(id)
50
58
  @payer_id = payer_id
@@ -70,6 +78,11 @@ module StarkInfra
70
78
  @status = status
71
79
  @subscription = subscription
72
80
  @tax_id = tax_id
81
+ @data = data
82
+ @description = description
83
+ @due = due.to_s.empty? ? nil : StarkCore::Utils::Checks.check_datetime(due)
84
+ @expired = expired.to_s.empty? ? nil : StarkCore::Utils::Checks.check_datetime(expired)
85
+ @jws = jws
73
86
  end
74
87
 
75
88
  # # Retrieve BrcodePreviews
@@ -116,7 +129,12 @@ module StarkInfra
116
129
  scheduled: json['scheduled'],
117
130
  status: json['status'],
118
131
  subscription: BrcodePreview::Subscription.parse_subscription(json['subscription']),
119
- tax_id: json['tax_id']
132
+ tax_id: json['tax_id'],
133
+ data: json['data'],
134
+ description: json['description'],
135
+ due: json['due'],
136
+ expired: json['expired'],
137
+ jws: json['jws']
120
138
  )
121
139
  }
122
140
  }
@@ -14,14 +14,14 @@ module StarkInfra
14
14
  # BrcodePreview returned by the API.
15
15
  #
16
16
  # ## Attributes (return-only):
17
- # - amount [integer]: amount in cents charged per cycle. nil for variable-amount subscriptions. ex: 1000 (= R$ 10.00)
17
+ # - amount [integer]: amount in cents charged per cycle. 0 for variable-amount subscriptions. ex: 1000 (= R$ 10.00)
18
18
  # - amount_min_limit [integer]: floor value for the maximum amount the sender can set when approving a variable-amount subscription. nil for fixed-amount subscriptions. ex: 500 (= R$ 5.00)
19
19
  # - bacen_id [string]: Central Bank's unique recurrency id for the subscription.
20
20
  # - created [DateTime]: creation datetime of the subscription. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
21
21
  # - description [string]: additional information delivered to the sender.
22
22
  # - installment_end [DateTime]: end datetime of settlements allowed for this subscription. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
23
23
  # - installment_start [DateTime]: start datetime of settlements allowed for this subscription. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
24
- # - interval [string]: cycle definition exposed verbatim from the server. ex: 'monthly'
24
+ # - interval [string]: billing interval of the subscription, translated from the Central Bank's periodicity code. Options: 'week', 'month', 'quarter', 'semester', 'year'.
25
25
  # - pull_retry_limit [integer]: max number of retries the receiver may issue for a single failed pull cycle.
26
26
  # - receiver_bank_code [string]: receiver's bank institution code.
27
27
  # - receiver_name [string]: receiver's full name.
@@ -0,0 +1,276 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+
6
+ module StarkInfra
7
+ # # BusinessAccountRequest object
8
+ #
9
+ # Request to open a Stark Infra account for a company. Each of the company's owners completes an
10
+ # identity verification through an independent webview, delivered as the owner's validator_link. The
11
+ # API runs the approval flow asynchronously, moving the request through 'created' -> 'processing' ->
12
+ # ('approved' | 'denied'); 'failed' when the request could not be processed.
13
+ #
14
+ # When you initialize a BusinessAccountRequest, the entity will not be automatically
15
+ # created in the Stark Infra API. The 'create' function sends the objects
16
+ # to the Stark Infra API and returns the list of created objects.
17
+ #
18
+ # ## Parameters (required):
19
+ # - address [BusinessAccountRequest::Address object]: company's structured address. ex: StarkInfra::BusinessAccountRequest::Address.new(street: 'Av. Faria Lima', number: '2000', neighborhood: 'Itaim Bibi', city: 'Sao Paulo', state: 'SP', zip_code: '04538-132')
20
+ # - revenue [integer]: company's annual revenue in cents. ex: 100000000 (= R$ 1,000,000.00)
21
+ # - name [string]: company's legal name (minimum 5 characters). ex: 'Stark Bank S.A.'
22
+ # - tax_id [string]: company's tax ID (CNPJ). ex: '20.018.183/0001-80'
23
+ # - owners [list of BusinessAccountRequest::Owner objects]: list of 1 to 10 company owners. ex: [StarkInfra::BusinessAccountRequest::Owner.new(tax_id: '012.345.678-90', name: 'Jamie Lannister', role: 'partner')]
24
+ #
25
+ # ## Parameters (optional):
26
+ # - tags [list of strings, default nil]: list of strings for reference when searching for BusinessAccountRequests. ex: ['employees', 'monthly']
27
+ #
28
+ # ## Attributes (return-only):
29
+ # - id [string]: unique id returned when the BusinessAccountRequest is created. ex: '5656565656565656'
30
+ # - account_type [string]: type of the account. ex: 'business'
31
+ # - flags [list of hashes]: flags that motivated the decision, populated when the request is denied. Each flag has a code and a message. ex: [{'code' => 'failedIdentityProof', 'message' => 'O representante: 012.345.678-90 falhou na verificação de identidade.'}]
32
+ # - status [string]: current status of the BusinessAccountRequest. Options: 'created', 'processing', 'approved', 'denied', 'failed'
33
+ # - created [DateTime]: creation datetime for the BusinessAccountRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
34
+ # - updated [DateTime]: latest update datetime for the BusinessAccountRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
35
+ class BusinessAccountRequest < StarkCore::Utils::Resource
36
+ attr_reader :address, :revenue, :name, :tax_id, :owners, :tags, :id, :account_type, :flags, :status, :created, :updated
37
+ def initialize(address:, revenue:, name:, tax_id:, owners:, tags: nil, id: nil, account_type: nil,
38
+ flags: nil, status: nil, created: nil, updated: nil)
39
+ super(id)
40
+ @address = BusinessAccountRequest.parse_address(address)
41
+ @revenue = revenue
42
+ @name = name
43
+ @tax_id = tax_id
44
+ @owners = BusinessAccountRequest.parse_owners(owners)
45
+ @tags = tags
46
+ @account_type = account_type
47
+ @flags = flags
48
+ @status = status
49
+ @created = StarkCore::Utils::Checks.check_datetime(created)
50
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
51
+ end
52
+
53
+ # # Create BusinessAccountRequests
54
+ #
55
+ # Send a list of BusinessAccountRequest objects for creation at the Stark Infra API
56
+ #
57
+ # ## Parameters (required):
58
+ # - requests [list of BusinessAccountRequest objects]: list of BusinessAccountRequest objects to be created in the API.
59
+ #
60
+ # ## Parameters (optional):
61
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
62
+ #
63
+ # ## Return:
64
+ # - list of BusinessAccountRequest objects with updated attributes
65
+ def self.create(requests, user: nil)
66
+ StarkInfra::Utils::Rest.post(entities: requests, user: user, **resource)
67
+ end
68
+
69
+ # # Retrieve a specific BusinessAccountRequest
70
+ #
71
+ # Receive a single BusinessAccountRequest object previously created in the Stark Infra API by its id
72
+ #
73
+ # ## Parameters (required):
74
+ # - id [string]: object unique id. ex: '5656565656565656'
75
+ #
76
+ # ## Parameters (optional):
77
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
78
+ #
79
+ # ## Return:
80
+ # - BusinessAccountRequest object with updated attributes
81
+ def self.get(id, user: nil)
82
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
83
+ end
84
+
85
+ # # Retrieve BusinessAccountRequests
86
+ #
87
+ # Receive a generator of BusinessAccountRequest objects previously created in the Stark Infra API
88
+ #
89
+ # ## Parameters (optional):
90
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
91
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
92
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
93
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['created', 'processing', 'approved', 'denied', 'failed']
94
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
95
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
96
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
97
+ #
98
+ # ## Return:
99
+ # - generator of BusinessAccountRequest objects with updated attributes
100
+ def self.query(limit: nil, status: nil, tags: nil, ids: nil, after: nil, before: nil, user: nil)
101
+ after = StarkCore::Utils::Checks.check_date(after)
102
+ before = StarkCore::Utils::Checks.check_date(before)
103
+ StarkInfra::Utils::Rest.get_stream(
104
+ limit: limit,
105
+ status: status,
106
+ tags: tags,
107
+ ids: ids,
108
+ after: after,
109
+ before: before,
110
+ user: user,
111
+ **resource
112
+ )
113
+ end
114
+
115
+ # # Retrieve paged BusinessAccountRequests
116
+ #
117
+ # Receive a list of up to 100 BusinessAccountRequest objects previously created in the Stark Infra API and the cursor to the next page.
118
+ # Use this function instead of query if you want to manually page your requests.
119
+ #
120
+ # ## Parameters (optional):
121
+ # - cursor [string, default nil]: cursor returned on the previous page function call
122
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 50
123
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
124
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
125
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['created', 'processing', 'approved', 'denied', 'failed']
126
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
127
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
128
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
129
+ #
130
+ # ## Return:
131
+ # - list of BusinessAccountRequest objects with updated attributes
132
+ # - cursor to retrieve the next page of BusinessAccountRequest objects
133
+ def self.page(cursor: nil, limit: nil, status: nil, tags: nil, ids: nil, after: nil, before: nil, user: nil)
134
+ after = StarkCore::Utils::Checks.check_date(after)
135
+ before = StarkCore::Utils::Checks.check_date(before)
136
+ StarkInfra::Utils::Rest.get_page(
137
+ cursor: cursor,
138
+ limit: limit,
139
+ status: status,
140
+ tags: tags,
141
+ ids: ids,
142
+ after: after,
143
+ before: before,
144
+ user: user,
145
+ **resource
146
+ )
147
+ end
148
+
149
+ def self.parse_address(address)
150
+ return nil if address.nil?
151
+ return address if address.is_a?(Address)
152
+
153
+ address_maker = Address.resource[:resource_maker]
154
+ StarkCore::Utils::API.from_api_json(address_maker, address)
155
+ end
156
+
157
+ def self.parse_owners(owners)
158
+ return nil if owners.nil?
159
+
160
+ owner_maker = Owner.resource[:resource_maker]
161
+ owners.map do |owner|
162
+ owner.is_a?(Owner) ? owner : StarkCore::Utils::API.from_api_json(owner_maker, owner)
163
+ end
164
+ end
165
+
166
+ def self.resource
167
+ {
168
+ resource_name: 'BusinessAccountRequest',
169
+ resource_maker: proc { |json|
170
+ BusinessAccountRequest.new(
171
+ id: json['id'],
172
+ address: json['address'],
173
+ revenue: json['revenue'],
174
+ name: json['name'],
175
+ tax_id: json['tax_id'],
176
+ owners: json['owners'],
177
+ tags: json['tags'],
178
+ account_type: json['account_type'],
179
+ flags: json['flags'],
180
+ status: json['status'],
181
+ created: json['created'],
182
+ updated: json['updated']
183
+ )
184
+ }
185
+ }
186
+ end
187
+
188
+ # # BusinessAccountRequest::Address object
189
+ #
190
+ # The Address object is the structured address of the company referenced by a
191
+ # BusinessAccountRequest. It is embedded on the parent's address field and has no endpoints of its own.
192
+ #
193
+ # ## Parameters (required):
194
+ # - street [string]: street name. ex: 'Av. Faria Lima'
195
+ # - number [string]: street number. ex: '2000'
196
+ # - neighborhood [string]: neighborhood / district. ex: 'Itaim Bibi'
197
+ # - city [string]: city. ex: 'Sao Paulo'
198
+ # - state [string]: state (BR 2-letter code). ex: 'SP'
199
+ # - zip_code [string]: ZIP code (BR CEP), formatted or digit-only. ex: '04538-132'
200
+ #
201
+ # ## Parameters (optional):
202
+ # - complement [string, default nil]: address complement. ex: 'Sala 42'
203
+ class Address < StarkCore::Utils::SubResource
204
+ attr_reader :street, :number, :neighborhood, :city, :state, :zip_code, :complement
205
+ def initialize(street:, number:, neighborhood:, city:, state:, zip_code:, complement: nil)
206
+ @street = street
207
+ @number = number
208
+ @neighborhood = neighborhood
209
+ @city = city
210
+ @state = state
211
+ @zip_code = zip_code
212
+ @complement = complement
213
+ end
214
+
215
+ def self.resource
216
+ {
217
+ resource_name: 'Address',
218
+ resource_maker: proc { |json|
219
+ Address.new(
220
+ street: json['street'],
221
+ number: json['number'],
222
+ neighborhood: json['neighborhood'],
223
+ city: json['city'],
224
+ state: json['state'],
225
+ zip_code: json['zip_code'],
226
+ complement: json['complement']
227
+ )
228
+ }
229
+ }
230
+ end
231
+ end
232
+
233
+ # # BusinessAccountRequest::Owner object
234
+ #
235
+ # The Owner object represents a company owner referenced by a BusinessAccountRequest. Each owner
236
+ # completes its own identity verification through an independent webview. It is embedded on the
237
+ # parent's owners field and has no endpoints of its own.
238
+ #
239
+ # ## Parameters (required):
240
+ # - tax_id [string]: owner's tax ID (CPF). ex: '012.345.678-90'
241
+ # - name [string]: owner's full name (minimum 5 characters). ex: 'Jamie Lannister'
242
+ # - role [string]: owner's role in the company. Options: 'partner', 'representative'
243
+ #
244
+ # ## Attributes (return-only):
245
+ # - identity_id [string]: unique id of the identity verification linked to this owner. ex: '5709594221805568'
246
+ # - validator_link [string]: webview link to be delivered to the owner to complete biometrics and document capture. Treat it as a credential: deliver it through a secure channel and never log it.
247
+ # - status [string]: current status of the owner verification. Options: 'created', 'approved', 'denied'
248
+ class Owner < StarkCore::Utils::SubResource
249
+ attr_reader :tax_id, :name, :role, :identity_id, :validator_link, :status
250
+ def initialize(tax_id:, name:, role:, identity_id: nil, validator_link: nil, status: nil)
251
+ @tax_id = tax_id
252
+ @name = name
253
+ @role = role
254
+ @identity_id = identity_id
255
+ @validator_link = validator_link
256
+ @status = status
257
+ end
258
+
259
+ def self.resource
260
+ {
261
+ resource_name: 'Owner',
262
+ resource_maker: proc { |json|
263
+ Owner.new(
264
+ tax_id: json['tax_id'],
265
+ name: json['name'],
266
+ role: json['role'],
267
+ identity_id: json['identity_id'],
268
+ validator_link: json['validator_link'],
269
+ status: json['status']
270
+ )
271
+ }
272
+ }
273
+ end
274
+ end
275
+ end
276
+ end
@@ -2,34 +2,35 @@
2
2
 
3
3
  require('starkcore')
4
4
  require_relative('../utils/rest')
5
- require_relative('individual_document')
5
+ require_relative('business_account_request')
6
6
 
7
7
  module StarkInfra
8
- class IndividualDocument
9
- # # IndividualDocument::Log object
8
+ class BusinessAccountRequest
9
+ # # BusinessAccountRequest::Log object
10
10
  #
11
- # Every time an IndividualDocument entity is updated, a corresponding IndividualDocument::Log is generated for the entity.
12
- # This Log is never generated by the user, but it can be retrieved to check additional information on the IndividualDocument.
11
+ # Every time a BusinessAccountRequest entity is modified, a corresponding BusinessAccountRequest::Log
12
+ # is generated for the entity. This log is never generated by the user, but it can be retrieved to
13
+ # check additional information on the BusinessAccountRequest.
13
14
  #
14
15
  # ## Attributes (return-only):
15
16
  # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
16
- # - document [IndividualDocument]: IndividualDocument entity to which the log refers to.
17
- # - errors [list of strings]: list of errors linked to this IndividualDocument event
18
- # - type [string]: type of the IndividualDocument event which triggered the log creation. ex: 'approved', 'canceled', 'confirmed', 'denied', 'reversed', 'voided'.
17
+ # - request [BusinessAccountRequest]: BusinessAccountRequest entity to which the log refers to.
18
+ # - errors [list of strings]: list of errors linked to this BusinessAccountRequest event
19
+ # - type [string]: type of the BusinessAccountRequest event which triggered the log creation. ex: 'created', 'processing', 'approved', 'denied', 'failed'
19
20
  # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
20
21
  class Log < StarkCore::Utils::Resource
21
- attr_reader :id, :document, :errors, :type, :created
22
- def initialize(id: nil, document: nil, errors: nil, type: nil, created: nil)
22
+ attr_reader :id, :request, :errors, :type, :created
23
+ def initialize(id: nil, request: nil, errors: nil, type: nil, created: nil)
23
24
  super(id)
24
- @document = document
25
+ @request = request
25
26
  @errors = errors
26
27
  @type = type
27
28
  @created = StarkCore::Utils::Checks.check_datetime(created)
28
29
  end
29
30
 
30
- # # Retrieve a specific IndividualDocument::Log
31
+ # # Retrieve a specific BusinessAccountRequest::Log
31
32
  #
32
- # Receive a single IndividualDocument::Log object previously created by the Stark Infra API by passing its id
33
+ # Receive a single BusinessAccountRequest::Log object previously created by the Stark Infra API by passing its id
33
34
  #
34
35
  # ## Parameters (required):
35
36
  # - id [string]: object unique id. ex: '5656565656565656'
@@ -38,58 +39,57 @@ module StarkInfra
38
39
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
39
40
  #
40
41
  # ## Return:
41
- # - IndividualDocument::Log object with updated attributes
42
+ # - BusinessAccountRequest::Log object with updated attributes
42
43
  def self.get(id, user: nil)
43
44
  StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
44
45
  end
45
46
 
46
- # # Retrieve IndividualDocument::Logs
47
+ # # Retrieve BusinessAccountRequest::Logs
47
48
  #
48
- # Receive a generator of IndividualDocument::Log objects previously created in the Stark Infra API
49
+ # Receive a generator of BusinessAccountRequest::Log objects previously created in the Stark Infra API
49
50
  #
50
51
  # ## Parameters (optional):
51
52
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
52
53
  # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
53
54
  # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
54
- # - types [list of strings, default nil]: filter for log event types. ex: ['created', 'canceled', 'processing', 'failed', 'success']
55
- # - document_ids [list of strings, default nil]: list of IndividualDocument ids to filter logs. ex: ['5656565656565656', '4545454545454545']
55
+ # - types [list of strings, default nil]: filter for log event types. ex: ['created', 'processing', 'approved', 'denied', 'failed']
56
+ # - account_request_ids [list of strings, default nil]: list of BusinessAccountRequest ids to filter logs. ex: ['5656565656565656', '4545454545454545']
56
57
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
57
58
  #
58
59
  # ## Return:
59
- # - generator of IndividualDocument::Log objects with updated attributes
60
- def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, document_ids: nil, user: nil)
60
+ # - generator of BusinessAccountRequest::Log objects with updated attributes
61
+ def self.query(limit: nil, after: nil, before: nil, types: nil, account_request_ids: nil, user: nil)
61
62
  after = StarkCore::Utils::Checks.check_date(after)
62
63
  before = StarkCore::Utils::Checks.check_date(before)
63
64
  StarkInfra::Utils::Rest.get_stream(
64
- ids: ids,
65
65
  limit: limit,
66
66
  after: after,
67
67
  before: before,
68
68
  types: types,
69
- document_ids: document_ids,
69
+ account_request_ids: account_request_ids,
70
70
  user: user,
71
71
  **resource
72
72
  )
73
73
  end
74
74
 
75
- # # Retrieve paged IndividualDocument::Logs
75
+ # # Retrieve paged BusinessAccountRequest::Logs
76
76
  #
77
- # Receive a list of up to 100 IndividualDocument::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 documents.
77
+ # Receive a list of up to 100 BusinessAccountRequest::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
79
  #
80
80
  # ## Parameters (optional):
81
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
82
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 50
83
83
  # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
84
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. ex: ['created', 'canceled', 'processing', 'failed', 'success']
86
- # - document_ids [list of strings, default nil]: list of document ids to filter logs. ex: ['5656565656565656', '4545454545454545']
85
+ # - types [list of strings, default nil]: filter for log event types. ex: ['created', 'processing', 'approved', 'denied', 'failed']
86
+ # - account_request_ids [list of strings, default nil]: list of BusinessAccountRequest ids to filter logs. ex: ['5656565656565656', '4545454545454545']
87
87
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
88
88
  #
89
89
  # ## Return:
90
- # - list of IndividualDocument::Log objects with updated attributes
91
- # - cursor to retrieve the next page of Log objects
92
- def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, document_ids: nil, user: nil)
90
+ # - list of BusinessAccountRequest::Log objects with updated attributes
91
+ # - cursor to retrieve the next page of BusinessAccountRequest::Log objects
92
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, account_request_ids: nil, user: nil)
93
93
  after = StarkCore::Utils::Checks.check_date(after)
94
94
  before = StarkCore::Utils::Checks.check_date(before)
95
95
  StarkInfra::Utils::Rest.get_page(
@@ -98,20 +98,20 @@ module StarkInfra
98
98
  after: after,
99
99
  before: before,
100
100
  types: types,
101
- document_ids: document_ids,
101
+ account_request_ids: account_request_ids,
102
102
  user: user,
103
103
  **resource
104
104
  )
105
105
  end
106
106
 
107
107
  def self.resource
108
- request_maker = StarkInfra::IndividualDocument.resource[:resource_maker]
108
+ request_maker = StarkInfra::BusinessAccountRequest.resource[:resource_maker]
109
109
  {
110
- resource_name: 'IndividualDocumentLog',
110
+ resource_name: 'BusinessAccountRequestLog',
111
111
  resource_maker: proc { |json|
112
112
  Log.new(
113
113
  id: json['id'],
114
- document: StarkCore::Utils::API.from_api_json(request_maker, json['document']),
114
+ request: StarkCore::Utils::API.from_api_json(request_maker, json['request']),
115
115
  errors: json['errors'],
116
116
  type: json['type'],
117
117
  created: json['created']
@@ -16,7 +16,7 @@ module StarkInfra
16
16
  #
17
17
  # ## Parameters (required):
18
18
  # - name [string]: name of the BusinessAttachment. ex: "articles-of-incorporation.pdf"
19
- # - content [string]: Base64 data url of the file or its raw bytes. ex: data:application/pdf;base64,JVBERi0xLjQ...
19
+ # - content [string]: Base64 data url of the file or its raw bytes on creation; when retrieved via get, populated only when expand: ['content'] is passed, nil otherwise. ex: data:application/pdf;base64,JVBERi0xLjQ...
20
20
  # - business_identity_id [string]: Unique id of BusinessIdentity. ex: "5656565656565656"
21
21
  #
22
22
  # ## Parameters (optional):
@@ -52,7 +52,10 @@ module StarkInfra
52
52
 
53
53
  # # Create BusinessAttachments
54
54
  #
55
- # Send a list of BusinessAttachment objects for creation at the Stark Infra API
55
+ # Send a list of BusinessAttachment objects for creation at the Stark Infra API. Limit of 1 attachment per
56
+ # request and 2 attachments per identity. Only PDF, JPG and PNG files are accepted, up to 8 MB each; name
57
+ # must be unique among the identity's other 'created' attachments; the identity must be in 'created'/'pending'
58
+ # status with fewer than 2 attachments already.
56
59
  #
57
60
  # ## Parameters (required):
58
61
  # - attachments [list of BusinessAttachment objects]: list of BusinessAttachment objects to be created in the API.
@@ -149,7 +152,7 @@ module StarkInfra
149
152
 
150
153
  # # Cancel a BusinessAttachment entity
151
154
  #
152
- # Cancel a BusinessAttachment entity previously created in the Stark Infra API
155
+ # Cancel a BusinessAttachment entity previously created in the Stark Infra API. Only attachments in 'created' status can be canceled.
153
156
  #
154
157
  # ## Parameters (required):
155
158
  # - id [string]: BusinessAttachment unique id. ex: '5656565656565656'
@@ -26,7 +26,7 @@ module StarkInfra
26
26
  # ## Attributes (return-only):
27
27
  # - id [string]: unique id returned when the BusinessIdentity is created. ex: "5656565656565656"
28
28
  # - name [string]: company's full name. ex: "Stark Bank S.A."
29
- # - tax_id_status [string]: current status of the tax ID. ex: "active"
29
+ # - tax_id_status [string]: bureau status of the CNPJ, normalized from the Receita Federal value. Options: 'active' (ATIVA), 'blocked' (SUSPENSA), 'pending' (INAPTA), 'canceled' (BAIXADA), 'voided' (NULA).
30
30
  # - insight_tax_id [string]: tax ID returned by the validation insight. ex: "20018183000180"
31
31
  # - insight_document_type [string]: document type returned by the validation insight. ex: "cnpj"
32
32
  # - num_pages [integer]: number of pages of the attached documents. ex: 3
@@ -60,7 +60,9 @@ module StarkInfra
60
60
 
61
61
  # # Create BusinessIdentities
62
62
  #
63
- # Send a list of BusinessIdentity objects for creation at the Stark Infra API
63
+ # Send a list of BusinessIdentity objects for creation at the Stark Infra API. Each entry is created in
64
+ # 'pending' status. The CNPJ must be valid, active in the official bureau, and return non-empty
65
+ # representatives (sócios), or the request fails.
64
66
  #
65
67
  # ## Parameters (required):
66
68
  # - identities [list of BusinessIdentity objects]: list of BusinessIdentity objects to be created in the API.
@@ -166,7 +168,7 @@ module StarkInfra
166
168
  # - id [string]: BusinessIdentity unique id. ex: '5656565656565656'
167
169
  #
168
170
  # ## Parameters (optional):
169
- # - status [string, default nil]: You may send BusinessAttachments to validation by passing 'processing' in the status
171
+ # - status [string, default nil]: only 'processing' is accepted, triggering the AI Model analysis. The identity must be in 'created'/'pending' status and already have at least one BusinessAttachment associated with it.
170
172
  # - tags [list of strings, default nil]: list of strings for reference when searching for BusinessIdentities. ex: ["employees", "monthly"]
171
173
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
172
174
  #
@@ -184,7 +186,8 @@ module StarkInfra
184
186
 
185
187
  # # Cancel a BusinessIdentity entity
186
188
  #
187
- # Cancel a BusinessIdentity entity previously created in the Stark Infra API
189
+ # Cancel a BusinessIdentity entity previously created in the Stark Infra API. Only identities in 'created'
190
+ # or 'pending' status can be canceled.
188
191
  #
189
192
  # ## Parameters (required):
190
193
  # - id [string]: BusinessIdentity unique id. ex: '5656565656565656'
@@ -42,7 +42,8 @@ module StarkInfra
42
42
 
43
43
  # # Create CreditHolmes
44
44
  #
45
- # Send a list of CreditHolmes objects for creation at the Stark Infra API
45
+ # Send a list of CreditHolmes objects for creation at the Stark Infra API. You can create up to 100
46
+ # CreditHolmes in a single call.
46
47
  #
47
48
  # ## Parameters (required):
48
49
  # - holmes [list of CreditHolmes objects]: list of CreditHolmes objects to be created in the API.