starkinfra 0.5.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcode_preview/brcode_preview.rb +25 -4
  3. data/lib/brcode_preview/subscription.rb +102 -0
  4. data/lib/business_account_request/business_account_request.rb +276 -0
  5. data/lib/business_account_request/log.rb +124 -0
  6. data/lib/business_attachment/business_attachment.rb +189 -0
  7. data/lib/{individual_document → business_attachment}/log.rb +35 -32
  8. data/lib/business_identity/business_identity.rb +228 -0
  9. data/lib/business_identity/log.rb +127 -0
  10. data/lib/credit_holmes/credit_holmes.rb +2 -1
  11. data/lib/credit_holmes/log.rb +125 -0
  12. data/lib/credit_note/credit_note.rb +51 -8
  13. data/lib/credit_note/rule.rb +55 -0
  14. data/lib/credit_note/transfer.rb +1 -1
  15. data/lib/credit_preview/credit_note_preview.rb +10 -2
  16. data/lib/credit_preview/credit_preview.rb +2 -1
  17. data/lib/credit_signer/credit_signer.rb +27 -2
  18. data/lib/dynamic_brcode/dynamic_brcode.rb +5 -2
  19. data/lib/event/event.rb +10 -2
  20. data/lib/individual_account_attachment/individual_account_attachment.rb +178 -0
  21. data/lib/individual_account_attachment/log.rb +124 -0
  22. data/lib/individual_account_request/individual_account_request.rb +271 -0
  23. data/lib/individual_account_request/log.rb +124 -0
  24. data/lib/individual_identity/individual_identity.rb +4 -7
  25. data/lib/issuing_balance/issuing_balance.rb +8 -2
  26. data/lib/issuing_billing_invoice/issuing_billing_invoice.rb +155 -0
  27. data/lib/issuing_billing_transaction/issuing_billing_transaction.rb +142 -0
  28. data/lib/issuing_card/issuing_card.rb +10 -6
  29. data/lib/issuing_design/issuing_design.rb +9 -0
  30. data/lib/issuing_embossing_request/issuing_embossing_request.rb +3 -2
  31. data/lib/issuing_holder/issuing_holder.rb +6 -5
  32. data/lib/issuing_product/issuing_product.rb +6 -3
  33. data/lib/issuing_purchase/issuing_purchase.rb +41 -8
  34. data/lib/issuing_restock/issuing_restock.rb +3 -2
  35. data/lib/issuing_rule/issuing_rule.rb +45 -3
  36. data/lib/issuing_stock/issuing_stock.rb +5 -2
  37. data/lib/issuing_stock_rule/issuing_stock_rule.rb +214 -0
  38. data/lib/issuing_token/issuing_token.rb +309 -0
  39. data/lib/issuing_token/log.rb +127 -0
  40. data/lib/issuing_token_activation/issuing_token_activation.rb +62 -0
  41. data/lib/issuing_token_design/issuing_token_design.rb +118 -0
  42. data/lib/issuing_token_request/issuing_token_request.rb +63 -0
  43. data/lib/issuing_withdrawal/issuing_withdrawal.rb +2 -2
  44. data/lib/ledger/ledger.rb +175 -0
  45. data/lib/ledger/log.rb +122 -0
  46. data/lib/ledger/rule.rb +55 -0
  47. data/lib/ledger_transaction/ledger_transaction.rb +179 -0
  48. data/lib/merchant_category/merchant_category.rb +6 -3
  49. data/lib/pix_balance/pix_balance.rb +1 -1
  50. data/lib/pix_chargeback/pix_chargeback.rb +34 -7
  51. data/lib/pix_claim/pix_claim.rb +14 -6
  52. data/lib/pix_director/pix_director.rb +1 -1
  53. data/lib/pix_dispute/log.rb +127 -0
  54. data/lib/pix_dispute/pix_dispute.rb +210 -0
  55. data/lib/pix_dispute/transaction.rb +91 -0
  56. data/lib/pix_fraud/log.rb +128 -0
  57. data/lib/pix_fraud/pix_fraud.rb +180 -0
  58. data/lib/pix_infraction/pix_infraction.rb +37 -7
  59. data/lib/pix_internal_transaction_report/log.rb +129 -0
  60. data/lib/pix_internal_transaction_report/pix_internal_transaction_report.rb +200 -0
  61. data/lib/pix_key/pix_key.rb +1 -1
  62. data/lib/pix_key_holmes/log.rb +129 -0
  63. data/lib/{individual_document/individual_document.rb → pix_key_holmes/pix_key_holmes.rb} +48 -56
  64. data/lib/pix_pull_request/log.rb +127 -0
  65. data/lib/pix_pull_request/pix_pull_request.rb +268 -0
  66. data/lib/pix_pull_subscription/log.rb +127 -0
  67. data/lib/pix_pull_subscription/pix_pull_subscription.rb +307 -0
  68. data/lib/pix_request/pix_request.rb +19 -6
  69. data/lib/pix_reversal/pix_reversal.rb +14 -8
  70. data/lib/pix_statement/pix_statement.rb +11 -5
  71. data/lib/pix_user/pix_user.rb +52 -0
  72. data/lib/pix_user/statistics.rb +64 -0
  73. data/lib/starkinfra.rb +45 -4
  74. data/lib/static_brcode/static_brcode.rb +8 -4
  75. data/lib/utils/bacen_id.rb +27 -0
  76. data/lib/utils/end_to_end_id.rb +20 -0
  77. data/lib/utils/pix_subscription_bacen_id.rb +21 -0
  78. data/lib/utils/return_id.rb +21 -0
  79. data/lib/webhook/webhook.rb +3 -3
  80. metadata +48 -11
@@ -0,0 +1,128 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('pix_fraud')
5
+ require_relative('../utils/rest')
6
+
7
+ module StarkInfra
8
+ class PixFraud
9
+ # # PixFraud::Log object
10
+ #
11
+ # Every time a PixFraud entity is modified, a corresponding PixFraud::Log
12
+ # is generated for the entity. This log is never generated by the
13
+ # user.
14
+ #
15
+ # ## Attributes (return-only):
16
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
17
+ # - fraud [PixFraud]: PixFraud entity to which the log refers to.
18
+ # - type [string]: type of the PixFraud event which triggered the log creation. ex: 'created', 'failed', 'registered', 'canceled'
19
+ # - errors [list of strings]: list of errors linked to this PixFraud event.
20
+ # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
21
+ class Log < StarkCore::Utils::Resource
22
+ attr_reader :id, :created, :type, :errors, :fraud
23
+ def initialize(id:, created:, type:, errors:, fraud:)
24
+ super(id)
25
+ @fraud = fraud
26
+ @type = type
27
+ @errors = errors
28
+ @created = StarkCore::Utils::Checks.check_datetime(created)
29
+ end
30
+
31
+ # # Retrieve a specific PixFraud::Log
32
+ #
33
+ # Receive a single PixFraud::Log object previously created by the Stark Infra API by passing its id
34
+ #
35
+ # ## Parameters (required):
36
+ # - id [string]: object unique id. ex: '5656565656565656'
37
+ #
38
+ # ## Parameters (optional):
39
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
40
+ #
41
+ # ## Return:
42
+ # - PixFraud::Log object with updated attributes
43
+ def self.get(id, user: nil)
44
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
45
+ end
46
+
47
+ # # Retrieve PixFraud::Logs
48
+ #
49
+ # Receive a generator of PixFraud::Log objects previously created in the Stark Infra API
50
+ #
51
+ # ## Parameters (optional):
52
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
53
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
54
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
55
+ # - types [list of strings, default nil]: filter retrieved objects by their types. ex: ['created', 'failed', 'registered', 'canceled']
56
+ # - fraud_ids [list of strings, default nil]: list of PixFraud ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
57
+ # - ids [list of strings, default nil]: Log ids to filter PixFraud Logs. ex: ['5656565656565656']
58
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
59
+ #
60
+ # ## Return:
61
+ # - list of PixFraud::Log objects with updated attributes
62
+ def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, fraud_ids: nil, user: nil)
63
+ after = StarkCore::Utils::Checks.check_date(after)
64
+ before = StarkCore::Utils::Checks.check_date(before)
65
+ StarkInfra::Utils::Rest.get_stream(
66
+ ids: ids,
67
+ limit: limit,
68
+ after: after,
69
+ before: before,
70
+ types: types,
71
+ fraud_ids: fraud_ids,
72
+ user: user,
73
+ **resource
74
+ )
75
+ end
76
+
77
+ # # Retrieve paged PixFraud::Logs
78
+ #
79
+ # Receive a list of up to 100 PixFraud::Log objects previously created in the Stark Infra API and the cursor to the next page.
80
+ # Use this function instead of query if you want to manually page your frauds.
81
+ #
82
+ # ## Parameters (optional):
83
+ # - cursor [string, default nil]: cursor returned on the previous page function call
84
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
85
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
86
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
87
+ # - types [list of strings, default nil]: filter retrieved objects by their types. ex: ['created', 'failed', 'registered', 'canceled']
88
+ # - fraud_ids [list of strings, default nil]: list of PixFraud ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
89
+ # - ids [list of strings, default nil]: Log ids to filter PixFraud Logs. ex: ['5656565656565656']
90
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
91
+ #
92
+ # ## Return:
93
+ # - list of PixFraud::Log objects with updated attributes
94
+ # - Cursor to retrieve the next page of Log objects
95
+ def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, fraud_ids: nil, user: nil)
96
+ after = StarkCore::Utils::Checks.check_date(after)
97
+ before = StarkCore::Utils::Checks.check_date(before)
98
+ StarkInfra::Utils::Rest.get_page(
99
+ cursor: cursor,
100
+ ids: ids,
101
+ limit: limit,
102
+ after: after,
103
+ before: before,
104
+ types: types,
105
+ fraud_ids: fraud_ids,
106
+ user: user,
107
+ **resource
108
+ )
109
+ end
110
+
111
+ def self.resource
112
+ fraud_maker = StarkInfra::PixFraud.resource[:resource_maker]
113
+ {
114
+ resource_name: 'PixFraudLog',
115
+ resource_maker: proc { |json|
116
+ Log.new(
117
+ id: json['id'],
118
+ fraud: StarkCore::Utils::API.from_api_json(fraud_maker, json['fraud']),
119
+ type: json['type'],
120
+ errors: json['errors'],
121
+ created: json['created']
122
+ )
123
+ }
124
+ }
125
+ end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,180 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+
6
+ module StarkInfra
7
+ # # PixFraud object
8
+ #
9
+ # PixFrauds are used to report a PixKey or taxId when a fraud
10
+ # has been confirmed.
11
+ # When you initialize a PixFraud, the entity will not be automatically
12
+ # created in the Stark Infra API. The 'create' function sends the objects
13
+ # to the Stark Infra API and returns the created object.
14
+ #
15
+ # ## Parameters (required):
16
+ # - external_id [string]: unique string to prevent duplicates among your PixFrauds. ex: 'my-internal-id-123456'
17
+ # - type [string]: type of PixFraud. Options: 'identity', 'mule', 'scam', 'other'
18
+ # - tax_id [string]: user tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
19
+ #
20
+ # ## Parameters (optional):
21
+ # - key_id [string, default nil]: marked PixKey id. ex: '+5511989898989'
22
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ['fraudulent']
23
+ #
24
+ # ## Attributes (return-only):
25
+ # - id [string]: unique id returned when the PixFraud is created. ex: '5656565656565656'
26
+ # - bacen_id [string]: unique transaction id returned from Central Bank. ex: 'ccf9bd9c-e99d-999e-bab9-b999ca999f99'
27
+ # - status [string]: current PixFraud status. Options: 'created', 'failed', 'registered', 'canceled'.
28
+ # - created [DateTime]: creation datetime for the PixFraud. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
29
+ # - updated [DateTime]: latest update datetime for the PixFraud. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
30
+ class PixFraud < StarkCore::Utils::Resource
31
+ attr_reader :external_id, :type, :tax_id, :key_id, :tags, :id, :bacen_id, :status, :created, :updated
32
+ def initialize(
33
+ external_id:, type:, tax_id:, key_id: nil, tags: nil,
34
+ id: nil, bacen_id: nil, status: nil, created: nil, updated: nil
35
+ )
36
+ super(id)
37
+ @external_id = external_id
38
+ @type = type
39
+ @tax_id = tax_id
40
+ @key_id = key_id
41
+ @tags = tags
42
+ @bacen_id = bacen_id
43
+ @status = status
44
+ @created = StarkCore::Utils::Checks.check_datetime(created)
45
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
46
+ end
47
+
48
+ # # Create PixFrauds
49
+ #
50
+ # Send a list of PixFraud objects for creation in the Stark Infra API
51
+ #
52
+ # ## Parameters (required):
53
+ # - frauds [list of PixFraud objects]: list of PixFraud objects to be created in the API.
54
+ #
55
+ # ## Parameters (optional):
56
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
57
+ #
58
+ # ## Return:
59
+ # - list of PixFraud objects with updated attributes
60
+ def self.create(frauds, user: nil)
61
+ StarkInfra::Utils::Rest.post(entities: frauds, user: user, **resource)
62
+ end
63
+
64
+ # # Retrieve a specific PixFraud
65
+ #
66
+ # Receive a single PixFraud object previously created in the Stark Infra API by passing 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
+ # - PixFraud 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 PixFrauds
81
+ #
82
+ # Receive a generator of PixFraud objects previously created in the Stark Infra API
83
+ #
84
+ # ## Parameters (optional):
85
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
86
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
87
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
88
+ # - status [list of strings, default nil]: filter for status of retrieved objects. Options: 'created', 'failed', 'registered', 'canceled'.
89
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
90
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ['fraudulent']
91
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
92
+ #
93
+ # ## Return:
94
+ # - generator of PixFraud objects with updated attributes
95
+ def self.query(limit: nil, after: nil, before: nil, status: nil, ids: nil, tags: nil, user: nil)
96
+ after = StarkCore::Utils::Checks.check_date(after)
97
+ before = StarkCore::Utils::Checks.check_date(before)
98
+ StarkInfra::Utils::Rest.get_stream(
99
+ limit: limit,
100
+ after: after,
101
+ before: before,
102
+ status: status,
103
+ ids: ids,
104
+ tags: tags,
105
+ user: user,
106
+ **resource
107
+ )
108
+ end
109
+
110
+ # # Retrieve paged PixFrauds
111
+ #
112
+ # Receive a list of up to 100 PixFraud objects previously created in the Stark Infra API and the cursor to the next page.
113
+ # Use this function instead of query if you want to manually page your frauds.
114
+ #
115
+ # ## Parameters (optional):
116
+ # - cursor [string, default nil]: cursor returned on the previous page function call
117
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
118
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
119
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
120
+ # - status [list of strings, default nil]: filter for status of retrieved objects. Options: 'created', 'failed', 'registered', 'canceled'.
121
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
122
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ['fraudulent']
123
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
124
+ #
125
+ # ## Return:
126
+ # - list of PixFraud objects with updated attributes
127
+ # - cursor to retrieve the next page of PixFraud objects
128
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil, tags: nil, user: nil)
129
+ after = StarkCore::Utils::Checks.check_date(after)
130
+ before = StarkCore::Utils::Checks.check_date(before)
131
+ StarkInfra::Utils::Rest.get_page(
132
+ cursor: cursor,
133
+ limit: limit,
134
+ after: after,
135
+ before: before,
136
+ status: status,
137
+ ids: ids,
138
+ tags: tags,
139
+ user: user,
140
+ **resource
141
+ )
142
+ end
143
+
144
+ # # Cancel a PixFraud entity
145
+ #
146
+ # Cancel a PixFraud entity previously created in the Stark Infra API
147
+ #
148
+ # ## Parameters (required):
149
+ # - id [string]: PixFraud unique id. ex: '5656565656565656'
150
+ #
151
+ # ## Parameters (optional):
152
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
153
+ #
154
+ # ## Return:
155
+ # - canceled PixFraud object
156
+ def self.cancel(id, user: nil)
157
+ StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
158
+ end
159
+
160
+ def self.resource
161
+ {
162
+ resource_name: 'PixFraud',
163
+ resource_maker: proc { |json|
164
+ PixFraud.new(
165
+ id: json['id'],
166
+ external_id: json['external_id'],
167
+ type: json['type'],
168
+ tax_id: json['tax_id'],
169
+ key_id: json['key_id'],
170
+ tags: json['tags'],
171
+ bacen_id: json['bacen_id'],
172
+ status: json['status'],
173
+ created: json['created'],
174
+ updated: json['updated']
175
+ )
176
+ }
177
+ }
178
+ end
179
+ end
180
+ end
@@ -15,10 +15,14 @@ module StarkInfra
15
15
  # ## Parameters (required):
16
16
  # - reference_id [string]: end_to_end_id or return_id of the transaction being reported. ex: 'E20018183202201201450u34sDGd19lz'
17
17
  # - type [string]: type of infraction report. Options: 'fraud', 'reversal', 'reversalChargeback'
18
+ # - operator_email [string]: contact email of the operator responsible for the PixInfraction. ex: 'ruby-sdk@starkinfra.com'
19
+ # - operator_phone [string]: contact phone number of the operator responsible for the PixInfraction. ex: '+5511999999999'
18
20
  #
19
21
  # ## Parameters (optional):
20
22
  # - description [string, default nil]: description for any details that can help with the infraction investigation.
21
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'
22
26
  #
23
27
  # ## Attributes (return-only):
24
28
  # - id [string]: unique id returned when the PixInfraction is created. ex: '5656565656565656'
@@ -29,18 +33,27 @@ module StarkInfra
29
33
  # - reported_by [string]: agent that reported the PixInfraction. Options: 'debited', 'credited'.
30
34
  # - result [string]: result after the analysis of the PixInfraction by the receiving party. Options: 'agreed', 'disagreed'
31
35
  # - status [string]: current PixInfraction status. Options: 'created', 'failed', 'delivered', 'closed', 'canceled'.
36
+ # - amount [integer]: amount in cents of the reported transaction. ex: 11234 (= R$ 112.34)
37
+ # - dispute_id [string]: id of the PixDispute associated with the PixInfraction. ex: '5656565656565656'
32
38
  # - created [DateTime]: creation datetime for the PixInfraction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
33
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'
34
42
  class PixInfraction < StarkCore::Utils::Resource
35
- attr_reader :reference_id, :type, :description, :tags, :id, :credited_bank_code, :flow, :analysis,
36
- :debited_bank_code, :reported_by, :result, :status, :created, :updated
43
+ attr_reader :reference_id, :type, :operator_email, :operator_phone, :description, :tags, :id, :credited_bank_code,
44
+ :flow, :analysis, :debited_bank_code, :reported_by, :result, :status, :amount, :dispute_id,
45
+ :created, :updated, :bacen_id, :fraud_id, :fraud_type, :method
37
46
  def initialize(
38
- reference_id:, type:, description: nil, id: nil, tags: nil, credited_bank_code: nil, debited_bank_code: nil,
39
- flow: nil, analysis: nil, reported_by: nil, result: nil, status: nil, created: nil, updated: nil
47
+ reference_id:, type:, operator_email:, operator_phone:, description: nil, id: nil, tags: nil,
48
+ credited_bank_code: nil, debited_bank_code: nil, flow: nil, analysis: nil, reported_by: nil, result: 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
40
51
  )
41
52
  super(id)
42
53
  @reference_id = reference_id
43
54
  @type = type
55
+ @operator_email = operator_email
56
+ @operator_phone = operator_phone
44
57
  @description = description
45
58
  @tags = tags
46
59
  @credited_bank_code = credited_bank_code
@@ -50,8 +63,14 @@ module StarkInfra
50
63
  @reported_by = reported_by
51
64
  @result = result
52
65
  @status = status
66
+ @amount = amount
67
+ @dispute_id = dispute_id
53
68
  @created = StarkCore::Utils::Checks.check_datetime(created)
54
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
55
74
  end
56
75
 
57
76
  # # Create PixInfractions
@@ -166,14 +185,17 @@ module StarkInfra
166
185
  # - id [string]: PixInfraction unique id. ex: '5656565656565656'
167
186
  # - result [string]: result after the analysis of the PixInfraction. Options: 'agreed', 'disagreed'
168
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
+ #
169
191
  # ## Parameters (optional):
170
192
  # - analysis [string, nil]: analysis that led to the result.
171
193
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
172
194
  #
173
195
  # ## Return:
174
196
  # - PixInfraction object with updated attributes
175
- def self.update(id, result:, analysis: nil, user: nil)
176
- 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)
177
199
  end
178
200
 
179
201
  # # Cancel a PixInfraction entity
@@ -200,6 +222,8 @@ module StarkInfra
200
222
  id: json['id'],
201
223
  reference_id: json['reference_id'],
202
224
  type: json['type'],
225
+ operator_email: json['operator_email'],
226
+ operator_phone: json['operator_phone'],
203
227
  description: json['description'],
204
228
  tags: json['tags'],
205
229
  credited_bank_code: json['credited_bank_code'],
@@ -209,8 +233,14 @@ module StarkInfra
209
233
  reported_by: json['reported_by'],
210
234
  result: json['result'],
211
235
  status: json['status'],
236
+ amount: json['amount'],
237
+ dispute_id: json['dispute_id'],
212
238
  created: json['created'],
213
- 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']
214
244
  )
215
245
  }
216
246
  }
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('pix_internal_transaction_report')
5
+ require_relative('../utils/rest')
6
+
7
+
8
+ module StarkInfra
9
+ class PixInternalTransactionReport
10
+ # # PixInternalTransactionReport::Log object
11
+ #
12
+ # Every time a PixInternalTransactionReport entity is updated, a corresponding
13
+ # PixInternalTransactionReport::Log is generated for the entity. This log is
14
+ # never generated by the user.
15
+ #
16
+ # ## Attributes (return-only):
17
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
18
+ # - report [PixInternalTransactionReport object]: PixInternalTransactionReport entity to which the log refers to.
19
+ # - type [string]: type of the PixInternalTransactionReport event which triggered the log creation. ex: 'created', 'failed', 'sent' or 'success'
20
+ # - errors [list of strings]: list of errors linked to this PixInternalTransactionReport event.
21
+ # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
22
+ class Log < StarkCore::Utils::Resource
23
+ attr_reader :id, :created, :type, :errors, :report
24
+ def initialize(id:, created:, type:, errors:, report:)
25
+ super(id)
26
+ @created = StarkCore::Utils::Checks.check_datetime(created)
27
+ @type = type
28
+ @errors = errors
29
+ @report = report
30
+ end
31
+
32
+ # # Retrieve a specific PixInternalTransactionReport::Log
33
+ #
34
+ # Receive a single PixInternalTransactionReport::Log object previously created by the Stark Infra API by passing its id
35
+ #
36
+ # ## Parameters (required):
37
+ # - id [string]: object unique id. ex: '5656565656565656'
38
+ #
39
+ # ## Parameters (optional):
40
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
41
+ #
42
+ # ## Return:
43
+ # - PixInternalTransactionReport::Log object with updated attributes
44
+ def self.get(id, user: nil)
45
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
46
+ end
47
+
48
+ # # Retrieve PixInternalTransactionReport::Logs
49
+ #
50
+ # Receive a generator of PixInternalTransactionReport::Log objects previously created in the Stark Infra API
51
+ #
52
+ # ## Parameters (optional):
53
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
54
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
55
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
56
+ # - types [list of strings, default nil]: filter retrieved objects by types. ex: 'success' or 'failed'
57
+ # - report_ids [list of strings, default nil]: list of PixInternalTransactionReport ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
58
+ # - ids [list of strings, default nil]: Log ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
59
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
60
+ #
61
+ # ## Return:
62
+ # - generator of PixInternalTransactionReport::Log objects with updated attributes
63
+ def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, report_ids: nil, user: nil)
64
+ after = StarkCore::Utils::Checks.check_date(after)
65
+ before = StarkCore::Utils::Checks.check_date(before)
66
+ StarkInfra::Utils::Rest.get_stream(
67
+ ids: ids,
68
+ limit: limit,
69
+ after: after,
70
+ before: before,
71
+ types: types,
72
+ report_ids: report_ids,
73
+ user: user,
74
+ **resource
75
+ )
76
+ end
77
+
78
+ # # Retrieve paged PixInternalTransactionReport::Logs
79
+ #
80
+ # Receive a list of up to 100 PixInternalTransactionReport::Log objects previously created in the Stark Infra API and the cursor to the next page.
81
+ # Use this function instead of query if you want to manually page your logs.
82
+ #
83
+ # ## Parameters (optional):
84
+ # - cursor [string, default nil]: cursor returned on the previous page function call
85
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
86
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
87
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
88
+ # - types [list of strings, default nil]: filter retrieved objects by types. ex: 'success' or 'failed'
89
+ # - report_ids [list of strings, default nil]: list of PixInternalTransactionReport ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
90
+ # - ids [list of strings, default nil]: Log ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
91
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
92
+ #
93
+ # ## Return:
94
+ # - list of PixInternalTransactionReport::Log objects with updated attributes
95
+ # - cursor to retrieve the next page of Log objects
96
+ def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, report_ids: nil, user: nil)
97
+ after = StarkCore::Utils::Checks.check_date(after)
98
+ before = StarkCore::Utils::Checks.check_date(before)
99
+ StarkInfra::Utils::Rest.get_page(
100
+ cursor: cursor,
101
+ ids: ids,
102
+ limit: limit,
103
+ after: after,
104
+ before: before,
105
+ types: types,
106
+ report_ids: report_ids,
107
+ user: user,
108
+ **resource
109
+ )
110
+ end
111
+
112
+ def self.resource
113
+ report_maker = StarkInfra::PixInternalTransactionReport.resource[:resource_maker]
114
+ {
115
+ resource_name: 'PixInternalTransactionReportLog',
116
+ resource_maker: proc { |json|
117
+ Log.new(
118
+ id: json['id'],
119
+ report: StarkCore::Utils::API.from_api_json(report_maker, json['report']),
120
+ type: json['type'],
121
+ errors: json['errors'],
122
+ created: json['created']
123
+ )
124
+ }
125
+ }
126
+ end
127
+ end
128
+ end
129
+ end