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.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/lib/{brcodepreview/brcodepreview.rb → brcode_preview/brcode_preview.rb} +5 -2
  3. data/lib/brcode_preview/subscription.rb +102 -0
  4. data/lib/business_attachment/business_attachment.rb +186 -0
  5. data/lib/business_attachment/log.rb +127 -0
  6. data/lib/business_identity/business_identity.rb +225 -0
  7. data/lib/business_identity/log.rb +127 -0
  8. data/lib/{creditnote/creditnote.rb → credit_note/credit_note.rb} +11 -5
  9. data/lib/{creditnote → credit_note}/log.rb +1 -1
  10. data/lib/credit_note/rule.rb +46 -0
  11. data/lib/event/event.rb +10 -2
  12. data/lib/{individualdocument → individual_document}/log.rb +1 -1
  13. data/lib/{individualidentity → individual_identity}/log.rb +1 -1
  14. data/lib/{issuingbalance/issuingbalance.rb → issuing_balance/issuing_balance.rb} +8 -2
  15. data/lib/issuing_billing_invoice/issuing_billing_invoice.rb +155 -0
  16. data/lib/issuing_billing_transaction/issuing_billing_transaction.rb +142 -0
  17. data/lib/{issuingcard/issuingcard.rb → issuing_card/issuing_card.rb} +5 -2
  18. data/lib/{issuingcard → issuing_card}/log.rb +1 -1
  19. data/lib/{issuingembossingrequest → issuing_embossing_request}/log.rb +1 -1
  20. data/lib/{issuingholder → issuing_holder}/log.rb +1 -1
  21. data/lib/{issuinginvoice → issuing_invoice}/log.rb +1 -1
  22. data/lib/{issuingproduct/issuingproduct.rb → issuing_product/issuing_product.rb} +5 -2
  23. data/lib/{issuingpurchase/issuingpurchase.rb → issuing_purchase/issuing_purchase.rb} +18 -9
  24. data/lib/{issuingpurchase → issuing_purchase}/log.rb +1 -1
  25. data/lib/{issuingrestock → issuing_restock}/log.rb +1 -1
  26. data/lib/{issuingrule/issuingrule.rb → issuing_rule/issuing_rule.rb} +9 -3
  27. data/lib/{issuingstock/issuingstock.rb → issuing_stock/issuing_stock.rb} +5 -2
  28. data/lib/{issuingstock → issuing_stock}/log.rb +1 -1
  29. data/lib/issuing_stock_rule/issuing_stock_rule.rb +213 -0
  30. data/lib/issuing_token/issuing_token.rb +309 -0
  31. data/lib/issuing_token_design/issuing_token_design.rb +118 -0
  32. data/lib/issuing_token_request/issuing_token_request.rb +63 -0
  33. data/lib/{merchantcategory/merchantcategory.rb → merchant_category/merchant_category.rb} +6 -3
  34. data/lib/{pixchargeback → pix_chargeback}/log.rb +1 -1
  35. data/lib/{pixchargeback/pixchargeback.rb → pix_chargeback/pix_chargeback.rb} +26 -2
  36. data/lib/{pixclaim → pix_claim}/log.rb +1 -1
  37. data/lib/pix_dispute/log.rb +127 -0
  38. data/lib/pix_dispute/pix_dispute.rb +210 -0
  39. data/lib/pix_dispute/transaction.rb +91 -0
  40. data/lib/pix_fraud/log.rb +128 -0
  41. data/lib/pix_fraud/pix_fraud.rb +180 -0
  42. data/lib/{pixinfraction → pix_infraction}/log.rb +1 -1
  43. data/lib/{pixinfraction/pixinfraction.rb → pix_infraction/pix_infraction.rb} +18 -4
  44. data/lib/pix_internal_transaction_report/log.rb +129 -0
  45. data/lib/pix_internal_transaction_report/pix_internal_transaction_report.rb +200 -0
  46. data/lib/{pixkey → pix_key}/log.rb +1 -1
  47. data/lib/pix_key_holmes/pix_key_holmes.rb +139 -0
  48. data/lib/pix_pull_request/log.rb +127 -0
  49. data/lib/pix_pull_request/pix_pull_request.rb +265 -0
  50. data/lib/pix_pull_subscription/log.rb +127 -0
  51. data/lib/pix_pull_subscription/pix_pull_subscription.rb +281 -0
  52. data/lib/{pixrequest → pix_request}/log.rb +1 -1
  53. data/lib/{pixrequest/pixrequest.rb → pix_request/pix_request.rb} +9 -2
  54. data/lib/{pixreversal → pix_reversal}/log.rb +1 -1
  55. data/lib/starkinfra.rb +83 -59
  56. data/lib/utils/parse.rb +2 -2
  57. data/lib/utils/return_id.rb +24 -0
  58. data/lib/webhook/webhook.rb +2 -2
  59. metadata +87 -67
  60. /data/lib/{cardmethod/cardmethod.rb → card_method/card_method.rb} +0 -0
  61. /data/lib/{creditholmes/creditholmes.rb → credit_holmes/credit_holmes.rb} +0 -0
  62. /data/lib/{creditnote → credit_note}/invoice/description.rb +0 -0
  63. /data/lib/{creditnote → credit_note}/invoice/discount.rb +0 -0
  64. /data/lib/{creditnote → credit_note}/invoice/invoice.rb +0 -0
  65. /data/lib/{creditnote → credit_note}/transfer.rb +0 -0
  66. /data/lib/{creditpreview/creditnotepreview.rb → credit_preview/credit_note_preview.rb} +0 -0
  67. /data/lib/{creditpreview/creditpreview.rb → credit_preview/credit_preview.rb} +0 -0
  68. /data/lib/{creditsigner/creditsigner.rb → credit_signer/credit_signer.rb} +0 -0
  69. /data/lib/{dynamicbrcode/dynamicbrcode.rb → dynamic_brcode/dynamic_brcode.rb} +0 -0
  70. /data/lib/{individualdocument/individualdocument.rb → individual_document/individual_document.rb} +0 -0
  71. /data/lib/{individualidentity/individualidentity.rb → individual_identity/individual_identity.rb} +0 -0
  72. /data/lib/{issuingdesign/issuingdesign.rb → issuing_design/issuing_design.rb} +0 -0
  73. /data/lib/{issuingembossingkit/issuingembossingkit.rb → issuing_embossing_kit/issuing_embossing_kit.rb} +0 -0
  74. /data/lib/{issuingembossingrequest/issuingembossingrequest.rb → issuing_embossing_request/issuing_embossing_request.rb} +0 -0
  75. /data/lib/{issuingholder/issuingholder.rb → issuing_holder/issuing_holder.rb} +0 -0
  76. /data/lib/{issuinginvoice/issuinginvoice.rb → issuing_invoice/issuing_invoice.rb} +0 -0
  77. /data/lib/{issuingrestock/issuingrestock.rb → issuing_restock/issuing_restock.rb} +0 -0
  78. /data/lib/{issuingtransaction/issuingtransaction.rb → issuing_transaction/issuing_transaction.rb} +0 -0
  79. /data/lib/{issuingwithdrawal/issuingwithdrawal.rb → issuing_withdrawal/issuing_withdrawal.rb} +0 -0
  80. /data/lib/{merchantcountry/merchantcountry.rb → merchant_country/merchant_country.rb} +0 -0
  81. /data/lib/{pixbalance/pixbalance.rb → pix_balance/pix_balance.rb} +0 -0
  82. /data/lib/{pixclaim/pixclaim.rb → pix_claim/pix_claim.rb} +0 -0
  83. /data/lib/{pixdirector/pixdirector.rb → pix_director/pix_director.rb} +0 -0
  84. /data/lib/{pixdomain → pix_domain}/certificate.rb +0 -0
  85. /data/lib/{pixdomain/pixdomain.rb → pix_domain/pix_domain.rb} +0 -0
  86. /data/lib/{pixkey/pixkey.rb → pix_key/pix_key.rb} +0 -0
  87. /data/lib/{pixreversal/pixreversal.rb → pix_reversal/pix_reversal.rb} +0 -0
  88. /data/lib/{pixstatement/pixstatement.rb → pix_statement/pix_statement.rb} +0 -0
  89. /data/lib/{staticbrcode/staticbrcode.rb → static_brcode/static_brcode.rb} +0 -0
@@ -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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require('starkcore')
4
- require_relative('pixrequest')
4
+ require_relative('pix_request')
5
5
  require_relative('../utils/rest')
6
6
 
7
7
  module StarkInfra
@@ -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, id: nil, fee: nil, status:nil, flow: nil, sender_bank_code: nil, created: nil, updated: 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'],
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('pixreversal')
3
+ require_relative('pix_reversal')
4
4
  require_relative('../utils/rest')
5
5
 
6
6
  module StarkInfra
data/lib/starkinfra.rb CHANGED
@@ -1,72 +1,96 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('brcodepreview/brcodepreview')
4
- require_relative('cardmethod/cardmethod')
5
- require_relative('creditnote/invoice/invoice')
6
- require_relative('creditnote/invoice/description')
7
- require_relative('creditnote/invoice/discount')
8
- require_relative('creditnote/creditnote')
9
- require_relative('creditnote/log')
10
- require_relative('creditnote/transfer')
11
- require_relative('creditholmes/creditholmes')
12
- require_relative('creditpreview/creditpreview')
13
- require_relative('creditpreview/creditnotepreview')
14
- require_relative('creditsigner/creditsigner')
15
- require_relative('dynamicbrcode/dynamicbrcode')
16
- require_relative('individualdocument/individualdocument')
17
- require_relative('individualdocument/log')
18
- require_relative('individualidentity/individualidentity')
19
- require_relative('individualidentity/log')
20
- require_relative('issuingbalance/issuingbalance')
21
- require_relative('issuingdesign/issuingdesign')
22
- require_relative('issuingembossingkit/issuingembossingkit')
23
- require_relative('issuingembossingrequest/issuingembossingrequest')
24
- require_relative('issuingembossingrequest/log')
25
- require_relative('issuingstock/issuingstock')
26
- require_relative('issuingstock/log')
27
- require_relative('issuingrestock/issuingrestock')
28
- require_relative('issuingrestock/log')
29
- require_relative('issuingcard/issuingcard')
30
- require_relative('issuingcard/log')
31
- require_relative('issuingholder/issuingholder')
32
- require_relative('issuingholder/log')
33
- require_relative('issuinginvoice/issuinginvoice')
34
- require_relative('issuinginvoice/log')
35
- require_relative('issuingproduct/issuingproduct')
36
- require_relative('issuingpurchase/issuingpurchase')
37
- require_relative('issuingpurchase/log')
38
- require_relative('issuingrule/issuingrule')
39
- require_relative('issuingtransaction/issuingtransaction')
40
- require_relative('issuingwithdrawal/issuingwithdrawal')
41
- require_relative('merchantcategory/merchantcategory')
42
- require_relative('merchantcountry/merchantcountry')
43
- require_relative('pixbalance/pixbalance')
44
- require_relative('pixchargeback/pixchargeback')
45
- require_relative('pixchargeback/log')
46
- require_relative('pixclaim/pixclaim')
47
- require_relative('pixclaim/log')
48
- require_relative('pixdirector/pixdirector')
49
- require_relative('pixdomain/pixdomain')
50
- require_relative('pixinfraction/pixinfraction')
51
- require_relative('pixinfraction/log')
52
- require_relative('pixkey/pixkey')
53
- require_relative('pixkey/log')
54
- require_relative('pixrequest/pixrequest')
55
- require_relative('pixrequest/log')
56
- require_relative('pixreversal/pixreversal')
57
- require_relative('pixreversal/log')
58
- require_relative('pixstatement/pixstatement')
59
- require_relative('staticbrcode/staticbrcode')
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')
9
+ require_relative('card_method/card_method')
10
+ require_relative('credit_note/invoice/invoice')
11
+ require_relative('credit_note/invoice/description')
12
+ require_relative('credit_note/invoice/discount')
13
+ require_relative('credit_note/credit_note')
14
+ require_relative('credit_note/rule')
15
+ require_relative('credit_note/log')
16
+ require_relative('credit_note/transfer')
17
+ require_relative('credit_holmes/credit_holmes')
18
+ require_relative('credit_preview/credit_preview')
19
+ require_relative('credit_preview/credit_note_preview')
20
+ require_relative('credit_signer/credit_signer')
21
+ require_relative('dynamic_brcode/dynamic_brcode')
22
+ require_relative('individual_document/individual_document')
23
+ require_relative('individual_document/log')
24
+ require_relative('individual_identity/individual_identity')
25
+ require_relative('individual_identity/log')
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')
29
+ require_relative('issuing_design/issuing_design')
30
+ require_relative('issuing_embossing_kit/issuing_embossing_kit')
31
+ require_relative('issuing_embossing_request/issuing_embossing_request')
32
+ require_relative('issuing_embossing_request/log')
33
+ require_relative('issuing_stock/issuing_stock')
34
+ require_relative('issuing_stock/log')
35
+ require_relative('issuing_stock_rule/issuing_stock_rule')
36
+ require_relative('issuing_restock/issuing_restock')
37
+ require_relative('issuing_restock/log')
38
+ require_relative('issuing_card/issuing_card')
39
+ require_relative('issuing_card/log')
40
+ require_relative('issuing_holder/issuing_holder')
41
+ require_relative('issuing_holder/log')
42
+ require_relative('issuing_invoice/issuing_invoice')
43
+ require_relative('issuing_invoice/log')
44
+ require_relative('issuing_product/issuing_product')
45
+ require_relative('issuing_purchase/issuing_purchase')
46
+ require_relative('issuing_purchase/log')
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')
51
+ require_relative('issuing_transaction/issuing_transaction')
52
+ require_relative('issuing_withdrawal/issuing_withdrawal')
53
+ require_relative('merchant_category/merchant_category')
54
+ require_relative('merchant_country/merchant_country')
55
+ require_relative('pix_balance/pix_balance')
56
+ require_relative('pix_chargeback/pix_chargeback')
57
+ require_relative('pix_chargeback/log')
58
+ require_relative('pix_claim/pix_claim')
59
+ require_relative('pix_claim/log')
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')
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')
68
+ require_relative('pix_infraction/pix_infraction')
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')
72
+ require_relative('pix_key/pix_key')
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')
78
+ require_relative('pix_request/pix_request')
79
+ require_relative('pix_request/log')
80
+ require_relative('pix_reversal/pix_reversal')
81
+ require_relative('pix_reversal/log')
82
+ require_relative('pix_statement/pix_statement')
83
+ require_relative('static_brcode/static_brcode')
60
84
  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.5.0'
93
+ SDK_VERSION = '0.6.0'
70
94
  HOST = "infra"
71
95
  public_constant :API_VERSION, :SDK_VERSION, :HOST;
72
96
 
data/lib/utils/parse.rb CHANGED
@@ -13,7 +13,7 @@ module StarkInfra
13
13
  resource: resource,
14
14
  user: user ? user : StarkInfra.user,
15
15
  language: StarkInfra.language,
16
- timeout: StarkInfra.language,
16
+ timeout: StarkInfra.timeout,
17
17
  key: key
18
18
  )
19
19
  end
@@ -27,7 +27,7 @@ module StarkInfra
27
27
  host: StarkInfra::HOST,
28
28
  user: user ? user : StarkInfra.user,
29
29
  language: StarkInfra.language,
30
- timeout: StarkInfra.language
30
+ timeout: StarkInfra.timeout
31
31
  )
32
32
  end
33
33
  end
@@ -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
@@ -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'