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
|
@@ -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
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('../utils/rest')
|
|
5
|
+
require_relative('individual_account_attachment')
|
|
6
|
+
|
|
7
|
+
module StarkInfra
|
|
8
|
+
class IndividualAccountAttachment
|
|
9
|
+
# # IndividualAccountAttachment::Log object
|
|
10
|
+
#
|
|
11
|
+
# Every time an IndividualAccountAttachment entity is modified, a corresponding IndividualAccountAttachment::Log
|
|
12
|
+
# is generated for the entity. This Log is never generated by the user, but it can be retrieved to check
|
|
13
|
+
# additional information on the IndividualAccountAttachment.
|
|
14
|
+
#
|
|
15
|
+
# ## Attributes (return-only):
|
|
16
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
|
17
|
+
# - attachment [IndividualAccountAttachment]: IndividualAccountAttachment entity to which the log refers to.
|
|
18
|
+
# - errors [list of strings]: list of errors linked to this IndividualAccountAttachment event.
|
|
19
|
+
# - type [string]: type of the IndividualAccountAttachment event which triggered the log creation. Options: 'created', 'success', 'failed', 'deleted'
|
|
20
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
21
|
+
class Log < StarkCore::Utils::Resource
|
|
22
|
+
attr_reader :id, :attachment, :errors, :type, :created
|
|
23
|
+
def initialize(id: nil, attachment: nil, errors: nil, type: nil, created: nil)
|
|
24
|
+
super(id)
|
|
25
|
+
@attachment = attachment
|
|
26
|
+
@errors = errors
|
|
27
|
+
@type = type
|
|
28
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# # Retrieve a specific IndividualAccountAttachment::Log
|
|
32
|
+
#
|
|
33
|
+
# Receive a single IndividualAccountAttachment::Log object previously created by the Stark Infra API by passing its id
|
|
34
|
+
#
|
|
35
|
+
# ## Parameters (required):
|
|
36
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
|
37
|
+
#
|
|
38
|
+
# ## Parameters (optional):
|
|
39
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
40
|
+
#
|
|
41
|
+
# ## Return:
|
|
42
|
+
# - IndividualAccountAttachment::Log object with updated attributes
|
|
43
|
+
def self.get(id, user: nil)
|
|
44
|
+
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# # Retrieve IndividualAccountAttachment::Logs
|
|
48
|
+
#
|
|
49
|
+
# Receive a generator of IndividualAccountAttachment::Log objects previously created in the Stark Infra API
|
|
50
|
+
#
|
|
51
|
+
# ## Parameters (optional):
|
|
52
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
|
53
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
54
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
55
|
+
# - types [list of strings, default nil]: filter for log event types. Options: 'created', 'success', 'failed', 'deleted'
|
|
56
|
+
# - attachment_ids [list of strings, default nil]: list of IndividualAccountAttachment ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
|
57
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
58
|
+
#
|
|
59
|
+
# ## Return:
|
|
60
|
+
# - generator of IndividualAccountAttachment::Log objects with updated attributes
|
|
61
|
+
def self.query(limit: nil, after: nil, before: nil, types: nil, attachment_ids: nil, user: nil)
|
|
62
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
63
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
64
|
+
StarkInfra::Utils::Rest.get_stream(
|
|
65
|
+
limit: limit,
|
|
66
|
+
after: after,
|
|
67
|
+
before: before,
|
|
68
|
+
types: types,
|
|
69
|
+
attachment_ids: attachment_ids,
|
|
70
|
+
user: user,
|
|
71
|
+
**resource
|
|
72
|
+
)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# # Retrieve paged IndividualAccountAttachment::Logs
|
|
76
|
+
#
|
|
77
|
+
# Receive a list of up to 100 IndividualAccountAttachment::Log objects previously created in the Stark Infra API and the cursor to the next page.
|
|
78
|
+
# Use this function instead of query if you want to manually page your requests.
|
|
79
|
+
#
|
|
80
|
+
# ## Parameters (optional):
|
|
81
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
|
82
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
|
83
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
84
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
85
|
+
# - types [list of strings, default nil]: filter for log event types. Options: 'created', 'success', 'failed', 'deleted'
|
|
86
|
+
# - attachment_ids [list of strings, default nil]: list of IndividualAccountAttachment ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
|
87
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
88
|
+
#
|
|
89
|
+
# ## Return:
|
|
90
|
+
# - list of IndividualAccountAttachment::Log objects with updated attributes
|
|
91
|
+
# - cursor to retrieve the next page of Log objects
|
|
92
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, attachment_ids: nil, user: nil)
|
|
93
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
94
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
95
|
+
StarkInfra::Utils::Rest.get_page(
|
|
96
|
+
cursor: cursor,
|
|
97
|
+
limit: limit,
|
|
98
|
+
after: after,
|
|
99
|
+
before: before,
|
|
100
|
+
types: types,
|
|
101
|
+
attachment_ids: attachment_ids,
|
|
102
|
+
user: user,
|
|
103
|
+
**resource
|
|
104
|
+
)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def self.resource
|
|
108
|
+
attachment_maker = StarkInfra::IndividualAccountAttachment.resource[:resource_maker]
|
|
109
|
+
{
|
|
110
|
+
resource_name: 'IndividualAccountAttachmentLog',
|
|
111
|
+
resource_maker: proc { |json|
|
|
112
|
+
Log.new(
|
|
113
|
+
id: json['id'],
|
|
114
|
+
attachment: StarkCore::Utils::API.from_api_json(attachment_maker, json['attachment']),
|
|
115
|
+
errors: json['errors'],
|
|
116
|
+
type: json['type'],
|
|
117
|
+
created: json['created']
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('../utils/rest')
|
|
5
|
+
|
|
6
|
+
module StarkInfra
|
|
7
|
+
# # IndividualAccountRequest object
|
|
8
|
+
#
|
|
9
|
+
# Request to open a Stark Infra account for an individual. The caller submits the individual's
|
|
10
|
+
# identifying data and income, and the API runs the approval flow asynchronously. Supporting
|
|
11
|
+
# documents are uploaded as IndividualAccountAttachment objects referencing this request.
|
|
12
|
+
#
|
|
13
|
+
# When you initialize an IndividualAccountRequest, the entity will not be automatically
|
|
14
|
+
# created in the Stark Infra API. The 'create' function sends the objects
|
|
15
|
+
# to the Stark Infra API and returns the list of created objects.
|
|
16
|
+
#
|
|
17
|
+
# ## Parameters (required):
|
|
18
|
+
# - name [string]: full legal name of the individual. ex: 'Tony Stark'
|
|
19
|
+
# - tax_id [string]: individual's Brazilian CPF. ex: '012.345.678-90' or '01234567890'
|
|
20
|
+
# - address [IndividualAccountRequest::Address object]: structured residential address.
|
|
21
|
+
# - income [integer]: monthly income in cents. Must be >= 0. ex: 1000000 (= R$ 10,000.00)
|
|
22
|
+
#
|
|
23
|
+
# ## Parameters (optional):
|
|
24
|
+
# - birth_date [Date or string, default nil]: individual's birth date. Returned as nil when not informed. ex: Date.new(2012, 3, 6) or '2012-03-06'
|
|
25
|
+
# - tags [list of strings, default nil]: list of strings for reference when searching for IndividualAccountRequests. ex: ['employees', 'monthly']
|
|
26
|
+
#
|
|
27
|
+
# ## Attributes (return-only):
|
|
28
|
+
# - id [string]: unique id returned when the IndividualAccountRequest is created. ex: '5656565656565656'
|
|
29
|
+
# - status [string]: current status of the IndividualAccountRequest. Options: 'created', 'processing', 'approved', 'denied', 'failed'
|
|
30
|
+
# - account_type [string]: account type of the request. Always 'individual' for this resource. ex: 'individual'
|
|
31
|
+
# - flags [list of hashes]: flags raised by the KYC pipeline, populated when the request is denied. Each flag has a code and a message. ex: [{ 'code' => 'bureauValidation', 'message' => '...' }]
|
|
32
|
+
# - validator_link [string]: webview link to be delivered to the taker to complete biometrics and document capture.
|
|
33
|
+
# - created [DateTime]: creation datetime for the IndividualAccountRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
34
|
+
# - updated [DateTime]: latest update datetime for the IndividualAccountRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
35
|
+
class IndividualAccountRequest < StarkCore::Utils::Resource
|
|
36
|
+
attr_reader :name, :tax_id, :address, :income, :birth_date, :tags, :id, :status, :account_type, :flags, :validator_link, :created, :updated
|
|
37
|
+
def initialize(
|
|
38
|
+
name:, tax_id:, address:, income:, birth_date: nil, tags: nil,
|
|
39
|
+
id: nil, status: nil, account_type: nil, flags: nil, validator_link: nil, created: nil, updated: nil
|
|
40
|
+
)
|
|
41
|
+
super(id)
|
|
42
|
+
@name = name
|
|
43
|
+
@tax_id = tax_id
|
|
44
|
+
@address = IndividualAccountRequest::Address.parse_address(address)
|
|
45
|
+
@income = income
|
|
46
|
+
@birth_date = birth_date.to_s.empty? ? nil : StarkCore::Utils::Checks.check_date(birth_date)
|
|
47
|
+
@tags = tags
|
|
48
|
+
@status = status
|
|
49
|
+
@account_type = account_type
|
|
50
|
+
@flags = flags
|
|
51
|
+
@validator_link = validator_link
|
|
52
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
53
|
+
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# # Create IndividualAccountRequests
|
|
57
|
+
#
|
|
58
|
+
# Send a list of IndividualAccountRequest objects for creation at the Stark Infra API
|
|
59
|
+
#
|
|
60
|
+
# ## Parameters (required):
|
|
61
|
+
# - requests [list of IndividualAccountRequest objects]: list of IndividualAccountRequest objects to be created in the API.
|
|
62
|
+
#
|
|
63
|
+
# ## Parameters (optional):
|
|
64
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
65
|
+
#
|
|
66
|
+
# ## Return:
|
|
67
|
+
# - list of IndividualAccountRequest objects with updated attributes
|
|
68
|
+
def self.create(requests, user: nil)
|
|
69
|
+
# Output-only fields (id, status, account_type, flags, created, updated) are
|
|
70
|
+
# rejected by the API on POST with "Unknown parameters in JSON: ...". Strip
|
|
71
|
+
# them from a shallow dup so the caller's objects are unmodified. The core
|
|
72
|
+
# serializer (StarkCore::Utils::API.build_entity_hash) skips nil ivars.
|
|
73
|
+
stripped = requests.map do |req|
|
|
74
|
+
copy = req.dup
|
|
75
|
+
%i[@id @status @account_type @flags @created @updated].each do |ivar|
|
|
76
|
+
copy.instance_variable_set(ivar, nil)
|
|
77
|
+
end
|
|
78
|
+
copy
|
|
79
|
+
end
|
|
80
|
+
StarkInfra::Utils::Rest.post(entities: stripped, user: user, **resource)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# # Retrieve a specific IndividualAccountRequest
|
|
84
|
+
#
|
|
85
|
+
# Receive a single IndividualAccountRequest object previously created in the Stark Infra API by its id
|
|
86
|
+
#
|
|
87
|
+
# ## Parameters (required):
|
|
88
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
|
89
|
+
#
|
|
90
|
+
# ## Parameters (optional):
|
|
91
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
92
|
+
#
|
|
93
|
+
# ## Return:
|
|
94
|
+
# - IndividualAccountRequest object with updated attributes
|
|
95
|
+
def self.get(id, user: nil)
|
|
96
|
+
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# # Retrieve IndividualAccountRequests
|
|
100
|
+
#
|
|
101
|
+
# Receive a generator of IndividualAccountRequest objects previously created in the Stark Infra API
|
|
102
|
+
#
|
|
103
|
+
# ## Parameters (optional):
|
|
104
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
|
105
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
106
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
107
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'created'
|
|
108
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
|
109
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
110
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
111
|
+
#
|
|
112
|
+
# ## Return:
|
|
113
|
+
# - generator of IndividualAccountRequest objects with updated attributes
|
|
114
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
|
115
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
116
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
117
|
+
StarkInfra::Utils::Rest.get_stream(
|
|
118
|
+
limit: limit,
|
|
119
|
+
after: after,
|
|
120
|
+
before: before,
|
|
121
|
+
status: status,
|
|
122
|
+
tags: tags,
|
|
123
|
+
ids: ids,
|
|
124
|
+
user: user,
|
|
125
|
+
**resource
|
|
126
|
+
)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# # Retrieve paged IndividualAccountRequests
|
|
130
|
+
#
|
|
131
|
+
# Receive a list of up to 100 IndividualAccountRequest objects previously created in the Stark Infra API and the cursor to the next page.
|
|
132
|
+
# Use this function instead of query if you want to manually page your requests.
|
|
133
|
+
#
|
|
134
|
+
# ## Parameters (optional):
|
|
135
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
|
136
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex 35
|
|
137
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
138
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
139
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'created'
|
|
140
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
|
141
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
142
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
143
|
+
#
|
|
144
|
+
# ## Return:
|
|
145
|
+
# - list of IndividualAccountRequest objects with updated attributes
|
|
146
|
+
# - cursor to retrieve the next page of IndividualAccountRequest objects
|
|
147
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
|
148
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
149
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
150
|
+
StarkInfra::Utils::Rest.get_page(
|
|
151
|
+
cursor: cursor,
|
|
152
|
+
limit: limit,
|
|
153
|
+
after: after,
|
|
154
|
+
before: before,
|
|
155
|
+
status: status,
|
|
156
|
+
tags: tags,
|
|
157
|
+
ids: ids,
|
|
158
|
+
user: user,
|
|
159
|
+
**resource
|
|
160
|
+
)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# # Update an IndividualAccountRequest entity
|
|
164
|
+
#
|
|
165
|
+
# Update an IndividualAccountRequest by passing its id.
|
|
166
|
+
#
|
|
167
|
+
# ## Parameters (required):
|
|
168
|
+
# - id [string]: IndividualAccountRequest unique id. ex: '5656565656565656'
|
|
169
|
+
#
|
|
170
|
+
# ## Parameters (optional):
|
|
171
|
+
# - name [string, default nil]: replace the legal name. ex: 'Tony Stark'
|
|
172
|
+
# - tax_id [string, default nil]: replace the CPF. ex: '012.345.678-90'
|
|
173
|
+
# - address [IndividualAccountRequest::Address object, default nil]: replace the address as a whole object.
|
|
174
|
+
# - income [integer, default nil]: replace monthly income in cents. ex: 1000000
|
|
175
|
+
# - birth_date [Date or string, default nil]: replace the birth date. ex: '2012-03-06'
|
|
176
|
+
# - status [string, default nil]: manual state transition. ex: 'processing'
|
|
177
|
+
# - tags [list of strings, default nil]: replace tag list. ex: ['employees', 'monthly']
|
|
178
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
179
|
+
#
|
|
180
|
+
# ## Return:
|
|
181
|
+
# - target IndividualAccountRequest with updated attributes
|
|
182
|
+
def self.update(id, name: nil, tax_id: nil, address: nil, income: nil, birth_date: nil, status: nil, tags: nil, user: nil)
|
|
183
|
+
StarkInfra::Utils::Rest.patch_id(
|
|
184
|
+
id: id,
|
|
185
|
+
name: name,
|
|
186
|
+
tax_id: tax_id,
|
|
187
|
+
address: address,
|
|
188
|
+
income: income,
|
|
189
|
+
birth_date: birth_date.to_s.empty? ? nil : StarkCore::Utils::Checks.check_date(birth_date),
|
|
190
|
+
status: status,
|
|
191
|
+
tags: tags,
|
|
192
|
+
user: user,
|
|
193
|
+
**resource
|
|
194
|
+
)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def self.resource
|
|
198
|
+
{
|
|
199
|
+
resource_name: 'IndividualAccountRequest',
|
|
200
|
+
resource_maker: proc { |json|
|
|
201
|
+
IndividualAccountRequest.new(
|
|
202
|
+
id: json['id'],
|
|
203
|
+
name: json['name'],
|
|
204
|
+
tax_id: json['tax_id'],
|
|
205
|
+
address: json['address'],
|
|
206
|
+
income: json['income'],
|
|
207
|
+
birth_date: json['birth_date'],
|
|
208
|
+
tags: json['tags'],
|
|
209
|
+
status: json['status'],
|
|
210
|
+
account_type: json['account_type'],
|
|
211
|
+
flags: json['flags'],
|
|
212
|
+
validator_link: json['validator_link'],
|
|
213
|
+
created: json['created'],
|
|
214
|
+
updated: json['updated']
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# # IndividualAccountRequest::Address object
|
|
221
|
+
#
|
|
222
|
+
# Structured residential address embedded as the `address` field on an IndividualAccountRequest.
|
|
223
|
+
# Serialized as a nested JSON object on the wire (never flattened).
|
|
224
|
+
#
|
|
225
|
+
# ## Parameters (required):
|
|
226
|
+
# - street [string]: street name. ex: 'Rua do Estilo Barroco'
|
|
227
|
+
# - number [string]: street number. ex: '648'
|
|
228
|
+
# - neighborhood [string]: neighborhood / district. ex: 'Santo Amaro'
|
|
229
|
+
# - city [string]: city. ex: 'SP'
|
|
230
|
+
# - state [string]: state (BR 2-letter code). ex: 'SP'
|
|
231
|
+
# - zip_code [string]: ZIP code (BR CEP). ex: '05724005'
|
|
232
|
+
#
|
|
233
|
+
# ## Parameters (optional):
|
|
234
|
+
# - complement [string, default nil]: address complement. ex: 'Apto. 123'
|
|
235
|
+
class Address < StarkCore::Utils::SubResource
|
|
236
|
+
attr_reader :street, :number, :neighborhood, :city, :state, :zip_code, :complement
|
|
237
|
+
def initialize(street: nil, number: nil, neighborhood: nil, city: nil, state: nil, zip_code: nil, complement: nil)
|
|
238
|
+
@street = street
|
|
239
|
+
@number = number
|
|
240
|
+
@neighborhood = neighborhood
|
|
241
|
+
@city = city
|
|
242
|
+
@state = state
|
|
243
|
+
@zip_code = zip_code
|
|
244
|
+
@complement = complement
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def self.parse_address(address)
|
|
248
|
+
return address if address.nil? || address.is_a?(IndividualAccountRequest::Address)
|
|
249
|
+
|
|
250
|
+
StarkCore::Utils::API.from_api_json(resource[:resource_maker], address)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def self.resource
|
|
254
|
+
{
|
|
255
|
+
resource_name: 'Address',
|
|
256
|
+
resource_maker: proc { |json|
|
|
257
|
+
Address.new(
|
|
258
|
+
street: json['street'],
|
|
259
|
+
number: json['number'],
|
|
260
|
+
neighborhood: json['neighborhood'],
|
|
261
|
+
city: json['city'],
|
|
262
|
+
state: json['state'],
|
|
263
|
+
zip_code: json['zip_code'],
|
|
264
|
+
complement: json['complement']
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
end
|