starkinfra 0.5.2 → 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.
- checksums.yaml +4 -4
- data/lib/brcode_preview/brcode_preview.rb +25 -4
- data/lib/brcode_preview/subscription.rb +102 -0
- data/lib/business_account_request/business_account_request.rb +276 -0
- data/lib/business_account_request/log.rb +124 -0
- data/lib/business_attachment/business_attachment.rb +189 -0
- data/lib/{individual_document → business_attachment}/log.rb +35 -32
- data/lib/business_identity/business_identity.rb +228 -0
- data/lib/business_identity/log.rb +127 -0
- data/lib/credit_holmes/credit_holmes.rb +2 -1
- data/lib/credit_holmes/log.rb +125 -0
- data/lib/credit_note/credit_note.rb +51 -8
- data/lib/credit_note/rule.rb +55 -0
- data/lib/credit_note/transfer.rb +1 -1
- data/lib/credit_preview/credit_note_preview.rb +10 -2
- data/lib/credit_preview/credit_preview.rb +2 -1
- data/lib/credit_signer/credit_signer.rb +27 -2
- data/lib/dynamic_brcode/dynamic_brcode.rb +5 -2
- data/lib/event/event.rb +10 -2
- data/lib/individual_account_attachment/individual_account_attachment.rb +178 -0
- data/lib/individual_account_attachment/log.rb +124 -0
- data/lib/individual_account_request/individual_account_request.rb +271 -0
- data/lib/individual_account_request/log.rb +124 -0
- data/lib/individual_identity/individual_identity.rb +4 -7
- data/lib/issuing_balance/issuing_balance.rb +8 -2
- data/lib/issuing_billing_invoice/issuing_billing_invoice.rb +155 -0
- data/lib/issuing_billing_transaction/issuing_billing_transaction.rb +142 -0
- data/lib/issuing_card/issuing_card.rb +10 -6
- data/lib/issuing_design/issuing_design.rb +9 -0
- data/lib/issuing_embossing_request/issuing_embossing_request.rb +3 -2
- data/lib/issuing_holder/issuing_holder.rb +6 -5
- data/lib/issuing_product/issuing_product.rb +6 -3
- data/lib/issuing_purchase/issuing_purchase.rb +41 -8
- data/lib/issuing_restock/issuing_restock.rb +3 -2
- data/lib/issuing_rule/issuing_rule.rb +45 -3
- data/lib/issuing_stock/issuing_stock.rb +5 -2
- data/lib/issuing_stock_rule/issuing_stock_rule.rb +214 -0
- data/lib/issuing_token/issuing_token.rb +309 -0
- data/lib/issuing_token/log.rb +127 -0
- data/lib/issuing_token_activation/issuing_token_activation.rb +62 -0
- data/lib/issuing_token_design/issuing_token_design.rb +118 -0
- data/lib/issuing_token_request/issuing_token_request.rb +63 -0
- data/lib/issuing_withdrawal/issuing_withdrawal.rb +2 -2
- data/lib/ledger/ledger.rb +175 -0
- data/lib/ledger/log.rb +122 -0
- data/lib/ledger/rule.rb +55 -0
- data/lib/ledger_transaction/ledger_transaction.rb +179 -0
- data/lib/merchant_category/merchant_category.rb +6 -3
- data/lib/pix_balance/pix_balance.rb +1 -1
- data/lib/pix_chargeback/pix_chargeback.rb +34 -7
- data/lib/pix_claim/pix_claim.rb +14 -6
- data/lib/pix_director/pix_director.rb +1 -1
- data/lib/pix_dispute/log.rb +127 -0
- data/lib/pix_dispute/pix_dispute.rb +210 -0
- data/lib/pix_dispute/transaction.rb +91 -0
- data/lib/pix_fraud/log.rb +128 -0
- data/lib/pix_fraud/pix_fraud.rb +180 -0
- data/lib/pix_infraction/pix_infraction.rb +37 -7
- data/lib/pix_internal_transaction_report/log.rb +129 -0
- data/lib/pix_internal_transaction_report/pix_internal_transaction_report.rb +200 -0
- data/lib/pix_key/pix_key.rb +1 -1
- data/lib/pix_key_holmes/log.rb +129 -0
- data/lib/{individual_document/individual_document.rb → pix_key_holmes/pix_key_holmes.rb} +48 -56
- data/lib/pix_pull_request/log.rb +127 -0
- data/lib/pix_pull_request/pix_pull_request.rb +268 -0
- data/lib/pix_pull_subscription/log.rb +127 -0
- data/lib/pix_pull_subscription/pix_pull_subscription.rb +307 -0
- data/lib/pix_request/pix_request.rb +19 -6
- data/lib/pix_reversal/pix_reversal.rb +14 -8
- data/lib/pix_statement/pix_statement.rb +11 -5
- data/lib/pix_user/pix_user.rb +52 -0
- data/lib/pix_user/statistics.rb +64 -0
- data/lib/starkinfra.rb +45 -4
- data/lib/static_brcode/static_brcode.rb +8 -4
- data/lib/utils/bacen_id.rb +27 -0
- data/lib/utils/end_to_end_id.rb +20 -0
- data/lib/utils/pix_subscription_bacen_id.rb +21 -0
- data/lib/utils/return_id.rb +21 -0
- data/lib/webhook/webhook.rb +3 -3
- metadata +48 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: de90969ab57cda69ca0b44cfc730e700c09eb6946aa4a910c83e746a22d1352c
|
|
4
|
+
data.tar.gz: 215ddb0ea963f80ea88b68be867ea8df47cc123db8c7b7a81861ce23a165b12a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
|
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)
|
|
@@ -34,16 +35,24 @@ module StarkInfra
|
|
|
34
35
|
# - reduction_amount [integer]: Reduction value to discount from nominal_amount. ex: 1000
|
|
35
36
|
# - scheduled [DateTime]: date of payment execution. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0).
|
|
36
37
|
# - status [string]: Payment status. ex: 'active', 'paid', 'canceled' or 'unknown'
|
|
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.
|
|
37
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...'
|
|
38
45
|
class BrcodePreview < StarkCore::Utils::Resource
|
|
39
46
|
attr_reader :id, :payer_id, :end_to_end_id, :account_number, :account_type, :amount, :amount_type, :bank_code, :branch_code, :cash_amount,
|
|
40
47
|
:cashier_bank_code, :cashier_type, :discount_amount, :fine_amount, :key_id, :interest_amount, :name,
|
|
41
|
-
:nominal_amount, :reconciliation_id, :reduction_amount, :scheduled, :status, :tax_id
|
|
48
|
+
:nominal_amount, :reconciliation_id, :reduction_amount, :scheduled, :status, :subscription, :tax_id,
|
|
49
|
+
:data, :description, :due, :expired, :jws
|
|
42
50
|
def initialize(
|
|
43
51
|
id:, payer_id:, end_to_end_id: nil, account_number: nil, account_type: nil, amount: nil, amount_type: nil, bank_code: nil,
|
|
44
52
|
branch_code: nil, cash_amount: nil, cashier_bank_code:nil, cashier_type:nil, discount_amount: nil,
|
|
45
53
|
fine_amount: nil, key_id: nil, interest_amount: nil, name: nil, nominal_amount: nil,
|
|
46
|
-
reconciliation_id: nil, reduction_amount: nil, scheduled: nil, status: 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
|
|
47
56
|
)
|
|
48
57
|
super(id)
|
|
49
58
|
@payer_id = payer_id
|
|
@@ -67,7 +76,13 @@ module StarkInfra
|
|
|
67
76
|
@reduction_amount = reduction_amount
|
|
68
77
|
@scheduled = scheduled
|
|
69
78
|
@status = status
|
|
79
|
+
@subscription = subscription
|
|
70
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
|
|
71
86
|
end
|
|
72
87
|
|
|
73
88
|
# # Retrieve BrcodePreviews
|
|
@@ -113,7 +128,13 @@ module StarkInfra
|
|
|
113
128
|
reduction_amount: json['reduction_amount'],
|
|
114
129
|
scheduled: json['scheduled'],
|
|
115
130
|
status: json['status'],
|
|
116
|
-
|
|
131
|
+
subscription: BrcodePreview::Subscription.parse_subscription(json['subscription']),
|
|
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']
|
|
117
138
|
)
|
|
118
139
|
}
|
|
119
140
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('brcode_preview')
|
|
5
|
+
require_relative('../utils/rest')
|
|
6
|
+
|
|
7
|
+
module StarkInfra
|
|
8
|
+
class BrcodePreview
|
|
9
|
+
# # BrcodePreview::Subscription object
|
|
10
|
+
#
|
|
11
|
+
# A read-only snapshot of a Pix recurring-debit subscription, embedded inside a
|
|
12
|
+
# BrcodePreview response when the previewed BR Code carries subscription metadata.
|
|
13
|
+
# This sub-resource has no endpoints and is constructed only when deserializing a
|
|
14
|
+
# BrcodePreview returned by the API.
|
|
15
|
+
#
|
|
16
|
+
# ## Attributes (return-only):
|
|
17
|
+
# - amount [integer]: amount in cents charged per cycle. 0 for variable-amount subscriptions. ex: 1000 (= R$ 10.00)
|
|
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
|
+
# - bacen_id [string]: Central Bank's unique recurrency id for the subscription.
|
|
20
|
+
# - created [DateTime]: creation datetime of the subscription. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
21
|
+
# - description [string]: additional information delivered to the sender.
|
|
22
|
+
# - installment_end [DateTime]: end datetime of settlements allowed for this subscription. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
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]: billing interval of the subscription, translated from the Central Bank's periodicity code. Options: 'week', 'month', 'quarter', 'semester', 'year'.
|
|
25
|
+
# - pull_retry_limit [integer]: max number of retries the receiver may issue for a single failed pull cycle.
|
|
26
|
+
# - receiver_bank_code [string]: receiver's bank institution code.
|
|
27
|
+
# - receiver_name [string]: receiver's full name.
|
|
28
|
+
# - receiver_tax_id [string]: receiver's tax id (CPF or CNPJ).
|
|
29
|
+
# - reference_code [string]: commercial-relation identifier (contract number, order id, or client code).
|
|
30
|
+
# - sender_final_name [string]: final sender name when the sender differs from the originating institution.
|
|
31
|
+
# - sender_final_tax_id [string]: final sender tax id when distinct from the originating sender.
|
|
32
|
+
# - status [string]: current lifecycle state of the subscription snapshot, verbatim from the server. ex: 'created', 'pending', 'failed', 'denied', 'approved', 'active', 'expired', 'canceled'
|
|
33
|
+
# - type [string]: subscription journey type, verbatim from the server. ex: 'push', 'qrcode', 'qrcodeAndPayment', 'paymentAndOrQrcode'
|
|
34
|
+
# - updated [DateTime]: latest update datetime of the subscription. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
35
|
+
class Subscription < StarkCore::Utils::SubResource
|
|
36
|
+
attr_reader :amount, :amount_min_limit, :bacen_id, :created, :description, :installment_end,
|
|
37
|
+
:installment_start, :interval, :pull_retry_limit, :receiver_bank_code, :receiver_name,
|
|
38
|
+
:receiver_tax_id, :reference_code, :sender_final_name, :sender_final_tax_id, :status,
|
|
39
|
+
:type, :updated
|
|
40
|
+
def initialize(
|
|
41
|
+
amount: nil, amount_min_limit: nil, bacen_id: nil, created: nil, description: nil,
|
|
42
|
+
installment_end: nil, installment_start: nil, interval: nil, pull_retry_limit: nil,
|
|
43
|
+
receiver_bank_code: nil, receiver_name: nil, receiver_tax_id: nil, reference_code: nil,
|
|
44
|
+
sender_final_name: nil, sender_final_tax_id: nil, status: nil, type: nil, updated: nil
|
|
45
|
+
)
|
|
46
|
+
@amount = amount
|
|
47
|
+
@amount_min_limit = amount_min_limit
|
|
48
|
+
@bacen_id = bacen_id
|
|
49
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
50
|
+
@description = description
|
|
51
|
+
@installment_end = StarkCore::Utils::Checks.check_datetime(installment_end == '' ? nil : installment_end)
|
|
52
|
+
@installment_start = StarkCore::Utils::Checks.check_datetime(installment_start == '' ? nil : installment_start)
|
|
53
|
+
@interval = interval
|
|
54
|
+
@pull_retry_limit = pull_retry_limit
|
|
55
|
+
@receiver_bank_code = receiver_bank_code
|
|
56
|
+
@receiver_name = receiver_name
|
|
57
|
+
@receiver_tax_id = receiver_tax_id
|
|
58
|
+
@reference_code = reference_code
|
|
59
|
+
@sender_final_name = sender_final_name
|
|
60
|
+
@sender_final_tax_id = sender_final_tax_id
|
|
61
|
+
@status = status
|
|
62
|
+
@type = type
|
|
63
|
+
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def self.parse_subscription(json)
|
|
67
|
+
return nil if json.nil? || (json.respond_to?(:empty?) && json.empty?)
|
|
68
|
+
|
|
69
|
+
subscription_maker = Subscription.resource[:resource_maker]
|
|
70
|
+
StarkCore::Utils::API.from_api_json(subscription_maker, json)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def self.resource
|
|
74
|
+
{
|
|
75
|
+
resource_name: 'Subscription',
|
|
76
|
+
resource_maker: proc { |json|
|
|
77
|
+
Subscription.new(
|
|
78
|
+
amount: json['amount'],
|
|
79
|
+
amount_min_limit: json['amount_min_limit'],
|
|
80
|
+
bacen_id: json['bacen_id'],
|
|
81
|
+
created: json['created'],
|
|
82
|
+
description: json['description'],
|
|
83
|
+
installment_end: json['installment_end'],
|
|
84
|
+
installment_start: json['installment_start'],
|
|
85
|
+
interval: json['interval'],
|
|
86
|
+
pull_retry_limit: json['pull_retry_limit'],
|
|
87
|
+
receiver_bank_code: json['receiver_bank_code'],
|
|
88
|
+
receiver_name: json['receiver_name'],
|
|
89
|
+
receiver_tax_id: json['receiver_tax_id'],
|
|
90
|
+
reference_code: json['reference_code'],
|
|
91
|
+
sender_final_name: json['sender_final_name'],
|
|
92
|
+
sender_final_tax_id: json['sender_final_tax_id'],
|
|
93
|
+
status: json['status'],
|
|
94
|
+
type: json['type'],
|
|
95
|
+
updated: json['updated']
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -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
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('../utils/rest')
|
|
5
|
+
require_relative('business_account_request')
|
|
6
|
+
|
|
7
|
+
module StarkInfra
|
|
8
|
+
class BusinessAccountRequest
|
|
9
|
+
# # BusinessAccountRequest::Log object
|
|
10
|
+
#
|
|
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.
|
|
14
|
+
#
|
|
15
|
+
# ## Attributes (return-only):
|
|
16
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
|
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'
|
|
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 BusinessAccountRequest::Log
|
|
32
|
+
#
|
|
33
|
+
# Receive a single BusinessAccountRequest::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
|
+
# - BusinessAccountRequest::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 BusinessAccountRequest::Logs
|
|
48
|
+
#
|
|
49
|
+
# Receive a generator of BusinessAccountRequest::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. 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']
|
|
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 BusinessAccountRequest::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 BusinessAccountRequest::Logs
|
|
76
|
+
#
|
|
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
|
+
#
|
|
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: 50
|
|
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. 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
|
+
# - 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 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
|
+
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::BusinessAccountRequest.resource[:resource_maker]
|
|
109
|
+
{
|
|
110
|
+
resource_name: 'BusinessAccountRequestLog',
|
|
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
|