starkinfra 0.5.0 → 0.6.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/{brcodepreview/brcodepreview.rb → brcode_preview/brcode_preview.rb} +5 -2
- data/lib/brcode_preview/subscription.rb +102 -0
- data/lib/business_attachment/business_attachment.rb +186 -0
- data/lib/business_attachment/log.rb +127 -0
- data/lib/business_identity/business_identity.rb +225 -0
- data/lib/business_identity/log.rb +127 -0
- data/lib/{creditnote/creditnote.rb → credit_note/credit_note.rb} +11 -5
- data/lib/{creditnote → credit_note}/log.rb +1 -1
- data/lib/credit_note/rule.rb +46 -0
- data/lib/event/event.rb +10 -2
- data/lib/{individualdocument → individual_document}/log.rb +1 -1
- data/lib/{individualidentity → individual_identity}/log.rb +1 -1
- data/lib/{issuingbalance/issuingbalance.rb → 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/{issuingcard/issuingcard.rb → issuing_card/issuing_card.rb} +5 -2
- data/lib/{issuingcard → issuing_card}/log.rb +1 -1
- data/lib/{issuingembossingrequest → issuing_embossing_request}/log.rb +1 -1
- data/lib/{issuingholder → issuing_holder}/log.rb +1 -1
- data/lib/{issuinginvoice → issuing_invoice}/log.rb +1 -1
- data/lib/{issuingproduct/issuingproduct.rb → issuing_product/issuing_product.rb} +5 -2
- data/lib/{issuingpurchase/issuingpurchase.rb → issuing_purchase/issuing_purchase.rb} +18 -9
- data/lib/{issuingpurchase → issuing_purchase}/log.rb +1 -1
- data/lib/{issuingrestock → issuing_restock}/log.rb +1 -1
- data/lib/{issuingrule/issuingrule.rb → issuing_rule/issuing_rule.rb} +9 -3
- data/lib/{issuingstock/issuingstock.rb → issuing_stock/issuing_stock.rb} +5 -2
- data/lib/{issuingstock → issuing_stock}/log.rb +1 -1
- data/lib/issuing_stock_rule/issuing_stock_rule.rb +213 -0
- data/lib/issuing_token/issuing_token.rb +309 -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/{merchantcategory/merchantcategory.rb → merchant_category/merchant_category.rb} +6 -3
- data/lib/{pixchargeback → pix_chargeback}/log.rb +1 -1
- data/lib/{pixchargeback/pixchargeback.rb → pix_chargeback/pix_chargeback.rb} +26 -2
- data/lib/{pixclaim → pix_claim}/log.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/{pixinfraction → pix_infraction}/log.rb +1 -1
- data/lib/{pixinfraction/pixinfraction.rb → pix_infraction/pix_infraction.rb} +18 -4
- 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/{pixkey → pix_key}/log.rb +1 -1
- data/lib/pix_key_holmes/pix_key_holmes.rb +139 -0
- data/lib/pix_pull_request/log.rb +127 -0
- data/lib/pix_pull_request/pix_pull_request.rb +265 -0
- data/lib/pix_pull_subscription/log.rb +127 -0
- data/lib/pix_pull_subscription/pix_pull_subscription.rb +281 -0
- data/lib/{pixrequest → pix_request}/log.rb +1 -1
- data/lib/{pixrequest/pixrequest.rb → pix_request/pix_request.rb} +9 -2
- data/lib/{pixreversal → pix_reversal}/log.rb +1 -1
- data/lib/starkinfra.rb +83 -59
- data/lib/utils/parse.rb +2 -2
- data/lib/utils/return_id.rb +24 -0
- data/lib/webhook/webhook.rb +2 -2
- metadata +87 -67
- /data/lib/{cardmethod/cardmethod.rb → card_method/card_method.rb} +0 -0
- /data/lib/{creditholmes/creditholmes.rb → credit_holmes/credit_holmes.rb} +0 -0
- /data/lib/{creditnote → credit_note}/invoice/description.rb +0 -0
- /data/lib/{creditnote → credit_note}/invoice/discount.rb +0 -0
- /data/lib/{creditnote → credit_note}/invoice/invoice.rb +0 -0
- /data/lib/{creditnote → credit_note}/transfer.rb +0 -0
- /data/lib/{creditpreview/creditnotepreview.rb → credit_preview/credit_note_preview.rb} +0 -0
- /data/lib/{creditpreview/creditpreview.rb → credit_preview/credit_preview.rb} +0 -0
- /data/lib/{creditsigner/creditsigner.rb → credit_signer/credit_signer.rb} +0 -0
- /data/lib/{dynamicbrcode/dynamicbrcode.rb → dynamic_brcode/dynamic_brcode.rb} +0 -0
- /data/lib/{individualdocument/individualdocument.rb → individual_document/individual_document.rb} +0 -0
- /data/lib/{individualidentity/individualidentity.rb → individual_identity/individual_identity.rb} +0 -0
- /data/lib/{issuingdesign/issuingdesign.rb → issuing_design/issuing_design.rb} +0 -0
- /data/lib/{issuingembossingkit/issuingembossingkit.rb → issuing_embossing_kit/issuing_embossing_kit.rb} +0 -0
- /data/lib/{issuingembossingrequest/issuingembossingrequest.rb → issuing_embossing_request/issuing_embossing_request.rb} +0 -0
- /data/lib/{issuingholder/issuingholder.rb → issuing_holder/issuing_holder.rb} +0 -0
- /data/lib/{issuinginvoice/issuinginvoice.rb → issuing_invoice/issuing_invoice.rb} +0 -0
- /data/lib/{issuingrestock/issuingrestock.rb → issuing_restock/issuing_restock.rb} +0 -0
- /data/lib/{issuingtransaction/issuingtransaction.rb → issuing_transaction/issuing_transaction.rb} +0 -0
- /data/lib/{issuingwithdrawal/issuingwithdrawal.rb → issuing_withdrawal/issuing_withdrawal.rb} +0 -0
- /data/lib/{merchantcountry/merchantcountry.rb → merchant_country/merchant_country.rb} +0 -0
- /data/lib/{pixbalance/pixbalance.rb → pix_balance/pix_balance.rb} +0 -0
- /data/lib/{pixclaim/pixclaim.rb → pix_claim/pix_claim.rb} +0 -0
- /data/lib/{pixdirector/pixdirector.rb → pix_director/pix_director.rb} +0 -0
- /data/lib/{pixdomain → pix_domain}/certificate.rb +0 -0
- /data/lib/{pixdomain/pixdomain.rb → pix_domain/pix_domain.rb} +0 -0
- /data/lib/{pixkey/pixkey.rb → pix_key/pix_key.rb} +0 -0
- /data/lib/{pixreversal/pixreversal.rb → pix_reversal/pix_reversal.rb} +0 -0
- /data/lib/{pixstatement/pixstatement.rb → pix_statement/pix_statement.rb} +0 -0
- /data/lib/{staticbrcode/staticbrcode.rb → static_brcode/static_brcode.rb} +0 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('../utils/rest')
|
|
5
|
+
|
|
6
|
+
module StarkInfra
|
|
7
|
+
# # PixPullRequest object
|
|
8
|
+
#
|
|
9
|
+
# A PixPullRequest is a command sent to the payer's bank to trigger the automatic debit
|
|
10
|
+
# linked to an active PixPullSubscription. It confirms the receiver's intent to collect the
|
|
11
|
+
# agreed amount within the current billing cycle and initiates the settlement process
|
|
12
|
+
# through the Pix infrastructure. Each pull request references a parent subscription via
|
|
13
|
+
# subscription_id.
|
|
14
|
+
#
|
|
15
|
+
# When you initialize a PixPullRequest, the entity will not be automatically
|
|
16
|
+
# created in the Stark Infra API. The 'create' function sends the objects
|
|
17
|
+
# to the Stark Infra API and returns the list of created objects.
|
|
18
|
+
#
|
|
19
|
+
# ## Parameters (required):
|
|
20
|
+
# - amount [integer]: amount to be charged in cents. ex: 11234 (= R$ 112.34)
|
|
21
|
+
# - due [DateTime or string]: due date for answering with an approval or denial. ex: '2020-10-28T17:59:26.249976+00:00'
|
|
22
|
+
# - end_to_end_id [string]: Central Bank's unique transaction id. ex: 'E00002649202201172211u34srod19le'
|
|
23
|
+
# - receiver_account_number [string]: receiver's bank account number. Use '-' before the verifier digit. ex: '876543-2'
|
|
24
|
+
# - receiver_account_type [string]: receiver's account type. Options: 'checking', 'savings', 'salary', 'payment'
|
|
25
|
+
# - receiver_bank_code [string]: receiver's bank code. ex: '20018183'
|
|
26
|
+
# - reconciliation_id [string]: id used for conciliation of the resulting Pix transaction. Up to 25 alphanumeric chars. ex: '123456'
|
|
27
|
+
# - subscription_id [string]: unique id of the parent PixPullSubscription. ex: '5656565656565656'
|
|
28
|
+
#
|
|
29
|
+
# ## Parameters (optional):
|
|
30
|
+
# - attempt_type [string, default nil]: defines the type of attempt. Options: 'default', 'instantRetry', 'scheduledRetry'
|
|
31
|
+
# - description [string, default nil]: additional information to be delivered to the sender. ex: 'Payment for service #1234'
|
|
32
|
+
# - receiver_branch_code [string, default nil]: receiver's branch code. ex: '1357-9'
|
|
33
|
+
# - tags [list of strings, default nil]: free-form labels for filtering. ex: ['employees', 'monthly']
|
|
34
|
+
#
|
|
35
|
+
# ## Attributes (return-only):
|
|
36
|
+
# - id [string]: unique id returned when the PixPullRequest is created. ex: '5656565656565656'
|
|
37
|
+
# - status [string]: current PixPullRequest status. Options: 'created', 'processing', 'scheduled', 'denied', 'success', 'canceled', 'expired'
|
|
38
|
+
# - flow [string]: direction of money flow. Options: 'in', 'out'
|
|
39
|
+
# - receiver_name [string]: receiver's full name (filled in by the Pix infrastructure during settlement). ex: 'Edward Stark'
|
|
40
|
+
# - receiver_tax_id [string]: receiver's tax ID (CPF or CNPJ). ex: '01234567890' or '20.018.183/0001-80'
|
|
41
|
+
# - sender_bank_code [string]: sender's bank institution code in Brazil. ex: '20018183'
|
|
42
|
+
# - sender_final_name [string]: sender's final name when the sender differs from the originating institution. ex: 'Edward Stark'
|
|
43
|
+
# - sender_tax_id [string]: sender's tax ID (CPF or CNPJ). ex: '01234567890' or '20.018.183/0001-80'
|
|
44
|
+
# - subscription_bacen_id [string]: bacen_id of the parent subscription, denormalized for convenience.
|
|
45
|
+
# - created [DateTime]: creation datetime for the PixPullRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
46
|
+
# - updated [DateTime]: latest update datetime for the PixPullRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
47
|
+
class PixPullRequest < StarkCore::Utils::Resource
|
|
48
|
+
attr_reader :amount, :due, :end_to_end_id, :receiver_account_number, :receiver_account_type,
|
|
49
|
+
:receiver_bank_code, :reconciliation_id, :subscription_id, :attempt_type, :description,
|
|
50
|
+
:receiver_branch_code, :tags, :id, :status, :flow, :receiver_name, :receiver_tax_id,
|
|
51
|
+
:sender_bank_code, :sender_final_name, :sender_tax_id, :subscription_bacen_id,
|
|
52
|
+
:created, :updated
|
|
53
|
+
def initialize(
|
|
54
|
+
amount:, due:, end_to_end_id:, receiver_account_number:, receiver_account_type:,
|
|
55
|
+
receiver_bank_code:, reconciliation_id:, subscription_id:,
|
|
56
|
+
attempt_type: nil, description: nil, receiver_branch_code: nil, tags: nil,
|
|
57
|
+
id: nil, status: nil, flow: nil, receiver_name: nil, receiver_tax_id: nil,
|
|
58
|
+
sender_bank_code: nil, sender_final_name: nil, sender_tax_id: nil,
|
|
59
|
+
subscription_bacen_id: nil, created: nil, updated: nil
|
|
60
|
+
)
|
|
61
|
+
super(id)
|
|
62
|
+
@amount = amount
|
|
63
|
+
@due = StarkCore::Utils::Checks.check_datetime(due == '' ? nil : due)
|
|
64
|
+
@end_to_end_id = end_to_end_id
|
|
65
|
+
@receiver_account_number = receiver_account_number
|
|
66
|
+
@receiver_account_type = receiver_account_type
|
|
67
|
+
@receiver_bank_code = receiver_bank_code
|
|
68
|
+
@reconciliation_id = reconciliation_id
|
|
69
|
+
@subscription_id = subscription_id
|
|
70
|
+
@attempt_type = attempt_type
|
|
71
|
+
@description = description
|
|
72
|
+
@receiver_branch_code = receiver_branch_code
|
|
73
|
+
@tags = tags
|
|
74
|
+
@status = status
|
|
75
|
+
@flow = flow
|
|
76
|
+
@receiver_name = receiver_name
|
|
77
|
+
@receiver_tax_id = receiver_tax_id
|
|
78
|
+
@sender_bank_code = sender_bank_code
|
|
79
|
+
@sender_final_name = sender_final_name
|
|
80
|
+
@sender_tax_id = sender_tax_id
|
|
81
|
+
@subscription_bacen_id = subscription_bacen_id
|
|
82
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
83
|
+
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# # Create PixPullRequests
|
|
87
|
+
#
|
|
88
|
+
# Send a list of PixPullRequest objects for creation in the Stark Infra API
|
|
89
|
+
#
|
|
90
|
+
# ## Parameters (required):
|
|
91
|
+
# - requests [list of PixPullRequest objects]: list of PixPullRequest objects to be created in the API
|
|
92
|
+
#
|
|
93
|
+
# ## Parameters (optional):
|
|
94
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
95
|
+
#
|
|
96
|
+
# ## Return:
|
|
97
|
+
# - list of PixPullRequest objects with updated attributes
|
|
98
|
+
def self.create(requests, user: nil)
|
|
99
|
+
StarkInfra::Utils::Rest.post(entities: requests, user: user, **resource)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# # Retrieve a specific PixPullRequest
|
|
103
|
+
#
|
|
104
|
+
# Receive a single PixPullRequest object previously created in the Stark Infra API by passing its id
|
|
105
|
+
#
|
|
106
|
+
# ## Parameters (required):
|
|
107
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
|
108
|
+
#
|
|
109
|
+
# ## Parameters (optional):
|
|
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
|
+
# - PixPullRequest object with updated attributes
|
|
114
|
+
def self.get(id, user: nil)
|
|
115
|
+
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# # Retrieve PixPullRequests
|
|
119
|
+
#
|
|
120
|
+
# Receive a generator of PixPullRequest objects previously created in the Stark Infra API
|
|
121
|
+
#
|
|
122
|
+
# ## Parameters (optional):
|
|
123
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
|
124
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
125
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
126
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'created'
|
|
127
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['employees', 'monthly']
|
|
128
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
129
|
+
# - subscription_ids [list of strings, default nil]: list of parent subscription ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
130
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
131
|
+
#
|
|
132
|
+
# ## Return:
|
|
133
|
+
# - generator of PixPullRequest objects with updated attributes
|
|
134
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, subscription_ids: nil, user: nil)
|
|
135
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
136
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
137
|
+
StarkInfra::Utils::Rest.get_stream(
|
|
138
|
+
limit: limit,
|
|
139
|
+
after: after,
|
|
140
|
+
before: before,
|
|
141
|
+
status: status,
|
|
142
|
+
tags: tags,
|
|
143
|
+
ids: ids,
|
|
144
|
+
subscription_ids: subscription_ids,
|
|
145
|
+
user: user,
|
|
146
|
+
**resource
|
|
147
|
+
)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# # Retrieve paged PixPullRequests
|
|
151
|
+
#
|
|
152
|
+
# Receive a list of up to 100 PixPullRequest objects previously created in the Stark Infra API and the cursor to the next page.
|
|
153
|
+
# Use this function instead of query if you want to manually page your requests.
|
|
154
|
+
#
|
|
155
|
+
# ## Parameters (optional):
|
|
156
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
|
157
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
|
158
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
159
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
160
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['created', 'active']
|
|
161
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['employees', 'monthly']
|
|
162
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
163
|
+
# - subscription_ids [list of strings, default nil]: list of parent subscription ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
164
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
165
|
+
#
|
|
166
|
+
# ## Return:
|
|
167
|
+
# - list of PixPullRequest objects with updated attributes
|
|
168
|
+
# - cursor to retrieve the next page of PixPullRequest objects
|
|
169
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, subscription_ids: nil, user: nil)
|
|
170
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
171
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
172
|
+
StarkInfra::Utils::Rest.get_page(
|
|
173
|
+
cursor: cursor,
|
|
174
|
+
limit: limit,
|
|
175
|
+
after: after,
|
|
176
|
+
before: before,
|
|
177
|
+
status: status,
|
|
178
|
+
tags: tags,
|
|
179
|
+
ids: ids,
|
|
180
|
+
subscription_ids: subscription_ids,
|
|
181
|
+
user: user,
|
|
182
|
+
**resource
|
|
183
|
+
)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# # Update a PixPullRequest entity
|
|
187
|
+
#
|
|
188
|
+
# Update a PixPullRequest entity previously created in the Stark Infra API.
|
|
189
|
+
# The patch payload accepts at minimum status ('scheduled' or 'denied') and a
|
|
190
|
+
# conditionally-required reason (one of 'senderAccountClosed', 'senderAccountBlocked',
|
|
191
|
+
# 'amountNotAllowed').
|
|
192
|
+
#
|
|
193
|
+
# ## Parameters (required):
|
|
194
|
+
# - id [string]: PixPullRequest unique id. ex: '5656565656565656'
|
|
195
|
+
#
|
|
196
|
+
# ## Parameters (optional):
|
|
197
|
+
# - patch_data [hash, default nil]: hash of fields to be updated. ex: { status: 'denied', reason: 'amountNotAllowed' }
|
|
198
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
199
|
+
#
|
|
200
|
+
# ## Return:
|
|
201
|
+
# - updated PixPullRequest object
|
|
202
|
+
def self.update(id, patch_data: nil, user: nil)
|
|
203
|
+
patch_data ||= {}
|
|
204
|
+
StarkInfra::Utils::Rest.patch_id(id: id, user: user, **patch_data, **resource)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# # Cancel a PixPullRequest entity
|
|
208
|
+
#
|
|
209
|
+
# Cancel a PixPullRequest entity previously created in the Stark Infra API.
|
|
210
|
+
# The reason is sent as a query parameter, not in the request body.
|
|
211
|
+
#
|
|
212
|
+
# ## Parameters (required):
|
|
213
|
+
# - id [string]: PixPullRequest unique id. ex: '5656565656565656'
|
|
214
|
+
# - reason [string]: reason for the cancellation. As receiver: 'accountClosed', 'receiverOrganizationClosed', 'receiverInternalError', 'fraud', 'receiverUserRequested'. As sender: 'accountClosed', 'senderDeceased', 'fraud', 'senderUserRequested'.
|
|
215
|
+
#
|
|
216
|
+
# ## Parameters (optional):
|
|
217
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
218
|
+
#
|
|
219
|
+
# ## Return:
|
|
220
|
+
# - canceled PixPullRequest object
|
|
221
|
+
def self.cancel(id, reason:, user: nil)
|
|
222
|
+
response = StarkInfra::Utils::Rest.delete_raw(
|
|
223
|
+
path: "/pix-pull-request/#{id}",
|
|
224
|
+
query: { reason: reason },
|
|
225
|
+
user: user,
|
|
226
|
+
raiseException: true
|
|
227
|
+
)
|
|
228
|
+
maker = resource[:resource_maker]
|
|
229
|
+
StarkCore::Utils::API.from_api_json(maker, response.json['request'])
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def self.resource
|
|
233
|
+
{
|
|
234
|
+
resource_name: 'PixPullRequest',
|
|
235
|
+
resource_maker: proc { |json|
|
|
236
|
+
PixPullRequest.new(
|
|
237
|
+
id: json['id'],
|
|
238
|
+
amount: json['amount'],
|
|
239
|
+
due: json['due'],
|
|
240
|
+
end_to_end_id: json['end_to_end_id'],
|
|
241
|
+
receiver_account_number: json['receiver_account_number'],
|
|
242
|
+
receiver_account_type: json['receiver_account_type'],
|
|
243
|
+
receiver_bank_code: json['receiver_bank_code'],
|
|
244
|
+
reconciliation_id: json['reconciliation_id'],
|
|
245
|
+
subscription_id: json['subscription_id'],
|
|
246
|
+
attempt_type: json['attempt_type'],
|
|
247
|
+
description: json['description'],
|
|
248
|
+
receiver_branch_code: json['receiver_branch_code'],
|
|
249
|
+
tags: json['tags'],
|
|
250
|
+
status: json['status'],
|
|
251
|
+
flow: json['flow'],
|
|
252
|
+
receiver_name: json['receiver_name'],
|
|
253
|
+
receiver_tax_id: json['receiver_tax_id'],
|
|
254
|
+
sender_bank_code: json['sender_bank_code'],
|
|
255
|
+
sender_final_name: json['sender_final_name'],
|
|
256
|
+
sender_tax_id: json['sender_tax_id'],
|
|
257
|
+
subscription_bacen_id: json['subscription_bacen_id'],
|
|
258
|
+
created: json['created'],
|
|
259
|
+
updated: json['updated']
|
|
260
|
+
)
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('pix_pull_subscription')
|
|
5
|
+
require_relative('../utils/rest')
|
|
6
|
+
|
|
7
|
+
module StarkInfra
|
|
8
|
+
class PixPullSubscription
|
|
9
|
+
# # PixPullSubscription::Log object
|
|
10
|
+
#
|
|
11
|
+
# Every time a PixPullSubscription entity is modified, a corresponding PixPullSubscription::Log
|
|
12
|
+
# is generated for the entity. This log is never generated by the user.
|
|
13
|
+
#
|
|
14
|
+
# ## Attributes (return-only):
|
|
15
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
|
16
|
+
# - subscription [PixPullSubscription]: PixPullSubscription entity to which the log refers to.
|
|
17
|
+
# - type [string]: type of the PixPullSubscription event which triggered the log creation. Options: 'created', 'delivering', 'delivered', 'failed', 'approved', 'denied', 'confirmed', 'expired', 'canceling', 'canceled'
|
|
18
|
+
# - errors [list of strings]: list of errors linked to this PixPullSubscription event.
|
|
19
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
20
|
+
class Log < StarkCore::Utils::Resource
|
|
21
|
+
attr_reader :id, :subscription, :type, :errors, :created
|
|
22
|
+
def initialize(id:, subscription:, type:, errors:, created:)
|
|
23
|
+
super(id)
|
|
24
|
+
@subscription = subscription
|
|
25
|
+
@type = type
|
|
26
|
+
@errors = errors
|
|
27
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# # Retrieve a specific PixPullSubscription::Log
|
|
31
|
+
#
|
|
32
|
+
# Receive a single PixPullSubscription::Log object previously created by the Stark Infra API by passing its id
|
|
33
|
+
#
|
|
34
|
+
# ## Parameters (required):
|
|
35
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
|
36
|
+
#
|
|
37
|
+
# ## Parameters (optional):
|
|
38
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
39
|
+
#
|
|
40
|
+
# ## Return:
|
|
41
|
+
# - PixPullSubscription::Log object with updated attributes
|
|
42
|
+
def self.get(id, user: nil)
|
|
43
|
+
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# # Retrieve PixPullSubscription::Logs
|
|
47
|
+
#
|
|
48
|
+
# Receive a generator of PixPullSubscription::Log objects previously created in the Stark Infra API
|
|
49
|
+
#
|
|
50
|
+
# ## Parameters (optional):
|
|
51
|
+
# - ids [list of strings, default nil]: Log ids to filter PixPullSubscription Logs. ex: ['5656565656565656']
|
|
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 retrieved objects by types. Options: 'created', 'delivering', 'delivered', 'failed', 'approved', 'denied', 'confirmed', 'expired', 'canceling', 'canceled'
|
|
56
|
+
# - subscription_ids [list of strings, default nil]: list of PixPullSubscription ids to filter retrieved objects. 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 PixPullSubscription::Log objects with updated attributes
|
|
61
|
+
def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, subscription_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
|
+
ids: ids,
|
|
66
|
+
limit: limit,
|
|
67
|
+
after: after,
|
|
68
|
+
before: before,
|
|
69
|
+
types: types,
|
|
70
|
+
subscription_ids: subscription_ids,
|
|
71
|
+
user: user,
|
|
72
|
+
**resource
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# # Retrieve paged PixPullSubscription::Logs
|
|
77
|
+
#
|
|
78
|
+
# Receive a list of up to 100 PixPullSubscription::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 subscriptions.
|
|
80
|
+
#
|
|
81
|
+
# ## Parameters (optional):
|
|
82
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
|
83
|
+
# - ids [list of strings, default nil]: Log ids to filter PixPullSubscription Logs. ex: ['5656565656565656']
|
|
84
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
|
85
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
86
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
87
|
+
# - types [list of strings, default nil]: filter retrieved objects by types. Options: 'created', 'delivering', 'delivered', 'failed', 'approved', 'denied', 'confirmed', 'expired', 'canceling', 'canceled'
|
|
88
|
+
# - subscription_ids [list of strings, default nil]: list of PixPullSubscription ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
89
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
90
|
+
#
|
|
91
|
+
# ## Return:
|
|
92
|
+
# - list of PixPullSubscription::Log objects with updated attributes
|
|
93
|
+
# - cursor to retrieve the next page of Log objects
|
|
94
|
+
def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, subscription_ids: nil, user: nil)
|
|
95
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
96
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
97
|
+
StarkInfra::Utils::Rest.get_page(
|
|
98
|
+
cursor: cursor,
|
|
99
|
+
ids: ids,
|
|
100
|
+
limit: limit,
|
|
101
|
+
after: after,
|
|
102
|
+
before: before,
|
|
103
|
+
types: types,
|
|
104
|
+
subscription_ids: subscription_ids,
|
|
105
|
+
user: user,
|
|
106
|
+
**resource
|
|
107
|
+
)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def self.resource
|
|
111
|
+
subscription_maker = StarkInfra::PixPullSubscription.resource[:resource_maker]
|
|
112
|
+
{
|
|
113
|
+
resource_name: 'PixPullSubscriptionLog',
|
|
114
|
+
resource_maker: proc { |json|
|
|
115
|
+
Log.new(
|
|
116
|
+
id: json['id'],
|
|
117
|
+
subscription: StarkCore::Utils::API.from_api_json(subscription_maker, json['subscription']),
|
|
118
|
+
type: json['type'],
|
|
119
|
+
errors: json['errors'],
|
|
120
|
+
created: json['created']
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|