starkinfra 0.5.2 → 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/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/credit_note/credit_note.rb +10 -4
- data/lib/credit_note/rule.rb +46 -0
- data/lib/event/event.rb +8 -0
- 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 +5 -2
- data/lib/issuing_product/issuing_product.rb +5 -2
- data/lib/issuing_purchase/issuing_purchase.rb +16 -7
- data/lib/issuing_rule/issuing_rule.rb +9 -3
- data/lib/issuing_stock/issuing_stock.rb +5 -2
- 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/merchant_category/merchant_category.rb +6 -3
- data/lib/pix_chargeback/pix_chargeback.rb +26 -2
- 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 +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/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/pix_request/pix_request.rb +9 -2
- data/lib/starkinfra.rb +26 -2
- data/lib/utils/return_id.rb +24 -0
- data/lib/webhook/webhook.rb +2 -2
- metadata +29 -9
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('../utils/rest')
|
|
5
|
+
|
|
6
|
+
module StarkInfra
|
|
7
|
+
# # PixPullSubscription object
|
|
8
|
+
#
|
|
9
|
+
# A PixPullSubscription is a recurring Pix debit authorization. It defines the frequency, amount,
|
|
10
|
+
# and required payer authorizations for a series of Pix debits to be pulled from the sender by
|
|
11
|
+
# the receiver. Each cycle of an active subscription is triggered by a PixPullRequest whose
|
|
12
|
+
# subscription_id references the subscription's id.
|
|
13
|
+
#
|
|
14
|
+
# When you initialize a PixPullSubscription, the entity will not be automatically
|
|
15
|
+
# created in the Stark Infra API. The 'create' function sends the objects
|
|
16
|
+
# to the Stark Infra API and returns the list of created objects.
|
|
17
|
+
#
|
|
18
|
+
# ## Parameters (required):
|
|
19
|
+
# - bacen_id [string]: Central Bank's unique recurrency id. Identifies the subscription in the Pix infrastructure.
|
|
20
|
+
# - external_id [string]: url safe string that must be unique among all your Pix Pull Subscriptions. Used for idempotency. ex: 'my-internal-id-123456'
|
|
21
|
+
# - installment_start [DateTime or string]: start datetime of settlements allowed for this subscription. ex: '2020-10-28T17:59:26.249976+00:00'
|
|
22
|
+
# - interval [string]: cycle definition. Options: 'week', 'month', 'quarter', 'semester', 'year'
|
|
23
|
+
# - receiver_name [string]: receiver's full name. ex: 'Edward Stark'
|
|
24
|
+
# - receiver_tax_id [string]: receiver's tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
|
|
25
|
+
# - sender_account_number [string]: sender's bank account number. Use '-' before the verifier digit. ex: '876543-2'
|
|
26
|
+
# - sender_bank_code [string]: sender's bank institution code in Brazil. ex: '20018183'
|
|
27
|
+
# - sender_branch_code [string]: sender's bank account branch code. Use '-' in case there is a verifier digit. ex: '1357-9'
|
|
28
|
+
# - sender_tax_id [string]: sender's tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
|
|
29
|
+
# - type [string]: subscription journey type. Options: 'push', 'qrcode', 'qrcodeAndPayment', 'paymentAndOrQrcode'
|
|
30
|
+
#
|
|
31
|
+
# ## Parameters (conditionally-required):
|
|
32
|
+
# - amount [integer, default nil]: amount in cents charged every cycle. Required if the subscription has a fixed amount. ex: 1234 (= R$ 12.34)
|
|
33
|
+
# - amount_min_limit [integer, default nil]: floor value for the maximum amount the sender can set when approving. Required if the subscription has a variable amount. ex: 1234 (= R$ 12.34)
|
|
34
|
+
#
|
|
35
|
+
# ## Parameters (optional):
|
|
36
|
+
# - description [string, default nil]: additional information delivered to the sender. ex: 'Payment for service #1234'
|
|
37
|
+
# - due [DateTime or string, default nil]: due date for the sender's answer (approval or denial). ex: '2020-10-28T17:59:26.249976+00:00'
|
|
38
|
+
# - installment_end [DateTime or string, default nil]: end datetime of settlements allowed for this subscription. ex: '2020-10-28T17:59:26.249976+00:00'
|
|
39
|
+
# - receiver_bank_code [string, default nil]: receiver's bank institution code. Defaults to the workspace's primary institution when omitted. ex: '20018183'
|
|
40
|
+
# - reference_code [string, default nil]: commercial-relation identifier. May be a contract number, order id, or client code. ex: 'contract-123'
|
|
41
|
+
# - pull_retry_limit [integer, default nil]: max number of retries the receiver may issue for a single failed pull cycle. ex: 3
|
|
42
|
+
# - sender_city_code [string, default nil]: IBGE code of the payer's city. ex: '3550308'
|
|
43
|
+
# - sender_final_name [string, default nil]: final sender name when the sender differs from the originating institution. ex: 'Edward Stark'
|
|
44
|
+
# - sender_final_tax_id [string, default nil]: final sender tax ID. Same format rules as sender_tax_id. ex: '01234567890' or '20.018.183/0001-80'
|
|
45
|
+
# - tags [list of strings, default nil]: list of strings for tagging. ex: ['employees', 'monthly']
|
|
46
|
+
#
|
|
47
|
+
# ## Attributes (return-only):
|
|
48
|
+
# - id [string]: unique id returned when the PixPullSubscription is created. ex: '5656565656565656'
|
|
49
|
+
# - status [string]: current PixPullSubscription status. Options: 'created', 'pending', 'failed', 'denied', 'approved', 'active', 'expired', 'canceled'
|
|
50
|
+
# - flow [string]: direction of money flow. Options: 'in', 'out'
|
|
51
|
+
# - created [DateTime]: creation datetime for the PixPullSubscription. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
52
|
+
# - updated [DateTime]: latest update datetime for the PixPullSubscription. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
53
|
+
class PixPullSubscription < StarkCore::Utils::Resource
|
|
54
|
+
attr_reader :bacen_id, :external_id, :installment_start, :interval, :receiver_name, :receiver_tax_id,
|
|
55
|
+
:sender_account_number, :sender_bank_code, :sender_branch_code, :sender_tax_id, :type,
|
|
56
|
+
:amount, :amount_min_limit, :description, :due, :installment_end, :receiver_bank_code,
|
|
57
|
+
:reference_code, :pull_retry_limit, :sender_city_code, :sender_final_name, :sender_final_tax_id,
|
|
58
|
+
:tags, :id, :status, :flow, :created, :updated
|
|
59
|
+
def initialize(
|
|
60
|
+
bacen_id:, external_id:, installment_start:, interval:, receiver_name:, receiver_tax_id:,
|
|
61
|
+
sender_account_number:, sender_bank_code:, sender_branch_code:, sender_tax_id:, type:,
|
|
62
|
+
amount: nil, amount_min_limit: nil, description: nil, due: nil, installment_end: nil,
|
|
63
|
+
receiver_bank_code: nil, reference_code: nil, pull_retry_limit: nil, sender_city_code: nil,
|
|
64
|
+
sender_final_name: nil, sender_final_tax_id: nil, tags: nil, id: nil, status: nil, flow: nil,
|
|
65
|
+
created: nil, updated: nil
|
|
66
|
+
)
|
|
67
|
+
super(id)
|
|
68
|
+
@bacen_id = bacen_id
|
|
69
|
+
@external_id = external_id
|
|
70
|
+
@installment_start = StarkCore::Utils::Checks.check_datetime(installment_start)
|
|
71
|
+
@interval = interval
|
|
72
|
+
@receiver_name = receiver_name
|
|
73
|
+
@receiver_tax_id = receiver_tax_id
|
|
74
|
+
@sender_account_number = sender_account_number
|
|
75
|
+
@sender_bank_code = sender_bank_code
|
|
76
|
+
@sender_branch_code = sender_branch_code
|
|
77
|
+
@sender_tax_id = sender_tax_id
|
|
78
|
+
@type = type
|
|
79
|
+
@amount = amount
|
|
80
|
+
@amount_min_limit = amount_min_limit
|
|
81
|
+
@description = description
|
|
82
|
+
@due = StarkCore::Utils::Checks.check_datetime(due == '' ? nil : due)
|
|
83
|
+
@installment_end = StarkCore::Utils::Checks.check_datetime(installment_end == '' ? nil : installment_end)
|
|
84
|
+
@receiver_bank_code = receiver_bank_code
|
|
85
|
+
@reference_code = reference_code
|
|
86
|
+
@pull_retry_limit = pull_retry_limit
|
|
87
|
+
@sender_city_code = sender_city_code
|
|
88
|
+
@sender_final_name = sender_final_name
|
|
89
|
+
@sender_final_tax_id = sender_final_tax_id
|
|
90
|
+
@tags = tags
|
|
91
|
+
@status = status
|
|
92
|
+
@flow = flow
|
|
93
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
94
|
+
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# # Create PixPullSubscriptions
|
|
98
|
+
#
|
|
99
|
+
# Send a list of PixPullSubscription objects for creation in the Stark Infra API
|
|
100
|
+
#
|
|
101
|
+
# ## Parameters (required):
|
|
102
|
+
# - subscriptions [list of PixPullSubscription objects]: list of PixPullSubscription objects to be created in the API
|
|
103
|
+
#
|
|
104
|
+
# ## Parameters (optional):
|
|
105
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
106
|
+
#
|
|
107
|
+
# ## Return:
|
|
108
|
+
# - list of PixPullSubscription objects with updated attributes
|
|
109
|
+
def self.create(subscriptions, user: nil)
|
|
110
|
+
StarkInfra::Utils::Rest.post(entities: subscriptions, user: user, **resource)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# # Retrieve a specific PixPullSubscription
|
|
114
|
+
#
|
|
115
|
+
# Receive a single PixPullSubscription object previously created in the Stark Infra API by passing its id
|
|
116
|
+
#
|
|
117
|
+
# ## Parameters (required):
|
|
118
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
|
119
|
+
#
|
|
120
|
+
# ## Parameters (optional):
|
|
121
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
122
|
+
#
|
|
123
|
+
# ## Return:
|
|
124
|
+
# - PixPullSubscription object with updated attributes
|
|
125
|
+
def self.get(id, user: nil)
|
|
126
|
+
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# # Retrieve PixPullSubscriptions
|
|
130
|
+
#
|
|
131
|
+
# Receive a generator of PixPullSubscription objects previously created in the Stark Infra API
|
|
132
|
+
#
|
|
133
|
+
# ## Parameters (optional):
|
|
134
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
|
135
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
136
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
137
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['active', 'canceled']
|
|
138
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['employees', 'monthly']
|
|
139
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
140
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
141
|
+
#
|
|
142
|
+
# ## Return:
|
|
143
|
+
# - generator of PixPullSubscription objects with updated attributes
|
|
144
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
|
145
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
146
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
147
|
+
StarkInfra::Utils::Rest.get_stream(
|
|
148
|
+
limit: limit,
|
|
149
|
+
after: after,
|
|
150
|
+
before: before,
|
|
151
|
+
status: status,
|
|
152
|
+
tags: tags,
|
|
153
|
+
ids: ids,
|
|
154
|
+
user: user,
|
|
155
|
+
**resource
|
|
156
|
+
)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# # Retrieve paged PixPullSubscriptions
|
|
160
|
+
#
|
|
161
|
+
# Receive a list of up to 100 PixPullSubscription objects previously created in the Stark Infra API and the cursor to the next page.
|
|
162
|
+
# Use this function instead of query if you want to manually page your subscriptions.
|
|
163
|
+
#
|
|
164
|
+
# ## Parameters (optional):
|
|
165
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
|
166
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
|
167
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
168
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
169
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['active', 'canceled']
|
|
170
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['employees', 'monthly']
|
|
171
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
172
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
173
|
+
#
|
|
174
|
+
# ## Return:
|
|
175
|
+
# - list of PixPullSubscription objects with updated attributes
|
|
176
|
+
# - cursor to retrieve the next page of PixPullSubscription objects
|
|
177
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
|
178
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
179
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
180
|
+
StarkInfra::Utils::Rest.get_page(
|
|
181
|
+
cursor: cursor,
|
|
182
|
+
limit: limit,
|
|
183
|
+
after: after,
|
|
184
|
+
before: before,
|
|
185
|
+
status: status,
|
|
186
|
+
tags: tags,
|
|
187
|
+
ids: ids,
|
|
188
|
+
user: user,
|
|
189
|
+
**resource
|
|
190
|
+
)
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# # Update PixPullSubscriptions
|
|
194
|
+
#
|
|
195
|
+
# A Pix Subscription can be patched for three distinct purposes - to update, confirm or deny it.
|
|
196
|
+
# As the receiver, you can approve or deny the subscription if the subscription type is 'subscriptionAndPayment'.
|
|
197
|
+
# As the sender, you can confirm or deny a delivered subscription.
|
|
198
|
+
#
|
|
199
|
+
# ## Parameters (required):
|
|
200
|
+
# - id [string]: PixPullSubscription unique id. ex: '5656565656565656'
|
|
201
|
+
# - patch_data [hash]: hash containing the attributes to be updated. ex: { status: 'approved', sender_city_code: '3550308' }
|
|
202
|
+
# ## Parameters (required):
|
|
203
|
+
# - status [string]: new status of the Pix Subscription.
|
|
204
|
+
# ## Parameters (conditionally-required):
|
|
205
|
+
# - sender_city_code [string]: IBGE code of the payer's city. Required if you are confirming the subscription.
|
|
206
|
+
# - reason [string]: reason why the Pix Subscription is being patched. Options: 'accountClosed', 'accountBlocked', 'invalidBranchCode', 'notRecognizedBySender', 'userRejected', 'notOffered'
|
|
207
|
+
#
|
|
208
|
+
# ## Parameters (optional):
|
|
209
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
210
|
+
#
|
|
211
|
+
# ## Return:
|
|
212
|
+
# - updated PixPullSubscription object
|
|
213
|
+
def self.update(id, patch_data: nil, user: nil)
|
|
214
|
+
patch_data ||= {}
|
|
215
|
+
StarkInfra::Utils::Rest.patch_id(id: id, user: user, **patch_data, **resource)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# # Cancel a PixPullSubscription entity
|
|
219
|
+
#
|
|
220
|
+
# Cancel a PixPullSubscription entity previously created in the Stark Infra API.
|
|
221
|
+
# The reason is sent as a query parameter, not in the request body.
|
|
222
|
+
#
|
|
223
|
+
# ## Parameters (required):
|
|
224
|
+
# - id [string]: PixPullSubscription unique id. ex: '5656565656565656'
|
|
225
|
+
# - reason [string]: reason for the cancellation. As receiver: 'accountClosed', 'receiverOrganizationClosed', 'receiverInternalError', 'fraud', 'receiverUserRequested'. As sender: 'accountClosed', 'senderDeceased', 'fraud', 'senderUserRequested'.
|
|
226
|
+
#
|
|
227
|
+
# ## Parameters (optional):
|
|
228
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
229
|
+
#
|
|
230
|
+
# ## Return:
|
|
231
|
+
# - canceled PixPullSubscription object
|
|
232
|
+
def self.cancel(id, reason:, user: nil)
|
|
233
|
+
response = StarkInfra::Utils::Rest.delete_raw(
|
|
234
|
+
path: "/pix-pull-subscription/#{id}",
|
|
235
|
+
query: { reason: reason },
|
|
236
|
+
user: user,
|
|
237
|
+
raiseException: true
|
|
238
|
+
)
|
|
239
|
+
maker = resource[:resource_maker]
|
|
240
|
+
StarkCore::Utils::API.from_api_json(maker, response.json['subscription'])
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
def self.resource
|
|
244
|
+
{
|
|
245
|
+
resource_name: 'PixPullSubscription',
|
|
246
|
+
resource_maker: proc { |json|
|
|
247
|
+
PixPullSubscription.new(
|
|
248
|
+
id: json['id'],
|
|
249
|
+
bacen_id: json['bacen_id'],
|
|
250
|
+
external_id: json['external_id'],
|
|
251
|
+
installment_start: json['installment_start'],
|
|
252
|
+
interval: json['interval'],
|
|
253
|
+
receiver_name: json['receiver_name'],
|
|
254
|
+
receiver_tax_id: json['receiver_tax_id'],
|
|
255
|
+
sender_account_number: json['sender_account_number'],
|
|
256
|
+
sender_bank_code: json['sender_bank_code'],
|
|
257
|
+
sender_branch_code: json['sender_branch_code'],
|
|
258
|
+
sender_tax_id: json['sender_tax_id'],
|
|
259
|
+
type: json['type'],
|
|
260
|
+
amount: json['amount'],
|
|
261
|
+
amount_min_limit: json['amount_min_limit'],
|
|
262
|
+
description: json['description'],
|
|
263
|
+
due: json['due'],
|
|
264
|
+
installment_end: json['installment_end'],
|
|
265
|
+
receiver_bank_code: json['receiver_bank_code'],
|
|
266
|
+
reference_code: json['reference_code'],
|
|
267
|
+
pull_retry_limit: json['pull_retry_limit'],
|
|
268
|
+
sender_city_code: json['sender_city_code'],
|
|
269
|
+
sender_final_name: json['sender_final_name'],
|
|
270
|
+
sender_final_tax_id: json['sender_final_tax_id'],
|
|
271
|
+
tags: json['tags'],
|
|
272
|
+
status: json['status'],
|
|
273
|
+
flow: json['flow'],
|
|
274
|
+
created: json['created'],
|
|
275
|
+
updated: json['updated']
|
|
276
|
+
)
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
end
|
|
@@ -42,6 +42,8 @@ module StarkInfra
|
|
|
42
42
|
# - initiator_tax_id [string, default nil]: Payment initiator's tax id (CPF/CNPJ). ex: '01234567890' or '20.018.183/0001-80'
|
|
43
43
|
# - tags [list of strings, default nil]: list of strings for reference when searching for PixRequests. ex: ['employees', 'monthly']
|
|
44
44
|
# - method [string, default nil]: execution method of creation of the Pix. ex: 'manual', 'payerQrcode', 'dynamicQrcode'.
|
|
45
|
+
# - priority priority [string, default 'high']: Specifies the message channel used to send the Pix Request. If set to 'high', the request is sent through the primary channel; if set to 'low', it uses the secondary channel. Options: 'high' or 'low'
|
|
46
|
+
# - reason [string, default 'customerRequest']: underlying reason for the payment transaction. ex: 'customerRequest', 'fraud', 'subscriptionFlaw'
|
|
45
47
|
#
|
|
46
48
|
# ## Attributes (return-only):
|
|
47
49
|
# - id [string]: unique id returned when the PixRequest is created. ex: '5656565656565656'
|
|
@@ -56,13 +58,14 @@ module StarkInfra
|
|
|
56
58
|
:sender_account_type, :receiver_name, :receiver_tax_id, :receiver_bank_code, :receiver_account_number,
|
|
57
59
|
:receiver_branch_code, :receiver_account_type, :end_to_end_id, :cashier_type,
|
|
58
60
|
:cashier_bank_code, :cash_amount, :receiver_key_id, :description, :reconciliation_id, :initiator_tax_id,
|
|
59
|
-
:tags, :method, :id, :fee, :status, :flow, :sender_bank_code, :created, :updated
|
|
61
|
+
:tags, :method, :priority, :reason, :id, :fee, :status, :flow, :sender_bank_code, :created, :updated
|
|
60
62
|
def initialize(
|
|
61
63
|
amount:, external_id:, sender_name:, sender_tax_id:, sender_branch_code:, sender_account_number:,
|
|
62
64
|
sender_account_type:, receiver_name:, receiver_tax_id:, receiver_bank_code:, receiver_account_number:,
|
|
63
65
|
receiver_branch_code:, receiver_account_type:, end_to_end_id:, cashier_type: nil, cashier_bank_code: nil,
|
|
64
66
|
cash_amount: nil, receiver_key_id: nil, description: nil, reconciliation_id: nil, initiator_tax_id: nil,
|
|
65
|
-
tags: nil, method: nil,
|
|
67
|
+
tags: nil, method: nil, priority: nil, reason: nil, id: nil, fee: nil, status:nil, flow: nil, sender_bank_code: nil,
|
|
68
|
+
created: nil, updated: nil
|
|
66
69
|
)
|
|
67
70
|
super(id)
|
|
68
71
|
@amount = amount
|
|
@@ -88,6 +91,8 @@ module StarkInfra
|
|
|
88
91
|
@initiator_tax_id = initiator_tax_id
|
|
89
92
|
@tags = tags
|
|
90
93
|
@method = method
|
|
94
|
+
@priority = priority
|
|
95
|
+
@reason = reason
|
|
91
96
|
@fee = fee
|
|
92
97
|
@status = status
|
|
93
98
|
@flow = flow
|
|
@@ -276,6 +281,8 @@ module StarkInfra
|
|
|
276
281
|
initiator_tax_id: json['initiator_tax_id'],
|
|
277
282
|
tags: json['tags'],
|
|
278
283
|
method: json['method'],
|
|
284
|
+
priority: json['priority'],
|
|
285
|
+
reason: json['reason'],
|
|
279
286
|
fee: json['fee'],
|
|
280
287
|
status: json['status'],
|
|
281
288
|
flow: json['flow'],
|
data/lib/starkinfra.rb
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative('brcode_preview/brcode_preview')
|
|
4
|
+
require_relative('business_attachment/business_attachment')
|
|
5
|
+
require_relative('business_attachment/log')
|
|
6
|
+
require_relative('business_identity/business_identity')
|
|
7
|
+
require_relative('business_identity/log')
|
|
8
|
+
require_relative('brcode_preview/subscription')
|
|
4
9
|
require_relative('card_method/card_method')
|
|
5
10
|
require_relative('credit_note/invoice/invoice')
|
|
6
11
|
require_relative('credit_note/invoice/description')
|
|
7
12
|
require_relative('credit_note/invoice/discount')
|
|
8
13
|
require_relative('credit_note/credit_note')
|
|
14
|
+
require_relative('credit_note/rule')
|
|
9
15
|
require_relative('credit_note/log')
|
|
10
16
|
require_relative('credit_note/transfer')
|
|
11
17
|
require_relative('credit_holmes/credit_holmes')
|
|
@@ -18,12 +24,15 @@ require_relative('individual_document/log')
|
|
|
18
24
|
require_relative('individual_identity/individual_identity')
|
|
19
25
|
require_relative('individual_identity/log')
|
|
20
26
|
require_relative('issuing_balance/issuing_balance')
|
|
27
|
+
require_relative('issuing_billing_invoice/issuing_billing_invoice')
|
|
28
|
+
require_relative('issuing_billing_transaction/issuing_billing_transaction')
|
|
21
29
|
require_relative('issuing_design/issuing_design')
|
|
22
30
|
require_relative('issuing_embossing_kit/issuing_embossing_kit')
|
|
23
31
|
require_relative('issuing_embossing_request/issuing_embossing_request')
|
|
24
32
|
require_relative('issuing_embossing_request/log')
|
|
25
33
|
require_relative('issuing_stock/issuing_stock')
|
|
26
34
|
require_relative('issuing_stock/log')
|
|
35
|
+
require_relative('issuing_stock_rule/issuing_stock_rule')
|
|
27
36
|
require_relative('issuing_restock/issuing_restock')
|
|
28
37
|
require_relative('issuing_restock/log')
|
|
29
38
|
require_relative('issuing_card/issuing_card')
|
|
@@ -36,6 +45,9 @@ require_relative('issuing_product/issuing_product')
|
|
|
36
45
|
require_relative('issuing_purchase/issuing_purchase')
|
|
37
46
|
require_relative('issuing_purchase/log')
|
|
38
47
|
require_relative('issuing_rule/issuing_rule')
|
|
48
|
+
require_relative('issuing_token/issuing_token')
|
|
49
|
+
require_relative('issuing_token_request/issuing_token_request')
|
|
50
|
+
require_relative('issuing_token_design/issuing_token_design')
|
|
39
51
|
require_relative('issuing_transaction/issuing_transaction')
|
|
40
52
|
require_relative('issuing_withdrawal/issuing_withdrawal')
|
|
41
53
|
require_relative('merchant_category/merchant_category')
|
|
@@ -46,11 +58,23 @@ require_relative('pix_chargeback/log')
|
|
|
46
58
|
require_relative('pix_claim/pix_claim')
|
|
47
59
|
require_relative('pix_claim/log')
|
|
48
60
|
require_relative('pix_director/pix_director')
|
|
61
|
+
require_relative('pix_dispute/pix_dispute')
|
|
62
|
+
require_relative('pix_dispute/transaction')
|
|
63
|
+
require_relative('pix_dispute/log')
|
|
49
64
|
require_relative('pix_domain/pix_domain')
|
|
65
|
+
require_relative('pix_key_holmes/pix_key_holmes')
|
|
66
|
+
require_relative('pix_fraud/pix_fraud')
|
|
67
|
+
require_relative('pix_fraud/log')
|
|
50
68
|
require_relative('pix_infraction/pix_infraction')
|
|
51
69
|
require_relative('pix_infraction/log')
|
|
70
|
+
require_relative('pix_internal_transaction_report/pix_internal_transaction_report')
|
|
71
|
+
require_relative('pix_internal_transaction_report/log')
|
|
52
72
|
require_relative('pix_key/pix_key')
|
|
53
73
|
require_relative('pix_key/log')
|
|
74
|
+
require_relative('pix_pull_request/pix_pull_request')
|
|
75
|
+
require_relative('pix_pull_request/log')
|
|
76
|
+
require_relative('pix_pull_subscription/pix_pull_subscription')
|
|
77
|
+
require_relative('pix_pull_subscription/log')
|
|
54
78
|
require_relative('pix_request/pix_request')
|
|
55
79
|
require_relative('pix_request/log')
|
|
56
80
|
require_relative('pix_reversal/pix_reversal')
|
|
@@ -61,12 +85,12 @@ require_relative('webhook/webhook')
|
|
|
61
85
|
require_relative('event/event')
|
|
62
86
|
require_relative('event/attempt')
|
|
63
87
|
require_relative('request/request')
|
|
88
|
+
require_relative('utils/return_id')
|
|
64
89
|
|
|
65
|
-
# SDK to facilitate Ruby integrations with Stark Infra
|
|
66
90
|
module StarkInfra
|
|
67
91
|
|
|
68
92
|
API_VERSION = 'v2'
|
|
69
|
-
SDK_VERSION = '0.
|
|
93
|
+
SDK_VERSION = '0.6.0'
|
|
70
94
|
HOST = "infra"
|
|
71
95
|
public_constant :API_VERSION, :SDK_VERSION, :HOST;
|
|
72
96
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StarkInfra
|
|
4
|
+
# # ReturnId object
|
|
5
|
+
#
|
|
6
|
+
# A ReturnId is a 32-character string that uniquely identifies a return Pix transaction
|
|
7
|
+
# at the BACEN (Banco Central do Brasil) level. It is composed of a "D" prefix,
|
|
8
|
+
# the sender bank's ISPB code (zero-padded to 8 digits), a datetime stamp (yyyyMMddHHmm),
|
|
9
|
+
# and 11 random alphanumeric characters.
|
|
10
|
+
#
|
|
11
|
+
# ## Parameters (required):
|
|
12
|
+
# - bank_code [string]: 8-digit ISPB code of the sending bank. ex: '20018183'
|
|
13
|
+
#
|
|
14
|
+
# ## Return:
|
|
15
|
+
# - ReturnId string. ex: 'D200181832022012014505GD19lzAbCdE'
|
|
16
|
+
class ReturnId
|
|
17
|
+
RANDOM_SOURCE = (('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a).freeze
|
|
18
|
+
|
|
19
|
+
def self.create(bank_code)
|
|
20
|
+
random_string = (0...11).map { RANDOM_SOURCE.sample }.join
|
|
21
|
+
"D#{bank_code}#{Time.now.strftime('%Y%m%d%H%M')}#{random_string}"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/lib/webhook/webhook.rb
CHANGED
|
@@ -7,11 +7,11 @@ module StarkInfra
|
|
|
7
7
|
# # Webhook object
|
|
8
8
|
#
|
|
9
9
|
# A Webhook is used to subscribe to notification events on a user-selected endpoint.
|
|
10
|
-
# Currently available services for subscription are contract, credit-note, signer, issuing-card, issuing-invoice, issuing-purchase, pix-request.in, pix-request.out, pix-reversal.in, pix-reversal.out, pix-claim, pix-key, pix-chargeback, pix-infraction.
|
|
10
|
+
# Currently available services for subscription are contract, credit-note, signer, issuing-card, issuing-invoice, issuing-purchase, pix-request.in, pix-request.out, pix-reversal.in, pix-reversal.out, pix-claim, pix-key, pix-chargeback, pix-infraction, pix-pull-request, pix-pull-subscription.
|
|
11
11
|
#
|
|
12
12
|
# ## Parameters (required):
|
|
13
13
|
# - url [string]: URL that will be notified when an event occurs.
|
|
14
|
-
# - subscriptions [list of strings]: list of any non-empty combination of the available services. ex: ['contract', 'credit-note', 'signer', 'issuing-card', 'issuing-invoice', 'issuing-purchase', 'pix-request.in', 'pix-request.out', 'pix-reversal.in', 'pix-reversal.out', 'pix-claim', 'pix-key', 'pix-chargeback', 'pix-infraction']
|
|
14
|
+
# - subscriptions [list of strings]: list of any non-empty combination of the available services. ex: ['contract', 'credit-note', 'signer', 'issuing-card', 'issuing-invoice', 'issuing-purchase', 'pix-request.in', 'pix-request.out', 'pix-reversal.in', 'pix-reversal.out', 'pix-claim', 'pix-key', 'pix-chargeback', 'pix-infraction', 'pix-pull-request', 'pix-pull-subscription']
|
|
15
15
|
#
|
|
16
16
|
# ## Attributes (return-only):
|
|
17
17
|
# - id [string]: unique id returned when the webhook is created. ex: '5656565656565656'
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: starkinfra
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- starkinfra
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: starkcore
|
|
@@ -66,13 +65,16 @@ dependencies:
|
|
|
66
65
|
- - "~>"
|
|
67
66
|
- !ruby/object:Gem::Version
|
|
68
67
|
version: '0.81'
|
|
69
|
-
description:
|
|
70
|
-
email:
|
|
71
68
|
executables: []
|
|
72
69
|
extensions: []
|
|
73
70
|
extra_rdoc_files: []
|
|
74
71
|
files:
|
|
75
72
|
- lib/brcode_preview/brcode_preview.rb
|
|
73
|
+
- lib/brcode_preview/subscription.rb
|
|
74
|
+
- lib/business_attachment/business_attachment.rb
|
|
75
|
+
- lib/business_attachment/log.rb
|
|
76
|
+
- lib/business_identity/business_identity.rb
|
|
77
|
+
- lib/business_identity/log.rb
|
|
76
78
|
- lib/card_method/card_method.rb
|
|
77
79
|
- lib/credit_holmes/credit_holmes.rb
|
|
78
80
|
- lib/credit_note/credit_note.rb
|
|
@@ -80,6 +82,7 @@ files:
|
|
|
80
82
|
- lib/credit_note/invoice/discount.rb
|
|
81
83
|
- lib/credit_note/invoice/invoice.rb
|
|
82
84
|
- lib/credit_note/log.rb
|
|
85
|
+
- lib/credit_note/rule.rb
|
|
83
86
|
- lib/credit_note/transfer.rb
|
|
84
87
|
- lib/credit_preview/credit_note_preview.rb
|
|
85
88
|
- lib/credit_preview/credit_preview.rb
|
|
@@ -93,6 +96,8 @@ files:
|
|
|
93
96
|
- lib/individual_identity/individual_identity.rb
|
|
94
97
|
- lib/individual_identity/log.rb
|
|
95
98
|
- lib/issuing_balance/issuing_balance.rb
|
|
99
|
+
- lib/issuing_billing_invoice/issuing_billing_invoice.rb
|
|
100
|
+
- lib/issuing_billing_transaction/issuing_billing_transaction.rb
|
|
96
101
|
- lib/issuing_card/issuing_card.rb
|
|
97
102
|
- lib/issuing_card/log.rb
|
|
98
103
|
- lib/issuing_design/issuing_design.rb
|
|
@@ -111,6 +116,10 @@ files:
|
|
|
111
116
|
- lib/issuing_rule/issuing_rule.rb
|
|
112
117
|
- lib/issuing_stock/issuing_stock.rb
|
|
113
118
|
- lib/issuing_stock/log.rb
|
|
119
|
+
- lib/issuing_stock_rule/issuing_stock_rule.rb
|
|
120
|
+
- lib/issuing_token/issuing_token.rb
|
|
121
|
+
- lib/issuing_token_design/issuing_token_design.rb
|
|
122
|
+
- lib/issuing_token_request/issuing_token_request.rb
|
|
114
123
|
- lib/issuing_transaction/issuing_transaction.rb
|
|
115
124
|
- lib/issuing_withdrawal/issuing_withdrawal.rb
|
|
116
125
|
- lib/merchant_category/merchant_category.rb
|
|
@@ -121,12 +130,24 @@ files:
|
|
|
121
130
|
- lib/pix_claim/log.rb
|
|
122
131
|
- lib/pix_claim/pix_claim.rb
|
|
123
132
|
- lib/pix_director/pix_director.rb
|
|
133
|
+
- lib/pix_dispute/log.rb
|
|
134
|
+
- lib/pix_dispute/pix_dispute.rb
|
|
135
|
+
- lib/pix_dispute/transaction.rb
|
|
124
136
|
- lib/pix_domain/certificate.rb
|
|
125
137
|
- lib/pix_domain/pix_domain.rb
|
|
138
|
+
- lib/pix_fraud/log.rb
|
|
139
|
+
- lib/pix_fraud/pix_fraud.rb
|
|
126
140
|
- lib/pix_infraction/log.rb
|
|
127
141
|
- lib/pix_infraction/pix_infraction.rb
|
|
142
|
+
- lib/pix_internal_transaction_report/log.rb
|
|
143
|
+
- lib/pix_internal_transaction_report/pix_internal_transaction_report.rb
|
|
128
144
|
- lib/pix_key/log.rb
|
|
129
145
|
- lib/pix_key/pix_key.rb
|
|
146
|
+
- lib/pix_key_holmes/pix_key_holmes.rb
|
|
147
|
+
- lib/pix_pull_request/log.rb
|
|
148
|
+
- lib/pix_pull_request/pix_pull_request.rb
|
|
149
|
+
- lib/pix_pull_subscription/log.rb
|
|
150
|
+
- lib/pix_pull_subscription/pix_pull_subscription.rb
|
|
130
151
|
- lib/pix_request/log.rb
|
|
131
152
|
- lib/pix_request/pix_request.rb
|
|
132
153
|
- lib/pix_reversal/log.rb
|
|
@@ -137,12 +158,12 @@ files:
|
|
|
137
158
|
- lib/static_brcode/static_brcode.rb
|
|
138
159
|
- lib/utils/parse.rb
|
|
139
160
|
- lib/utils/rest.rb
|
|
161
|
+
- lib/utils/return_id.rb
|
|
140
162
|
- lib/webhook/webhook.rb
|
|
141
163
|
homepage: https://github.com/starkinfra/sdk-ruby
|
|
142
164
|
licenses:
|
|
143
165
|
- MIT
|
|
144
166
|
metadata: {}
|
|
145
|
-
post_install_message:
|
|
146
167
|
rdoc_options: []
|
|
147
168
|
require_paths:
|
|
148
169
|
- lib
|
|
@@ -150,15 +171,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
150
171
|
requirements:
|
|
151
172
|
- - ">="
|
|
152
173
|
- !ruby/object:Gem::Version
|
|
153
|
-
version: '
|
|
174
|
+
version: '3.0'
|
|
154
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
176
|
requirements:
|
|
156
177
|
- - ">="
|
|
157
178
|
- !ruby/object:Gem::Version
|
|
158
179
|
version: '0'
|
|
159
180
|
requirements: []
|
|
160
|
-
rubygems_version:
|
|
161
|
-
signing_key:
|
|
181
|
+
rubygems_version: 4.0.16
|
|
162
182
|
specification_version: 4
|
|
163
183
|
summary: SDK to facilitate Ruby integrations with Stark Infra
|
|
164
184
|
test_files: []
|