starkinfra 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcode_preview/brcode_preview.rb +22 -4
  3. data/lib/brcode_preview/subscription.rb +2 -2
  4. data/lib/business_account_request/business_account_request.rb +276 -0
  5. data/lib/{individual_document → business_account_request}/log.rb +35 -35
  6. data/lib/business_attachment/business_attachment.rb +6 -3
  7. data/lib/business_identity/business_identity.rb +7 -4
  8. data/lib/credit_holmes/credit_holmes.rb +2 -1
  9. data/lib/credit_holmes/log.rb +125 -0
  10. data/lib/credit_note/credit_note.rb +42 -5
  11. data/lib/credit_note/rule.rb +9 -0
  12. data/lib/credit_note/transfer.rb +1 -1
  13. data/lib/credit_preview/credit_note_preview.rb +10 -2
  14. data/lib/credit_preview/credit_preview.rb +2 -1
  15. data/lib/credit_signer/credit_signer.rb +27 -2
  16. data/lib/dynamic_brcode/dynamic_brcode.rb +5 -2
  17. data/lib/event/event.rb +2 -2
  18. data/lib/individual_account_attachment/individual_account_attachment.rb +178 -0
  19. data/lib/individual_account_attachment/log.rb +124 -0
  20. data/lib/individual_account_request/individual_account_request.rb +271 -0
  21. data/lib/individual_account_request/log.rb +124 -0
  22. data/lib/individual_identity/individual_identity.rb +4 -7
  23. data/lib/issuing_card/issuing_card.rb +5 -4
  24. data/lib/issuing_design/issuing_design.rb +9 -0
  25. data/lib/issuing_embossing_request/issuing_embossing_request.rb +3 -2
  26. data/lib/issuing_holder/issuing_holder.rb +6 -5
  27. data/lib/issuing_product/issuing_product.rb +2 -2
  28. data/lib/issuing_purchase/issuing_purchase.rb +25 -1
  29. data/lib/issuing_restock/issuing_restock.rb +3 -2
  30. data/lib/issuing_rule/issuing_rule.rb +36 -0
  31. data/lib/issuing_stock_rule/issuing_stock_rule.rb +6 -5
  32. data/lib/issuing_token/issuing_token.rb +2 -2
  33. data/lib/issuing_token/log.rb +127 -0
  34. data/lib/issuing_token_activation/issuing_token_activation.rb +62 -0
  35. data/lib/issuing_token_request/issuing_token_request.rb +1 -1
  36. data/lib/issuing_withdrawal/issuing_withdrawal.rb +2 -2
  37. data/lib/ledger/ledger.rb +175 -0
  38. data/lib/ledger/log.rb +122 -0
  39. data/lib/ledger/rule.rb +55 -0
  40. data/lib/ledger_transaction/ledger_transaction.rb +179 -0
  41. data/lib/pix_balance/pix_balance.rb +1 -1
  42. data/lib/pix_chargeback/pix_chargeback.rb +10 -7
  43. data/lib/pix_claim/pix_claim.rb +14 -6
  44. data/lib/pix_director/pix_director.rb +1 -1
  45. data/lib/pix_dispute/pix_dispute.rb +1 -1
  46. data/lib/pix_dispute/transaction.rb +4 -4
  47. data/lib/pix_fraud/pix_fraud.rb +1 -1
  48. data/lib/pix_infraction/pix_infraction.rb +21 -5
  49. data/lib/pix_internal_transaction_report/pix_internal_transaction_report.rb +1 -1
  50. data/lib/pix_key/pix_key.rb +1 -1
  51. data/lib/pix_key_holmes/log.rb +129 -0
  52. data/lib/pix_key_holmes/pix_key_holmes.rb +19 -2
  53. data/lib/pix_pull_request/pix_pull_request.rb +6 -3
  54. data/lib/pix_pull_subscription/pix_pull_subscription.rb +31 -5
  55. data/lib/pix_request/pix_request.rb +13 -7
  56. data/lib/pix_reversal/pix_reversal.rb +14 -8
  57. data/lib/pix_statement/pix_statement.rb +11 -5
  58. data/lib/pix_user/pix_user.rb +52 -0
  59. data/lib/pix_user/statistics.rb +64 -0
  60. data/lib/starkinfra.rb +20 -3
  61. data/lib/static_brcode/static_brcode.rb +8 -4
  62. data/lib/utils/bacen_id.rb +27 -0
  63. data/lib/utils/end_to_end_id.rb +20 -0
  64. data/lib/utils/pix_subscription_bacen_id.rb +21 -0
  65. data/lib/utils/return_id.rb +1 -4
  66. data/lib/webhook/webhook.rb +2 -2
  67. metadata +21 -4
  68. data/lib/individual_document/individual_document.rb +0 -164
data/lib/ledger/log.rb ADDED
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+ require_relative('ledger')
6
+
7
+ module StarkInfra
8
+ class Ledger
9
+ # # Ledger::Log object
10
+ #
11
+ # Every time a Ledger entity is updated, a corresponding Ledger::Log
12
+ # is generated for the entity. This log is never generated by the
13
+ # user, but it can be retrieved to check additional information
14
+ # on the Ledger.
15
+ #
16
+ # ## Attributes (return-only):
17
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
18
+ # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
19
+ # - type [string]: type of the Ledger event which triggered the log creation. ex: 'created', 'updated'
20
+ # - ledger [Ledger]: Ledger entity to which the log refers to.
21
+ class Log < StarkCore::Utils::Resource
22
+ attr_reader :id, :created, :type, :ledger
23
+ def initialize(id:, created:, type:, ledger:)
24
+ super(id)
25
+ @type = type
26
+ @ledger = ledger
27
+ @created = StarkCore::Utils::Checks.check_datetime(created)
28
+ end
29
+
30
+ # # Retrieve a specific Ledger::Log
31
+ #
32
+ # Receive a single Ledger::Log object previously created by the Stark Infra API by 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
+ # - Ledger::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 Ledger::Logs
47
+ #
48
+ # Receive a generator of Ledger::Log objects previously created in the Stark Infra API
49
+ #
50
+ # ## Parameters (optional):
51
+ # - ids [list of strings, default nil]: list of LedgerLog ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
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
+ # - ledger_id [string, default nil]: filter logs by Ledger id. ex: '5656565656565656'
56
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
57
+ #
58
+ # ## Return:
59
+ # - generator of Ledger::Log objects with updated attributes
60
+ def self.query(ids: nil, limit: nil, after: nil, before: nil, ledger_id: nil, user: nil)
61
+ after = StarkCore::Utils::Checks.check_date(after)
62
+ before = StarkCore::Utils::Checks.check_date(before)
63
+ StarkInfra::Utils::Rest.get_stream(
64
+ ids: ids,
65
+ limit: limit,
66
+ after: after,
67
+ before: before,
68
+ ledger_id: ledger_id,
69
+ user: user,
70
+ **resource
71
+ )
72
+ end
73
+
74
+ # # Retrieve paged Ledger::Logs
75
+ #
76
+ # Receive a list of up to 100 Ledger::Log objects previously created in the Stark Infra API and the cursor to the next page.
77
+ # Use this function instead of query if you want to manually page your requests.
78
+ #
79
+ # ## Parameters (optional):
80
+ # - ids [list of strings, default nil]: list of LedgerLog ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
81
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
82
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
83
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
84
+ # - ledger_id [string, default nil]: filter logs by Ledger id. ex: '5656565656565656'
85
+ # - cursor [string, default nil]: cursor returned on the previous page function call
86
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
87
+ #
88
+ # ## Return:
89
+ # - list of Ledger::Log objects with updated attributes
90
+ # - cursor to retrieve the next page of Ledger::Log objects
91
+ def self.page(ids: nil, limit: nil, after: nil, before: nil, ledger_id: nil, cursor: nil, user: nil)
92
+ after = StarkCore::Utils::Checks.check_date(after)
93
+ before = StarkCore::Utils::Checks.check_date(before)
94
+ StarkInfra::Utils::Rest.get_page(
95
+ cursor: cursor,
96
+ ids: ids,
97
+ limit: limit,
98
+ after: after,
99
+ before: before,
100
+ ledger_id: ledger_id,
101
+ user: user,
102
+ **resource
103
+ )
104
+ end
105
+
106
+ def self.resource
107
+ request_maker = StarkInfra::Ledger.resource[:resource_maker]
108
+ {
109
+ resource_name: 'LedgerLog',
110
+ resource_maker: proc { |json|
111
+ Log.new(
112
+ id: json['id'],
113
+ created: json['created'],
114
+ type: json['type'],
115
+ ledger: StarkCore::Utils::API.from_api_json(request_maker, json['ledger'])
116
+ )
117
+ }
118
+ }
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,55 @@
1
+ require_relative('../utils/rest')
2
+
3
+ module StarkInfra
4
+ class Ledger
5
+ # # Ledger::Rule object
6
+ #
7
+ # The Ledger::Rule object modifies the behavior of Ledger objects when passed as an argument upon their creation or update.
8
+ #
9
+ # ## Parameters (required):
10
+ # - key [string]: Rule to be customized, describes what Ledger behavior will be altered. ex: 'minimumBalance', 'maximumBalance'
11
+ # - value [integer]: Value of the rule. ex: 1000
12
+ class Rule < StarkCore::Utils::SubResource
13
+ attr_reader :key, :value
14
+ def initialize(key:, value:)
15
+ @key = key
16
+ @value = value
17
+ end
18
+
19
+ # # Parse Ledger::Rules
20
+ #
21
+ # Converts a list of hashes (or Rule objects) received from the API into a list of Ledger::Rule objects.
22
+ #
23
+ # ## Parameters (required):
24
+ # - rules [list of hashes or Ledger::Rule objects]: list to be parsed.
25
+ #
26
+ # ## Return:
27
+ # - list of parsed Ledger::Rule objects
28
+ def self.parse_rules(rules)
29
+ resource_maker = StarkInfra::Ledger::Rule.resource[:resource_maker]
30
+ return rules if rules.nil?
31
+
32
+ parsed_rules = []
33
+ rules.each do |rule|
34
+ unless rule.is_a? Rule
35
+ rule = StarkCore::Utils::API.from_api_json(resource_maker, rule)
36
+ end
37
+ parsed_rules << rule
38
+ end
39
+ return parsed_rules
40
+ end
41
+
42
+ def self.resource
43
+ {
44
+ resource_name: 'Rule',
45
+ resource_maker: proc { |json|
46
+ Rule.new(
47
+ key: json['key'],
48
+ value: json['value']
49
+ )
50
+ }
51
+ }
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,179 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+ require_relative('../ledger/rule')
6
+
7
+ module StarkInfra
8
+ # # LedgerTransaction object
9
+ #
10
+ # LedgerTransactions are used to track the balance of a given amount by inserting LedgerTransactions to them.
11
+ # They can represent a bank account, a digital wallet, an inventory product, etc.
12
+ #
13
+ # ## Parameters (required):
14
+ # - amount [integer]: amount of the transaction. ex: 11234
15
+ # - ledger_id [string]: id of the Ledger containing the transaction. ex: '5656565656565656'
16
+ # - external_id [string]: string that must be unique among all your LedgerTransactions in a single Ledger. ex: 'my-internal-id-123456'
17
+ # - source [string]: source of the LedgerTransaction. ex: 'bank-transfer/123'
18
+ #
19
+ # ## Parameters (optional):
20
+ # - fee [integer]: fee applied to the LedgerTransaction. ex: 100
21
+ # - rules [list of Ledger::Rule objects, default []]: list of Rule objects linked to the LedgerTransaction. Rules are used to overwrite the Ledger's rules for this transaction. ex: [Ledger::Rule.new(key: 'minimumBalance', value: 0)]
22
+ # - metadata [dictionary, default {}]: dictionary object used to store additional information about the LedgerTransaction object. ex: { 'orderId': '123', 'orderType': 'purchase' }
23
+ # - tags [list of strings, default []]: list of strings for reference when searching for LedgerTransactions. ex: ['transfer/123', 'savings']
24
+ # - created [DateTime or string, default nil]: datetime to backdate the transaction, used to import existing transaction history. Cannot be in the future; when creating multiple transactions in one request, their created values must be in chronological order. Defaults to the current datetime when omitted.
25
+ #
26
+ # ## Attributes (return-only):
27
+ # - id [string]: unique id returned when the LedgerTransaction is created. ex: '5656565656565656'
28
+ # - balance [integer]: Ledger's balance after the transaction. ex: 11234
29
+ class LedgerTransaction < StarkCore::Utils::Resource
30
+ attr_reader :amount, :ledger_id, :external_id, :source, :id, :balance, :fee, :rules, :metadata, :tags, :created
31
+ def initialize(
32
+ amount:, ledger_id:, external_id:, source:, id: nil, balance: nil, fee: nil, rules: nil,
33
+ metadata: nil, tags: nil, created: nil
34
+ )
35
+ super(id)
36
+ @amount = amount
37
+ @ledger_id = ledger_id
38
+ @external_id = external_id
39
+ @source = source
40
+ @balance = balance
41
+ @fee = fee
42
+ @rules = StarkInfra::Ledger::Rule.parse_rules(rules)
43
+ @metadata = metadata
44
+ @tags = tags
45
+ @created = StarkCore::Utils::Checks.check_datetime(created)
46
+ end
47
+
48
+ # # Create LedgerTransactions
49
+ #
50
+ # Send a list of LedgerTransaction objects for creation at the Stark Infra API
51
+ #
52
+ # ## Parameters (required):
53
+ # - transactions [list of LedgerTransaction objects]: list of LedgerTransaction objects to be created in the Stark Infra API. You can send up to 500 objects in a single request, targeting different ledgers if needed; each is applied to its Ledger in the order sent, and the resulting balance is returned for each one.
54
+ #
55
+ # ## Parameters (optional):
56
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
57
+ #
58
+ # ## Return:
59
+ # - list of LedgerTransaction objects with updated attributes
60
+ def self.create(transactions, user: nil)
61
+ StarkInfra::Utils::Rest.post(entities: transactions, user: user, **resource)
62
+ end
63
+
64
+ # # Retrieve a specific LedgerTransaction
65
+ #
66
+ # Receive a single LedgerTransaction object previously created in the Stark Infra API by its id
67
+ #
68
+ # ## Parameters (required):
69
+ # - id [string]: object unique id. ex: '5656565656565656'
70
+ #
71
+ # ## Parameters (optional):
72
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
73
+ #
74
+ # ## Return:
75
+ # - LedgerTransaction object with updated attributes
76
+ def self.get(id, user: nil)
77
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
78
+ end
79
+
80
+ # # Retrieve LedgerTransactions
81
+ #
82
+ # Receive a generator of LedgerTransaction objects previously created in the Stark Infra API
83
+ #
84
+ # ## Parameters (conditionally-required):
85
+ # - ledger_id [string, default nil]: id of the Ledger containing the transaction. Either ledger_id or ids must be provided. If both are sent, the query will be filtered by both. ex: '5656565656565656'
86
+ # - ids [list of strings, default nil]: list of LedgerTransaction ids to filter retrieved objects. Either ledger_id or ids must be provided. If both are sent, the query will be filtered by both. ex: ['5656565656565656', '4545454545454545']
87
+ #
88
+ # ## Parameters (optional):
89
+ # - flow [string, default nil]: direction of the transaction. ex: 'in' or 'out'
90
+ # - tags [list of strings, default nil]: list of tags to filter retrieved objects. ex: ['transfer/123', 'savings']
91
+ # - external_ids [list of strings, default nil]: list of LedgerTransaction external ids to filter retrieved objects. ex: ['my-internal-id-123456', 'my-internal-id-654321']
92
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
93
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
94
+ # - limit [integer, default 100, maximum 1000]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
95
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
96
+ #
97
+ # ## Return:
98
+ # - generator of LedgerTransaction objects with updated attributes
99
+ def self.query(ledger_id: nil, flow: nil, tags: nil, external_ids: nil, after: nil, before: nil,
100
+ ids: nil, limit: nil, user: nil)
101
+ after = StarkCore::Utils::Checks.check_date(after)
102
+ before = StarkCore::Utils::Checks.check_date(before)
103
+ StarkInfra::Utils::Rest.get_stream(
104
+ ledger_id: ledger_id,
105
+ flow: flow,
106
+ tags: tags,
107
+ external_ids: external_ids,
108
+ after: after,
109
+ before: before,
110
+ ids: ids,
111
+ limit: limit,
112
+ user: user,
113
+ **resource
114
+ )
115
+ end
116
+
117
+ # # Retrieve paged LedgerTransactions
118
+ #
119
+ # Receive a list of LedgerTransaction objects previously created in the Stark Infra API and the cursor to the next page.
120
+ # Use this function instead of query if you want to manually page your requests.
121
+ #
122
+ # ## Parameters (conditionally-required):
123
+ # - ledger_id [string, default nil]: id of the Ledger containing the transaction. Either ledger_id or ids must be provided. If both are sent, the query will be filtered by both. ex: '5656565656565656'
124
+ # - ids [list of strings, default nil]: list of LedgerTransaction ids to filter retrieved objects. Either ledger_id or ids must be provided. If both are sent, the query will be filtered by both. ex: ['5656565656565656', '4545454545454545']
125
+ #
126
+ # ## Parameters (optional):
127
+ # - flow [string, default nil]: direction of the transaction. ex: 'in' or 'out'
128
+ # - tags [list of strings, default nil]: list of tags to filter retrieved objects. ex: ['transfer/123', 'savings']
129
+ # - external_ids [list of strings, default nil]: list of LedgerTransaction external ids to filter retrieved objects. ex: ['my-internal-id-123456', 'my-internal-id-654321']
130
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
131
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
132
+ # - limit [integer, default 100, maximum 1000]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
133
+ # - cursor [string, default nil]: cursor returned on the previous page function call
134
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
135
+ #
136
+ # ## Return:
137
+ # - list of LedgerTransaction objects with updated attributes
138
+ # - cursor to retrieve the next page of LedgerTransaction objects
139
+ def self.page(ledger_id: nil, flow: nil, tags: nil, external_ids: nil, after: nil, before: nil,
140
+ ids: nil, limit: nil, cursor: nil, user: nil)
141
+ after = StarkCore::Utils::Checks.check_date(after)
142
+ before = StarkCore::Utils::Checks.check_date(before)
143
+ StarkInfra::Utils::Rest.get_page(
144
+ ledger_id: ledger_id,
145
+ flow: flow,
146
+ tags: tags,
147
+ external_ids: external_ids,
148
+ after: after,
149
+ before: before,
150
+ ids: ids,
151
+ limit: limit,
152
+ cursor: cursor,
153
+ user: user,
154
+ **resource
155
+ )
156
+ end
157
+
158
+ def self.resource
159
+ {
160
+ resource_name: 'LedgerTransaction',
161
+ resource_maker: proc { |json|
162
+ LedgerTransaction.new(
163
+ id: json['id'],
164
+ amount: json['amount'],
165
+ ledger_id: json['ledger_id'],
166
+ external_id: json['external_id'],
167
+ source: json['source'],
168
+ balance: json['balance'],
169
+ fee: json['fee'],
170
+ rules: json['rules'],
171
+ metadata: json['metadata'],
172
+ tags: json['tags'],
173
+ created: json['created']
174
+ )
175
+ }
176
+ }
177
+ end
178
+ end
179
+ end
@@ -12,7 +12,7 @@ module StarkInfra
12
12
  # can be retrieved to see the available information.
13
13
  #
14
14
  # ## Attributes (return-only):
15
- # - id [string]: unique id returned when Balance is created. ex: '5656565656565656'
15
+ # - id [string]: identifier of the balance. Holds the participant bank code for direct participants, or the workspace id for indirect participants.
16
16
  # - amount [integer]: current balance amount of the workspace in cents. ex: 200 (= R$ 2.00)
17
17
  # - currency [string]: currency of the current workspace. Expect others to be added eventually. ex: 'BRL'
18
18
  # - updated [DateTime]: latest update datetime for the balance. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
@@ -17,10 +17,10 @@ module StarkInfra
17
17
  # ## Parameters (required):
18
18
  # - amount [integer]: amount in cents to be reversed. ex: 11234 (= R$ 112.34)
19
19
  # - reference_id [string]: end_to_end_id or return_id of the transaction to be reversed. ex: 'E20018183202201201450u34sDGd19lz'
20
- # - reason [string]: reason why the reversal was requested. Options: 'fraud', 'flaw', 'reversalChargeback'
20
+ # - reason [string]: reason why the reversal was requested. Options: 'flaw', 'fraud', 'subscriptionFlaw' (the API also assigns 'reversalChargeback' automatically when a chargeback stems from a closed Pix Infraction, but it cannot be passed on creation).
21
21
  #
22
22
  # ## Parameters (optional):
23
- # - description [string, default nil]: description for the PixChargeback. ex: 'Payment for service #1234'
23
+ # - description [string, default nil]: description for the PixChargeback. Required when reason is 'flaw'. ex: 'Payment for service #1234'
24
24
  # - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
25
25
  #
26
26
  # ## Attributes (return-only):
@@ -42,16 +42,17 @@ module StarkInfra
42
42
  # - reversal_tax_id [string]: tax ID for the reversal transaction. ex: '01234567890'
43
43
  # - created [DateTime]: creation datetime for the PixChargeback. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
44
44
  # - updated [DateTime]: latest update datetime for the PixChargeback. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
45
+ # - bacen_id [string]: unique transaction id returned from Central Bank. ex: 'ccf9bd9c-e99d-999e-bab9-b999ca999f99'
45
46
  class PixChargeback < StarkCore::Utils::Resource
46
47
  attr_reader :amount, :reference_id, :reason, :description, :tags, :id, :analysis, :sender_bank_code,
47
48
  :receiver_bank_code, :rejection_reason, :reversal_reference_id, :result, :flow, :status,
48
49
  :dispute_id, :is_monitoring_required, :reversal_account_number, :reversal_account_type,
49
- :reversal_bank_code, :reversal_branch_code, :reversal_tax_id, :created, :updated
50
+ :reversal_bank_code, :reversal_branch_code, :reversal_tax_id, :created, :updated, :bacen_id
50
51
  def initialize(
51
52
  amount:, reference_id:, reason:, description: nil, tags: nil, id: nil, analysis: nil, sender_bank_code: nil,
52
53
  receiver_bank_code: nil, rejection_reason: nil, reversal_reference_id: nil, result: nil, flow: nil, status: nil,
53
54
  dispute_id: nil, is_monitoring_required: nil, reversal_account_number: nil, reversal_account_type: nil,
54
- reversal_bank_code: nil, reversal_branch_code: nil, reversal_tax_id: nil, created: nil, updated: nil
55
+ reversal_bank_code: nil, reversal_branch_code: nil, reversal_tax_id: nil, created: nil, updated: nil, bacen_id: nil
55
56
  )
56
57
  super(id)
57
58
  @amount = amount
@@ -76,6 +77,7 @@ module StarkInfra
76
77
  @reversal_tax_id = reversal_tax_id
77
78
  @created = StarkCore::Utils::Checks.check_datetime(created)
78
79
  @updated = StarkCore::Utils::Checks.check_datetime(updated)
80
+ @bacen_id = bacen_id
79
81
  end
80
82
 
81
83
  # # Create PixChargebacks
@@ -184,10 +186,10 @@ module StarkInfra
184
186
  #
185
187
  # ## Parameters (required):
186
188
  # - id [string]: PixChargeback unique id. ex: '5656565656565656'
187
- # - result [string]: result after the analysis of the PixChargeback. Options: 'rejected', 'accepted', 'partiallyAccepted'.
189
+ # - result [string]: result of the chargeback analysis to submit. Options: 'agreed', 'disagreed', 'partiallyAgreed'.
188
190
  #
189
191
  # ## Parameters (conditionally required):
190
- # - rejection_reason [string, default nil]: if the PixChargeback is rejected a reason is required. Options: 'noBalance', 'accountClosed', 'unableToReverse',
192
+ # - rejection_reason [string, default nil]: if the PixChargeback's result is 'rejected', a reason is required. Options: 'other', 'noBalance', 'accountClosed', 'invalidRequest' ('unableToReverse' is not a valid value).
191
193
  # - reversal_reference_id [string, default nil]: return_id of the reversal transaction. ex: 'D20018183202201201450u34sDGd19lz'
192
194
  #
193
195
  # ## Parameters (optional):
@@ -251,7 +253,8 @@ module StarkInfra
251
253
  reversal_branch_code: json['reversal_branch_code'],
252
254
  reversal_tax_id: json['reversal_tax_id'],
253
255
  created: json['created'],
254
- updated: json['updated']
256
+ updated: json['updated'],
257
+ bacen_id: json['bacen_id']
255
258
  )
256
259
  }
257
260
  }
@@ -8,6 +8,8 @@ module StarkInfra
8
8
  #
9
9
  # A Pix Claim is a request to transfer a Pix Key from an account hosted at another
10
10
  # Pix participant to an account under your bank code. Pix Claims must always be requested by the claimer.
11
+ # An 'ownership' claim changes the holder of a Pix Key and only applies to phone-type keys; a 'portability'
12
+ # claim changes the linked account without changing the holder, and applies to phone, email or taxId keys.
11
13
  #
12
14
  # When you initialize a PixClaim, the entity will not be automatically
13
15
  # created in the Stark Infra API. The 'create' function sends the objects
@@ -27,9 +29,10 @@ module StarkInfra
27
29
  #
28
30
  # ## Attributes (return-only):
29
31
  # - id [string]: unique id returned when the PixClaim is created. ex: '5656565656565656'
32
+ # - bacen_id [string]: unique transaction id returned from Central Bank. ex: 'ccf9bd9c-e99d-999e-bab9-b999ca999f99'
30
33
  # - status [string]: current PixClaim status. Options: 'created', 'failed', 'delivered', 'confirmed', 'success', 'canceled'
31
34
  # - type [string]: type of Pix Claim. Options: 'ownership', 'portability'.
32
- # - key_type [string]: keyType of the claimed Pix Key. Options: 'CPF', 'CNPJ', 'phone' or 'email'
35
+ # - key_type [string]: keyType of the claimed Pix Key. Options: 'cpf', 'cnpj', 'phone', 'email', 'evp'.
33
36
  # - flow [string]: direction of the Pix Claim. Options: 'in' if you received the PixClaim or 'out' if you created the PixClaim.
34
37
  # - claimer_bank_code [string]: bank_code of the Pix participant that created the PixClaim. ex: '20018183'.
35
38
  # - claimed_bank_code [string]: bank_code of the account donating the PixClaim. ex: '20018183'.
@@ -37,11 +40,12 @@ module StarkInfra
37
40
  # - updated [DateTime]: update datetime for the PixClaim. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
38
41
  class PixClaim < StarkCore::Utils::Resource
39
42
  attr_reader :account_created, :account_number, :account_type, :branch_code, :name, :tax_id, :key_id,
40
- :tags, :id, :status, :type, :key_type, :flow, :claimer_bank_code, :claimed_bank_code, :created, :updated
43
+ :tags, :id, :status, :type, :key_type, :flow, :claimer_bank_code, :claimed_bank_code, :created, :updated,
44
+ :bacen_id
41
45
  def initialize(
42
46
  account_created:, account_number:, account_type:, branch_code:, name:,
43
47
  tax_id:, key_id:, tags: nil, id: nil, status: nil, type: nil, key_type: nil, flow: nil,
44
- claimer_bank_code: nil, claimed_bank_code: nil, created: nil, updated: nil
48
+ claimer_bank_code: nil, claimed_bank_code: nil, created: nil, updated: nil, bacen_id: nil
45
49
  )
46
50
  super(id)
47
51
  @account_created = account_created
@@ -60,6 +64,7 @@ module StarkInfra
60
64
  @claimed_bank_code = claimed_bank_code
61
65
  @created = StarkCore::Utils::Checks.check_datetime(created)
62
66
  @updated = StarkCore::Utils::Checks.check_datetime(updated)
67
+ @bacen_id = bacen_id
63
68
  end
64
69
 
65
70
  # # Create a PixClaim object
@@ -183,11 +188,13 @@ module StarkInfra
183
188
 
184
189
  # # Update a PixClaim entity
185
190
  #
186
- # Update a PixClaim parameters by passing id.
191
+ # Update a PixClaim by passing id. You must answer an inbound PixClaim within 7 days of its status
192
+ # changing to 'delivered' — if unanswered, a 'portability' claim is rejected by default and an
193
+ # 'ownership' claim is accepted by default, both with reason 'defaultBehavior'.
187
194
  #
188
195
  # ## Parameters (required):
189
196
  # - id [string]: PixClaim unique id. ex: '5656565656565656'
190
- # - status [string]: patched status for Pix Claim. Options: 'confirmed' and 'canceled'
197
+ # - status [string]: patched status for the PixClaim. Options: 'confirmed' (only allowed from 'delivered' status; deletes the referenced PixKey from Stark Infra and the Central Bank) and 'canceled' (only allowed from 'delivered' or 'confirmed' status).
191
198
  #
192
199
  # ## Parameters (optional):
193
200
  # - reason [string, default 'userRequested']: reason why the PixClaim is being patched. Options: 'fraud', 'userRequested', 'accountClosure'.
@@ -226,7 +233,8 @@ module StarkInfra
226
233
  claimer_bank_code: json['claimer_bank_code'],
227
234
  claimed_bank_code: json['claimed_bank_code'],
228
235
  created: json['created'],
229
- updated: json['updated']
236
+ updated: json['updated'],
237
+ bacen_id: json['bacen_id']
230
238
  )
231
239
  }
232
240
  }
@@ -23,7 +23,7 @@ module StarkInfra
23
23
  # - team_phones [list of strings]: list of phones of the team. ex: ['+5511988889999', '+5511988889998']
24
24
  #
25
25
  # ## Attributes (return-only):
26
- # - status [string]: current PixDirector status. ex: 'success'
26
+ # - status [string]: current PixDirector status. Options: 'success', 'processing', 'failed'.
27
27
  class PixDirector < StarkCore::Utils::SubResource
28
28
  attr_reader :name, :tax_id, :phone, :email, :password, :team_email, :team_phones, :status
29
29
  def initialize(name:, tax_id:, phone:, email:, password:, team_email:, team_phones:, status: nil)
@@ -16,7 +16,7 @@ module StarkInfra
16
16
  #
17
17
  # ## Parameters (required):
18
18
  # - reference_id [string]: end_to_end_id of the transaction being reported. ex: 'E20018183202201201450u34sDGd19lz'
19
- # - method [string]: method of the dispute. Options: 'scam', 'unauthorized', 'coercion', 'invasion', 'other'
19
+ # - method [string]: method of the dispute. Options: 'scam', 'unauthorized', 'coercion', 'invasion', 'other', 'unknown'.
20
20
  # - operator_email [string]: contact email of the operator responsible for the PixDispute. ex: 'ruby-sdk@starkinfra.com'
21
21
  # - operator_phone [string]: contact phone number of the operator responsible for the PixDispute. ex: '+5511999999999'
22
22
  #
@@ -11,18 +11,18 @@ module StarkInfra
11
11
  #
12
12
  # ## Attributes (return-only):
13
13
  # - end_to_end_id [string]: central bank's unique transaction id. ex: 'E20018183202201201450u34sDGd19lz'
14
- # - amount [integer]: refundable amount in cents. ex: 11234 (= R$ 112.34)
15
- # - nominal_amount [integer]: transaction amount in cents. ex: 11234 (= R$ 112.34)
14
+ # - amount [integer]: transaction amount in cents. ex: 11234 (= R$ 112.34)
15
+ # - nominal_amount [integer]: refundable amount in cents of the transaction. ex: 11234 (= R$ 112.34)
16
16
  # - receiver_type [string]: receiver's type. Options: 'individual', 'business'
17
17
  # - receiver_tax_id_created [string]: receiver's taxId creation date (business type only).
18
18
  # - receiver_account_created [string]: receiver's account creation date.
19
19
  # - receiver_bank_code [string]: receiver's bank code. ex: '20018183'
20
- # - receiver_id [string]: identifier of the accountholder in the graph.
20
+ # - receiver_id [string]: Bacen-generated pseudo ID for the receiver, used only for transaction-tracking context (not a real account identifier).
21
21
  # - sender_type [string]: sender's type. Options: 'individual', 'business'
22
22
  # - sender_tax_id_created [string]: sender's taxId creation date (business type only).
23
23
  # - sender_account_created [string]: sender's account creation date.
24
24
  # - sender_bank_code [string]: sender's bank code. ex: '20018183'
25
- # - sender_id [string]: identifier of the accountholder in the graph.
25
+ # - sender_id [string]: Bacen-generated pseudo ID for the sender, used only for transaction-tracking context (not a real account identifier).
26
26
  # - settled [DateTime]: settled datetime of the transaction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
27
27
  class Transaction < StarkCore::Utils::SubResource
28
28
  attr_reader :end_to_end_id, :amount, :nominal_amount, :receiver_type, :receiver_tax_id_created,
@@ -13,7 +13,7 @@ module StarkInfra
13
13
  # to the Stark Infra API and returns the created object.
14
14
  #
15
15
  # ## Parameters (required):
16
- # - external_id [string]: end_to_end_id or return_id of the transaction being reported. ex: 'E20018183202201201450u34sDGd19lz'
16
+ # - external_id [string]: unique string to prevent duplicates among your PixFrauds. ex: 'my-internal-id-123456'
17
17
  # - type [string]: type of PixFraud. Options: 'identity', 'mule', 'scam', 'other'
18
18
  # - tax_id [string]: user tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
19
19
  #
@@ -21,6 +21,8 @@ module StarkInfra
21
21
  # ## Parameters (optional):
22
22
  # - description [string, default nil]: description for any details that can help with the infraction investigation.
23
23
  # - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
24
+ # - fraud_type [string, default nil]: type of Pix Fraud. Options: 'identity', 'mule', 'scam', 'other', 'unknown'
25
+ # - method [string, default nil]: method of Pix Infraction. Options: 'scam', 'unauthorized', 'coercion', 'invasion', 'other', 'unknown'
24
26
  #
25
27
  # ## Attributes (return-only):
26
28
  # - id [string]: unique id returned when the PixInfraction is created. ex: '5656565656565656'
@@ -35,14 +37,17 @@ module StarkInfra
35
37
  # - dispute_id [string]: id of the PixDispute associated with the PixInfraction. ex: '5656565656565656'
36
38
  # - created [DateTime]: creation datetime for the PixInfraction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
37
39
  # - updated [DateTime]: latest update datetime for the PixInfraction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
40
+ # - bacen_id [string]: unique transaction id returned from Central Bank. ex: 'ccf9bd9c-e99d-999e-bab9-b999ca999f99'
41
+ # - fraud_id [string]: id of the Pix Fraud. ex: '5741774970552320'
38
42
  class PixInfraction < StarkCore::Utils::Resource
39
43
  attr_reader :reference_id, :type, :operator_email, :operator_phone, :description, :tags, :id, :credited_bank_code,
40
44
  :flow, :analysis, :debited_bank_code, :reported_by, :result, :status, :amount, :dispute_id,
41
- :created, :updated
45
+ :created, :updated, :bacen_id, :fraud_id, :fraud_type, :method
42
46
  def initialize(
43
47
  reference_id:, type:, operator_email:, operator_phone:, description: nil, id: nil, tags: nil,
44
48
  credited_bank_code: nil, debited_bank_code: nil, flow: nil, analysis: nil, reported_by: nil, result: nil,
45
- status: nil, amount: nil, dispute_id: nil, created: nil, updated: nil
49
+ status: nil, amount: nil, dispute_id: nil, created: nil, updated: nil,
50
+ bacen_id: nil, fraud_id: nil, fraud_type: nil, method: nil
46
51
  )
47
52
  super(id)
48
53
  @reference_id = reference_id
@@ -62,6 +67,10 @@ module StarkInfra
62
67
  @dispute_id = dispute_id
63
68
  @created = StarkCore::Utils::Checks.check_datetime(created)
64
69
  @updated = StarkCore::Utils::Checks.check_datetime(updated)
70
+ @bacen_id = bacen_id
71
+ @fraud_id = fraud_id
72
+ @fraud_type = fraud_type
73
+ @method = method
65
74
  end
66
75
 
67
76
  # # Create PixInfractions
@@ -176,14 +185,17 @@ module StarkInfra
176
185
  # - id [string]: PixInfraction unique id. ex: '5656565656565656'
177
186
  # - result [string]: result after the analysis of the PixInfraction. Options: 'agreed', 'disagreed'
178
187
  #
188
+ # ## Parameters (conditionally required):
189
+ # - fraud_type [string, default nil]: type of Pix Fraud, required only when result is 'agreed' (optional/ignored when result is 'disagreed'). Options: 'identity', 'mule', 'scam', 'other' — 'unknown' is not an accepted value.
190
+ #
179
191
  # ## Parameters (optional):
180
192
  # - analysis [string, nil]: analysis that led to the result.
181
193
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
182
194
  #
183
195
  # ## Return:
184
196
  # - PixInfraction object with updated attributes
185
- def self.update(id, result:, analysis: nil, user: nil)
186
- StarkInfra::Utils::Rest.patch_id(id: id, result: result, analysis: analysis, user: user, **resource)
197
+ def self.update(id, result:, fraud_type: nil, analysis: nil, user: nil)
198
+ StarkInfra::Utils::Rest.patch_id(id: id, result: result, fraud_type: fraud_type, analysis: analysis, user: user, **resource)
187
199
  end
188
200
 
189
201
  # # Cancel a PixInfraction entity
@@ -224,7 +236,11 @@ module StarkInfra
224
236
  amount: json['amount'],
225
237
  dispute_id: json['dispute_id'],
226
238
  created: json['created'],
227
- updated: json['updated']
239
+ updated: json['updated'],
240
+ bacen_id: json['bacen_id'],
241
+ fraud_id: json['fraud_id'],
242
+ fraud_type: json['fraud_type'],
243
+ method: json['method']
228
244
  )
229
245
  }
230
246
  }
@@ -40,7 +40,7 @@ module StarkInfra
40
40
  #
41
41
  # ## Attributes (return-only):
42
42
  # - id [string]: unique id returned when the PixInternalTransactionReport is created. ex: '5656565656565656'
43
- # - status [string]: current PixInternalTransactionReport status. ex: 'created', 'failed', 'sent' or 'success'
43
+ # - status [string]: current PixInternalTransactionReport status. Options: 'created', 'processing', 'success', 'failed'.
44
44
  # - updated [DateTime]: latest update datetime for the PixInternalTransactionReport. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
45
45
  class PixInternalTransactionReport < StarkCore::Utils::Resource
46
46
  attr_reader :amount, :created, :end_to_end_id, :method, :reference_type, :sender_account_number,
@@ -16,7 +16,7 @@ module StarkInfra
16
16
  # ## Parameters (required):
17
17
  # - account_created [DateTime or string]: opening Date or DateTime for the linked account. ex: '2020-03-10T10:30:00.000000+00:00' or DateTime.new(2020, 3, 10, 10, 30, 0, 0).
18
18
  # - account_number [string]: number of the linked account. ex: '76543'.
19
- # - account_type [string]: type of the linked account. Options: 'checking', 'savings', 'salary' or 'payment'.
19
+ # - account_type [string]: type of the linked account. Options: 'checking', 'savings', 'salary', 'payment', 'other'.
20
20
  # - branch_code [string]: branch code of the linked account. ex: '1234'.
21
21
  # - name [string]: holder's name of the linked account. ex: 'Jamie Lannister'.
22
22
  # - tax_id [string]: holder's taxId (CPF/CNPJ) of the linked account. ex: '012.345.678-90'.