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.
- checksums.yaml +4 -4
- data/lib/brcode_preview/brcode_preview.rb +22 -4
- data/lib/brcode_preview/subscription.rb +2 -2
- data/lib/business_account_request/business_account_request.rb +276 -0
- data/lib/{individual_document → business_account_request}/log.rb +35 -35
- data/lib/business_attachment/business_attachment.rb +6 -3
- data/lib/business_identity/business_identity.rb +7 -4
- data/lib/credit_holmes/credit_holmes.rb +2 -1
- data/lib/credit_holmes/log.rb +125 -0
- data/lib/credit_note/credit_note.rb +42 -5
- data/lib/credit_note/rule.rb +9 -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 +2 -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_card/issuing_card.rb +5 -4
- 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 +2 -2
- data/lib/issuing_purchase/issuing_purchase.rb +25 -1
- data/lib/issuing_restock/issuing_restock.rb +3 -2
- data/lib/issuing_rule/issuing_rule.rb +36 -0
- data/lib/issuing_stock_rule/issuing_stock_rule.rb +6 -5
- data/lib/issuing_token/issuing_token.rb +2 -2
- data/lib/issuing_token/log.rb +127 -0
- data/lib/issuing_token_activation/issuing_token_activation.rb +62 -0
- data/lib/issuing_token_request/issuing_token_request.rb +1 -1
- 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/pix_balance/pix_balance.rb +1 -1
- data/lib/pix_chargeback/pix_chargeback.rb +10 -7
- data/lib/pix_claim/pix_claim.rb +14 -6
- data/lib/pix_director/pix_director.rb +1 -1
- data/lib/pix_dispute/pix_dispute.rb +1 -1
- data/lib/pix_dispute/transaction.rb +4 -4
- data/lib/pix_fraud/pix_fraud.rb +1 -1
- data/lib/pix_infraction/pix_infraction.rb +21 -5
- data/lib/pix_internal_transaction_report/pix_internal_transaction_report.rb +1 -1
- data/lib/pix_key/pix_key.rb +1 -1
- data/lib/pix_key_holmes/log.rb +129 -0
- data/lib/pix_key_holmes/pix_key_holmes.rb +19 -2
- data/lib/pix_pull_request/pix_pull_request.rb +6 -3
- data/lib/pix_pull_subscription/pix_pull_subscription.rb +31 -5
- data/lib/pix_request/pix_request.rb +13 -7
- 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 +20 -3
- 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 +1 -4
- data/lib/webhook/webhook.rb +2 -2
- metadata +21 -4
- data/lib/individual_document/individual_document.rb +0 -164
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('../utils/rest')
|
|
5
|
+
require_relative('credit_holmes')
|
|
6
|
+
|
|
7
|
+
module StarkInfra
|
|
8
|
+
class CreditHolmes
|
|
9
|
+
# # CreditHolmes::Log object
|
|
10
|
+
#
|
|
11
|
+
# Every time a CreditHolmes entity is updated, a corresponding CreditHolmes::Log
|
|
12
|
+
# is generated for the entity. This log is never generated by the
|
|
13
|
+
# user, but it can be retrieved to check additional information
|
|
14
|
+
# on the CreditHolmes.
|
|
15
|
+
#
|
|
16
|
+
# ## Attributes (return-only):
|
|
17
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
|
18
|
+
# - holmes [CreditHolmes]: CreditHolmes entity to which the log refers to.
|
|
19
|
+
# - errors [list of strings]: list of errors linked to this CreditHolmes event.
|
|
20
|
+
# - type [string]: type of the CreditHolmes event which triggered the log creation. ex: 'created', 'failed', 'success'
|
|
21
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
22
|
+
class Log < StarkCore::Utils::Resource
|
|
23
|
+
attr_reader :id, :created, :type, :errors, :holmes
|
|
24
|
+
def initialize(id:, created:, type:, errors:, holmes:)
|
|
25
|
+
super(id)
|
|
26
|
+
@holmes = holmes
|
|
27
|
+
@errors = errors
|
|
28
|
+
@type = type
|
|
29
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# # Retrieve a specific CreditHolmes::Log
|
|
33
|
+
#
|
|
34
|
+
# Receive a single CreditHolmes::Log object previously created by the Stark Infra API by its id
|
|
35
|
+
#
|
|
36
|
+
# ## Parameters (required):
|
|
37
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
|
38
|
+
#
|
|
39
|
+
# ## Parameters (optional):
|
|
40
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
41
|
+
#
|
|
42
|
+
# ## Return:
|
|
43
|
+
# - CreditHolmes::Log object with updated attributes
|
|
44
|
+
def self.get(id, user: nil)
|
|
45
|
+
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# # Retrieve CreditHolmes::Logs
|
|
49
|
+
#
|
|
50
|
+
# Receive a generator of CreditHolmes::Log objects previously created in the Stark Infra API
|
|
51
|
+
#
|
|
52
|
+
# ## Parameters (optional):
|
|
53
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
|
54
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
55
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
56
|
+
# - types [list of strings, default nil]: filter for log event types. ex: ['created', 'failed', 'success']
|
|
57
|
+
# - holmes_ids [list of strings, default nil]: list of CreditHolmes ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
|
58
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
59
|
+
#
|
|
60
|
+
# ## Return:
|
|
61
|
+
# - generator of CreditHolmes::Log objects with updated attributes
|
|
62
|
+
def self.query(limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil, user: nil)
|
|
63
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
64
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
65
|
+
StarkInfra::Utils::Rest.get_stream(
|
|
66
|
+
limit: limit,
|
|
67
|
+
after: after,
|
|
68
|
+
before: before,
|
|
69
|
+
types: types,
|
|
70
|
+
holmes_ids: holmes_ids,
|
|
71
|
+
user: user,
|
|
72
|
+
**resource
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# # Retrieve paged CreditHolmes::Logs
|
|
77
|
+
#
|
|
78
|
+
# Receive a list of up to 100 CreditHolmes::Log objects previously created in the Stark Infra API and the cursor to the next page.
|
|
79
|
+
# Use this function instead of query if you want to manually page your requests.
|
|
80
|
+
#
|
|
81
|
+
# ## Parameters (optional):
|
|
82
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
|
83
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
|
84
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
85
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
86
|
+
# - types [list of strings, default nil]: filter for log event types. ex: ['created', 'failed', 'success']
|
|
87
|
+
# - holmes_ids [list of strings, default nil]: list of CreditHolmes ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
|
88
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
89
|
+
#
|
|
90
|
+
# ## Return:
|
|
91
|
+
# - list of CreditHolmes::Log objects with updated attributes
|
|
92
|
+
# - cursor to retrieve the next page of CreditHolmes::Log objects
|
|
93
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil, user: nil)
|
|
94
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
95
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
96
|
+
StarkInfra::Utils::Rest.get_page(
|
|
97
|
+
cursor: cursor,
|
|
98
|
+
limit: limit,
|
|
99
|
+
after: after,
|
|
100
|
+
before: before,
|
|
101
|
+
types: types,
|
|
102
|
+
holmes_ids: holmes_ids,
|
|
103
|
+
user: user,
|
|
104
|
+
**resource
|
|
105
|
+
)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def self.resource
|
|
109
|
+
holmes_maker = StarkInfra::CreditHolmes.resource[:resource_maker]
|
|
110
|
+
{
|
|
111
|
+
resource_name: 'CreditHolmesLog',
|
|
112
|
+
resource_maker: proc { |json|
|
|
113
|
+
Log.new(
|
|
114
|
+
id: json['id'],
|
|
115
|
+
holmes: StarkCore::Utils::API.from_api_json(holmes_maker, json['holmes']),
|
|
116
|
+
errors: json['errors'],
|
|
117
|
+
type: json['type'],
|
|
118
|
+
created: json['created']
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -22,9 +22,9 @@ module StarkInfra
|
|
|
22
22
|
# - name [string]: credit receiver's full name. ex: 'Edward Stark'
|
|
23
23
|
# - tax_id [string]: credit receiver's tax ID (CPF or CNPJ). ex: '20.018.183/0001-80'
|
|
24
24
|
# - scheduled [DateTime, Date or string]: date of transfer execution. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
25
|
-
# - invoices [list of CreditNote::Invoice objects]:
|
|
25
|
+
# - invoices [list of up to 100 CreditNote::Invoice objects]: installments to be paid by the borrower. All invoices in the same CreditNote must share the same fine and interest. ex: [Invoice.new(), Invoice.new()]
|
|
26
26
|
# - payment [CreditNote::Transfer object]: payment entity to be created and sent to the credit receiver. ex: Transfer.new()
|
|
27
|
-
# - signers [list of CreditSigner objects]: signer's name, contact and delivery method for the signature request. ex: [CreditSigner.new(), CreditSigner.new()]
|
|
27
|
+
# - signers [list of up to 10 CreditSigner objects]: signer's name, contact and delivery method for the signature request. ex: [CreditSigner.new(), CreditSigner.new()]
|
|
28
28
|
# - external_id [string]: a string that must be unique among all your CreditNotes, used to avoid resource duplication. ex: 'my-internal-id-123456'
|
|
29
29
|
# - street_line_1 [string]: credit receiver main address. ex: 'Av. Paulista, 200'
|
|
30
30
|
# - street_line_2 [string]: credit receiver address complement. ex: 'Apto. 123'
|
|
@@ -42,7 +42,7 @@ module StarkInfra
|
|
|
42
42
|
# - rebate_amount [integer, default nil]: credit analysis fee deducted from lent amount. ex: 11234 (= R$ 112.34)
|
|
43
43
|
# - tags [list of strings, default nil]: list of strings for reference when searching for CreditNotes. ex: ['employees', 'monthly']
|
|
44
44
|
# - expiration [integer, default 604800]: time interval in seconds between scheduled date and expiration date. ex: 123456789
|
|
45
|
-
# - rules [list of CreditNote::Rule, default []]: list of
|
|
45
|
+
# - rules [list of CreditNote::Rule, default []]: list of {key, value} rules modifying the credit note behavior. Currently available key: 'invoiceCreationMode', values 'scheduled' (default - invoice issued a few days before due date), 'instant' (issued as soon as disbursed) or 'never' (not issued automatically).
|
|
46
46
|
#
|
|
47
47
|
# ## Attributes (return-only):
|
|
48
48
|
# - id [string]: unique id returned when the CreditNote is created. ex: '5656565656565656'
|
|
@@ -106,7 +106,8 @@ module StarkInfra
|
|
|
106
106
|
|
|
107
107
|
# # Create CreditNotes
|
|
108
108
|
#
|
|
109
|
-
# Send a list of CreditNote objects for creation in the Stark Infra API
|
|
109
|
+
# Send a list of CreditNote objects for creation in the Stark Infra API. You can create up to 100
|
|
110
|
+
# CreditNotes in a single call.
|
|
110
111
|
#
|
|
111
112
|
# ## Parameters (required):
|
|
112
113
|
# - notes [list of CreditNote objects]: list of CreditNote objects to be created in the API
|
|
@@ -202,7 +203,9 @@ module StarkInfra
|
|
|
202
203
|
|
|
203
204
|
# # Cancel a CreditNote entity
|
|
204
205
|
#
|
|
205
|
-
# Cancel a CreditNote entity previously created in the Stark Infra API
|
|
206
|
+
# Cancel a CreditNote entity previously created in the Stark Infra API. Only CreditNotes with status
|
|
207
|
+
# 'created', 'signed' or 'processing' are actually canceled (which also cancels the signing document);
|
|
208
|
+
# notes already 'success', 'failed', 'expired' or 'canceled' are returned unchanged.
|
|
206
209
|
#
|
|
207
210
|
# ## Parameters (required):
|
|
208
211
|
# - id [string]: object unique id. ex: '5656565656565656'
|
|
@@ -216,6 +219,40 @@ module StarkInfra
|
|
|
216
219
|
StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
|
|
217
220
|
end
|
|
218
221
|
|
|
222
|
+
# # Retrieve a specific CreditNote pdf file
|
|
223
|
+
#
|
|
224
|
+
# Receive the CCB disbursement pdf file of a CreditNote previously created in the Stark Infra API by its id.
|
|
225
|
+
# Not available for canceled CreditNotes.
|
|
226
|
+
#
|
|
227
|
+
# ## Parameters (required):
|
|
228
|
+
# - id [string]: CreditNote unique id. ex: '5656565656565656'
|
|
229
|
+
#
|
|
230
|
+
# ## Parameters (optional):
|
|
231
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
232
|
+
#
|
|
233
|
+
# ## Return:
|
|
234
|
+
# - CreditNote pdf file
|
|
235
|
+
def self.pdf(id, user: nil)
|
|
236
|
+
StarkInfra::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'pdf', **resource)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# # Retrieve a specific CreditNote payment pdf file
|
|
240
|
+
#
|
|
241
|
+
# Receive the CCB disbursement payment pdf file of a CreditNote previously created in the Stark Infra API by its id.
|
|
242
|
+
# Only CreditNotes with status "success" have a payment pdf.
|
|
243
|
+
#
|
|
244
|
+
# ## Parameters (required):
|
|
245
|
+
# - id [string]: CreditNote unique id. ex: '5656565656565656'
|
|
246
|
+
#
|
|
247
|
+
# ## Parameters (optional):
|
|
248
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
249
|
+
#
|
|
250
|
+
# ## Return:
|
|
251
|
+
# - CreditNote payment pdf file
|
|
252
|
+
def self.payment(id, user: nil)
|
|
253
|
+
StarkInfra::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'payment/pdf', **resource)
|
|
254
|
+
end
|
|
255
|
+
|
|
219
256
|
def self.parse_payment(payment, payment_type)
|
|
220
257
|
resource_maker = { 'transfer' => Transfer.resource[:resource_maker] }
|
|
221
258
|
if payment.is_a?(Hash)
|
data/lib/credit_note/rule.rb
CHANGED
|
@@ -16,6 +16,15 @@ module StarkInfra
|
|
|
16
16
|
@value = value
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
# # Parse CreditNote::Rules
|
|
20
|
+
#
|
|
21
|
+
# Converts a list of hashes (or Rule objects) received from the API into a list of CreditNote::Rule objects.
|
|
22
|
+
#
|
|
23
|
+
# ## Parameters (required):
|
|
24
|
+
# - rules [list of hashes or CreditNote::Rule objects]: list to be parsed.
|
|
25
|
+
#
|
|
26
|
+
# ## Return:
|
|
27
|
+
# - list of parsed CreditNote::Rule objects
|
|
19
28
|
def self.parse_rules(rules)
|
|
20
29
|
resource_maker = StarkInfra::CreditNote::Rule.resource[:resource_maker]
|
|
21
30
|
return rules if rules.nil?
|
data/lib/credit_note/transfer.rb
CHANGED
|
@@ -12,7 +12,7 @@ module StarkInfra
|
|
|
12
12
|
# ## Parameters (required):
|
|
13
13
|
# - name [string]: receiver full name. ex: 'Anthony Edward Stark'
|
|
14
14
|
# - tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
|
|
15
|
-
# - bank_code [string]:
|
|
15
|
+
# - bank_code [string]: receiver institution ISPB code, 8 digits. ex: '20018183'
|
|
16
16
|
# - branch_code [string]: receiver bank account branch. Use '-' in case there is a verifier digit. ex: '1357-9'
|
|
17
17
|
# - account_number [string]: receiver bank account number. Use '-' before the verifier digit. ex: '876543-2'
|
|
18
18
|
#
|
|
@@ -13,18 +13,26 @@ module StarkInfra
|
|
|
13
13
|
# to the Stark Infra API and returns the list of created objects.
|
|
14
14
|
#
|
|
15
15
|
# ## Parameters (required):
|
|
16
|
-
# - type [string]: table type that defines the amortization system. Options: 'sac', 'price', 'american', 'bullet', 'custom'
|
|
16
|
+
# - type [string]: table type that defines the amortization system. Options: 'sac' (constant amortization), 'price' (fixed installments), 'american' (periodic interest and principal at maturity), 'bullet' (principal and interest at maturity), 'custom' (you provide the invoices and the rates are computed).
|
|
17
17
|
# - nominal_amount [integer]: amount in cents transferred to the credit receiver, before deductions. ex: 11234 (= R$ 112.34)
|
|
18
18
|
# - scheduled [DateTime, Date or string]: date of transfer execution. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
19
19
|
# - tax_id [string]: credit receiver's tax ID (CPF or CNPJ). ex: '20.018.183/0001-80'
|
|
20
20
|
#
|
|
21
21
|
# ## Parameters (conditionally required):
|
|
22
|
+
# - nominal_amount or amount [integer]: provide exactly one; the other is computed from the invoice schedule (not used for type 'custom').
|
|
23
|
+
# - count or initial_amount [integer]: for 'sac' and 'price' types, provide exactly one; the other is computed.
|
|
22
24
|
# - invoices [list of CreditNote::Invoice objects]: list of CreditNote.Invoice objects to be created and sent to the credit receiver.
|
|
23
25
|
# - nominal_interest [float]: yearly nominal interest rate of the credit note, in percentage. ex: 12.5
|
|
24
26
|
# - initial_due [DateTime, Date or string]: date of the first invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0), Date.new(2020, 3, 10) or '2020-03-10'
|
|
25
27
|
# - count [integer]: quantity of invoices for payment. ex: 12
|
|
26
28
|
# - initial_amount [integer]: value of the first invoice in cents. ex: 1234 (= R$12.34)
|
|
27
|
-
# - interval [string]: interval between invoices.
|
|
29
|
+
# - interval [string, default 'month']: interval between invoices. Options: 'day', 'week', 'month', 'quarter', 'semester', 'year'.
|
|
30
|
+
#
|
|
31
|
+
# ## Parameters (conditionally required, by type):
|
|
32
|
+
# - 'sac'/'price': nominal_interest, scheduled, initial_due, tax_id and one of count/initial_amount.
|
|
33
|
+
# - 'american': nominal_interest, scheduled, initial_due, count, tax_id.
|
|
34
|
+
# - 'bullet': nominal_interest, scheduled, initial_due, tax_id.
|
|
35
|
+
# - 'custom': scheduled, tax_id, invoices.
|
|
28
36
|
#
|
|
29
37
|
# ## Parameters (optional):
|
|
30
38
|
# - rebate_amount [integer, default nil]: credit analysis fee deducted from lent amount. ex: 11234 (= R$ 112.34)
|
|
@@ -23,7 +23,8 @@ module StarkInfra
|
|
|
23
23
|
|
|
24
24
|
# # Create CreditPreviews
|
|
25
25
|
#
|
|
26
|
-
# Send a list of CreditPreview objects for processing in the Stark Infra API
|
|
26
|
+
# Send a list of CreditPreview objects for processing in the Stark Infra API. You can create up to 100
|
|
27
|
+
# previews in a single call.
|
|
27
28
|
#
|
|
28
29
|
# ## Parameters (required):
|
|
29
30
|
# - previews [list of CreditPreview objects]: list of CreditPreview objects to be created in the API
|
|
@@ -9,8 +9,8 @@ module StarkInfra
|
|
|
9
9
|
#
|
|
10
10
|
# ## Parameters (required):
|
|
11
11
|
# - name [string]: signer's name. ex: 'Tony Stark'
|
|
12
|
-
# - contact [string]: signer
|
|
13
|
-
# - method [string]:
|
|
12
|
+
# - contact [string]: signer contact that receives the signing link or token. Can be an email, a phone number or, for the 'server' and 'organization' methods, a URL. ex: 'tony@starkindustries.com'
|
|
13
|
+
# - method [string]: signing method. Options: 'link' (signing link sent to the contact), 'token' (signing token sent to the contact), 'server' and 'organization' (automatic signatures over URL contacts).
|
|
14
14
|
#
|
|
15
15
|
# ## Attributes (return-only):
|
|
16
16
|
# - id [string]: unique id returned when the CreditSigner is created. ex: '5656565656565656'
|
|
@@ -23,6 +23,31 @@ module StarkInfra
|
|
|
23
23
|
@method = method
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
# # Resend token to signer
|
|
27
|
+
#
|
|
28
|
+
# Resend token to a specific signer.
|
|
29
|
+
#
|
|
30
|
+
# ## Parameters (required):
|
|
31
|
+
# - id [string]: CreditSigner unique id. ex: '5656565656565656'
|
|
32
|
+
#
|
|
33
|
+
# ## Parameters (optional):
|
|
34
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
35
|
+
#
|
|
36
|
+
# ## Return:
|
|
37
|
+
# - CreditSigner object with updated attributes
|
|
38
|
+
def self.resend_token(id, user: nil)
|
|
39
|
+
StarkInfra::Utils::Rest.patch_id(id: id, is_sent: false, user: user, **resource)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# # Parse CreditSigners
|
|
43
|
+
#
|
|
44
|
+
# Converts a list of hashes (or CreditSigner objects) received from the API into a list of CreditSigner objects.
|
|
45
|
+
#
|
|
46
|
+
# ## Parameters (required):
|
|
47
|
+
# - signers [list of hashes or CreditSigner objects]: list to be parsed.
|
|
48
|
+
#
|
|
49
|
+
# ## Return:
|
|
50
|
+
# - list of parsed CreditSigner objects
|
|
26
51
|
def self.parse_signers(signers)
|
|
27
52
|
resource_maker = StarkInfra::CreditSigner.resource[:resource_maker]
|
|
28
53
|
return signers if signers.nil?
|
|
@@ -13,6 +13,9 @@ module StarkInfra
|
|
|
13
13
|
# in the BR Code. Stark Infra will receive the GET request and forward it to your
|
|
14
14
|
# registered endpoint with a GET request containing the UUID of the BR Code for
|
|
15
15
|
# identification.
|
|
16
|
+
# The 'subscription', 'subscriptionAndInstant' and 'dueAndOrSubscription' types let a DynamicBrcode initiate
|
|
17
|
+
# a Pix Automático recurring authorization; subscription reads are answered through PixPullSubscription, not
|
|
18
|
+
# response_due/response_instant.
|
|
16
19
|
#
|
|
17
20
|
# When you initialize a DynamicBrcode, the entity will not be automatically
|
|
18
21
|
# created in the Stark Infra API. The 'create' function sends the objects
|
|
@@ -24,7 +27,7 @@ module StarkInfra
|
|
|
24
27
|
# - external_id [string]: string that must be unique among all your DynamicBrcodes. Duplicated external ids will cause failures. ex: 'my-internal-id-123456'
|
|
25
28
|
#
|
|
26
29
|
# ## Parameters (optional):
|
|
27
|
-
# - type [string, default 'instant']: type of the DynamicBrcode. Options: 'instant', 'due'
|
|
30
|
+
# - type [string, default 'instant']: type of the DynamicBrcode. Options: 'instant', 'due', 'subscription', 'subscriptionAndInstant', 'dueAndOrSubscription'.
|
|
28
31
|
# - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
|
|
29
32
|
#
|
|
30
33
|
# ## Attributes (return-only):
|
|
@@ -281,7 +284,7 @@ module StarkInfra
|
|
|
281
284
|
# ## Return:
|
|
282
285
|
# - verified Brcode's uuid.
|
|
283
286
|
def self.verify(uuid:, signature:, user: nil)
|
|
284
|
-
|
|
287
|
+
StarkInfra::Utils::Parse.verify(content: uuid, signature: signature, user: user)
|
|
285
288
|
end
|
|
286
289
|
|
|
287
290
|
def self.resource
|
data/lib/event/event.rb
CHANGED
|
@@ -132,7 +132,7 @@ module StarkInfra
|
|
|
132
132
|
|
|
133
133
|
# # Delete a notification Event
|
|
134
134
|
#
|
|
135
|
-
# Delete a notification Event entity previously created in the Stark Infra API by its ID
|
|
135
|
+
# Delete a notification Event entity previously created in the Stark Infra API by its ID. This action cannot be undone.
|
|
136
136
|
#
|
|
137
137
|
# ## Parameters (required):
|
|
138
138
|
# - id [string]: Event unique id. ex: '5656565656565656'
|
|
@@ -152,7 +152,7 @@ module StarkInfra
|
|
|
152
152
|
# If is_delivered is true, the event will no longer be returned on queries with is_delivered=false.
|
|
153
153
|
#
|
|
154
154
|
# ## Parameters (required):
|
|
155
|
-
# - id [
|
|
155
|
+
# - id [string]: Event unique id. ex: '5656565656565656'
|
|
156
156
|
# - is_delivered [bool]: If true and event hasn't been delivered already, event will be set as delivered. ex: true
|
|
157
157
|
#
|
|
158
158
|
# ## Parameters (optional):
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('../utils/rest')
|
|
5
|
+
|
|
6
|
+
module StarkInfra
|
|
7
|
+
# # IndividualAccountAttachment object
|
|
8
|
+
#
|
|
9
|
+
# Supporting document (identity document, driver's license) attached to an IndividualAccountRequest
|
|
10
|
+
# for the account-approval flow. The caller uploads the raw image bytes and a MIME content type;
|
|
11
|
+
# the SDK encodes them as a data: URL before sending.
|
|
12
|
+
#
|
|
13
|
+
# When you initialize an IndividualAccountAttachment, 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
|
+
# - type [string]: type of the IndividualAccountAttachment. Options: 'drivers-license-front', 'drivers-license-back', 'identity-front', 'identity-back'
|
|
19
|
+
# - content [string]: raw image bytes of the picture. After encoding, becomes a data:<contentType>;base64,<payload> URL.
|
|
20
|
+
# - account_request_id [string]: id of the parent IndividualAccountRequest. ex: '5656565656565656'
|
|
21
|
+
#
|
|
22
|
+
# ## Parameters (optional):
|
|
23
|
+
# - content_type [string, default nil]: content MIME type. Consumed as input only to build the data: URL; never sent as its own wire field. ex: 'image/png' or 'image/jpeg'
|
|
24
|
+
# - tags [list of strings, default nil]: list of strings for reference when searching for IndividualAccountAttachments. ex: ['employees', 'monthly']
|
|
25
|
+
#
|
|
26
|
+
# ## Attributes (return-only):
|
|
27
|
+
# - id [string]: unique id returned when the IndividualAccountAttachment is created. ex: '5656565656565656'
|
|
28
|
+
# - status [string]: current status of the IndividualAccountAttachment. Options: 'created', 'success', 'failed', 'deleted'
|
|
29
|
+
# - created [DateTime]: creation datetime for the IndividualAccountAttachment. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
30
|
+
class IndividualAccountAttachment < StarkCore::Utils::Resource
|
|
31
|
+
attr_reader :type, :content, :content_type, :account_request_id, :tags, :id, :status, :created
|
|
32
|
+
def initialize(type:, content:, account_request_id:, content_type: nil, tags: nil, id: nil, status: nil, created: nil)
|
|
33
|
+
super(id)
|
|
34
|
+
@type = type
|
|
35
|
+
@account_request_id = account_request_id
|
|
36
|
+
@tags = tags
|
|
37
|
+
@status = status
|
|
38
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
39
|
+
@content = content
|
|
40
|
+
@content_type = content_type
|
|
41
|
+
|
|
42
|
+
if @content_type
|
|
43
|
+
@content = "data:#{content_type};base64,#{Base64.encode64(content)}"
|
|
44
|
+
@content_type = nil
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# # Create IndividualAccountAttachments
|
|
49
|
+
#
|
|
50
|
+
# Send a list of IndividualAccountAttachment objects for creation at the Stark Infra API
|
|
51
|
+
#
|
|
52
|
+
# ## Parameters (required):
|
|
53
|
+
# - attachments [list of IndividualAccountAttachment objects]: list of IndividualAccountAttachment objects to be created in the API.
|
|
54
|
+
#
|
|
55
|
+
# ## Parameters (optional):
|
|
56
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
57
|
+
#
|
|
58
|
+
# ## Return:
|
|
59
|
+
# - list of IndividualAccountAttachment objects with updated attributes
|
|
60
|
+
def self.create(attachments, user: nil)
|
|
61
|
+
StarkInfra::Utils::Rest.post(entities: attachments, user: user, **resource)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# # Retrieve a specific IndividualAccountAttachment
|
|
65
|
+
#
|
|
66
|
+
# Receive a single IndividualAccountAttachment object previously created in the Stark Infra API by its id
|
|
67
|
+
#
|
|
68
|
+
# ## Parameters (required):
|
|
69
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
|
70
|
+
#
|
|
71
|
+
# ## Parameters (optional):
|
|
72
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
73
|
+
#
|
|
74
|
+
# ## Return:
|
|
75
|
+
# - IndividualAccountAttachment object with updated attributes
|
|
76
|
+
def self.get(id, user: nil)
|
|
77
|
+
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# # Retrieve IndividualAccountAttachments
|
|
81
|
+
#
|
|
82
|
+
# Receive a generator of IndividualAccountAttachment objects previously created in the Stark Infra API
|
|
83
|
+
#
|
|
84
|
+
# ## Parameters (optional):
|
|
85
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
|
86
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
87
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
88
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'created'
|
|
89
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
|
90
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
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
|
+
# - generator of IndividualAccountAttachment objects with updated attributes
|
|
95
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
|
96
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
97
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
98
|
+
StarkInfra::Utils::Rest.get_stream(
|
|
99
|
+
limit: limit,
|
|
100
|
+
after: after,
|
|
101
|
+
before: before,
|
|
102
|
+
status: status,
|
|
103
|
+
tags: tags,
|
|
104
|
+
ids: ids,
|
|
105
|
+
user: user,
|
|
106
|
+
**resource
|
|
107
|
+
)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# # Retrieve paged IndividualAccountAttachments
|
|
111
|
+
#
|
|
112
|
+
# Receive a list of up to 100 IndividualAccountAttachment objects previously created in the Stark Infra API and the cursor to the next page.
|
|
113
|
+
# Use this function instead of query if you want to manually page your requests.
|
|
114
|
+
#
|
|
115
|
+
# ## Parameters (optional):
|
|
116
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
|
117
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex 35
|
|
118
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
119
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
120
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'created'
|
|
121
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
|
122
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
123
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
124
|
+
#
|
|
125
|
+
# ## Return:
|
|
126
|
+
# - list of IndividualAccountAttachment objects with updated attributes
|
|
127
|
+
# - cursor to retrieve the next page of IndividualAccountAttachment objects
|
|
128
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
|
129
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
130
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
131
|
+
StarkInfra::Utils::Rest.get_page(
|
|
132
|
+
cursor: cursor,
|
|
133
|
+
limit: limit,
|
|
134
|
+
after: after,
|
|
135
|
+
before: before,
|
|
136
|
+
status: status,
|
|
137
|
+
tags: tags,
|
|
138
|
+
ids: ids,
|
|
139
|
+
user: user,
|
|
140
|
+
**resource
|
|
141
|
+
)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# # Cancel an IndividualAccountAttachment entity
|
|
145
|
+
#
|
|
146
|
+
# Cancel an IndividualAccountAttachment entity previously created in the Stark Infra API
|
|
147
|
+
#
|
|
148
|
+
# ## Parameters (required):
|
|
149
|
+
# - id [string]: IndividualAccountAttachment unique id. ex: '5656565656565656'
|
|
150
|
+
#
|
|
151
|
+
# ## Parameters (optional):
|
|
152
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
153
|
+
#
|
|
154
|
+
# ## Return:
|
|
155
|
+
# - canceled IndividualAccountAttachment object
|
|
156
|
+
def self.cancel(id, user: nil)
|
|
157
|
+
StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def self.resource
|
|
161
|
+
{
|
|
162
|
+
resource_name: 'IndividualAccountAttachment',
|
|
163
|
+
resource_maker: proc { |json|
|
|
164
|
+
IndividualAccountAttachment.new(
|
|
165
|
+
type: json['type'],
|
|
166
|
+
content: json['content'],
|
|
167
|
+
content_type: json['content_type'],
|
|
168
|
+
account_request_id: json['account_request_id'],
|
|
169
|
+
tags: json['tags'],
|
|
170
|
+
id: json['id'],
|
|
171
|
+
status: json['status'],
|
|
172
|
+
created: json['created']
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|