starkinfra 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/{brcodepreview/brcodepreview.rb → brcode_preview/brcode_preview.rb} +5 -2
- data/lib/brcode_preview/subscription.rb +102 -0
- data/lib/business_attachment/business_attachment.rb +186 -0
- data/lib/business_attachment/log.rb +127 -0
- data/lib/business_identity/business_identity.rb +225 -0
- data/lib/business_identity/log.rb +127 -0
- data/lib/{creditnote/creditnote.rb → credit_note/credit_note.rb} +11 -5
- data/lib/{creditnote → credit_note}/log.rb +1 -1
- data/lib/credit_note/rule.rb +46 -0
- data/lib/event/event.rb +10 -2
- data/lib/{individualdocument → individual_document}/log.rb +1 -1
- data/lib/{individualidentity → individual_identity}/log.rb +1 -1
- data/lib/{issuingbalance/issuingbalance.rb → issuing_balance/issuing_balance.rb} +8 -2
- data/lib/issuing_billing_invoice/issuing_billing_invoice.rb +155 -0
- data/lib/issuing_billing_transaction/issuing_billing_transaction.rb +142 -0
- data/lib/{issuingcard/issuingcard.rb → issuing_card/issuing_card.rb} +5 -2
- data/lib/{issuingcard → issuing_card}/log.rb +1 -1
- data/lib/{issuingembossingrequest → issuing_embossing_request}/log.rb +1 -1
- data/lib/{issuingholder → issuing_holder}/log.rb +1 -1
- data/lib/{issuinginvoice → issuing_invoice}/log.rb +1 -1
- data/lib/{issuingproduct/issuingproduct.rb → issuing_product/issuing_product.rb} +5 -2
- data/lib/{issuingpurchase/issuingpurchase.rb → issuing_purchase/issuing_purchase.rb} +18 -9
- data/lib/{issuingpurchase → issuing_purchase}/log.rb +1 -1
- data/lib/{issuingrestock → issuing_restock}/log.rb +1 -1
- data/lib/{issuingrule/issuingrule.rb → issuing_rule/issuing_rule.rb} +9 -3
- data/lib/{issuingstock/issuingstock.rb → issuing_stock/issuing_stock.rb} +5 -2
- data/lib/{issuingstock → issuing_stock}/log.rb +1 -1
- data/lib/issuing_stock_rule/issuing_stock_rule.rb +213 -0
- data/lib/issuing_token/issuing_token.rb +309 -0
- data/lib/issuing_token_design/issuing_token_design.rb +118 -0
- data/lib/issuing_token_request/issuing_token_request.rb +63 -0
- data/lib/{merchantcategory/merchantcategory.rb → merchant_category/merchant_category.rb} +6 -3
- data/lib/{pixchargeback → pix_chargeback}/log.rb +1 -1
- data/lib/{pixchargeback/pixchargeback.rb → pix_chargeback/pix_chargeback.rb} +26 -2
- data/lib/{pixclaim → pix_claim}/log.rb +1 -1
- data/lib/pix_dispute/log.rb +127 -0
- data/lib/pix_dispute/pix_dispute.rb +210 -0
- data/lib/pix_dispute/transaction.rb +91 -0
- data/lib/pix_fraud/log.rb +128 -0
- data/lib/pix_fraud/pix_fraud.rb +180 -0
- data/lib/{pixinfraction → pix_infraction}/log.rb +1 -1
- data/lib/{pixinfraction/pixinfraction.rb → pix_infraction/pix_infraction.rb} +18 -4
- data/lib/pix_internal_transaction_report/log.rb +129 -0
- data/lib/pix_internal_transaction_report/pix_internal_transaction_report.rb +200 -0
- data/lib/{pixkey → pix_key}/log.rb +1 -1
- data/lib/pix_key_holmes/pix_key_holmes.rb +139 -0
- data/lib/pix_pull_request/log.rb +127 -0
- data/lib/pix_pull_request/pix_pull_request.rb +265 -0
- data/lib/pix_pull_subscription/log.rb +127 -0
- data/lib/pix_pull_subscription/pix_pull_subscription.rb +281 -0
- data/lib/{pixrequest → pix_request}/log.rb +1 -1
- data/lib/{pixrequest/pixrequest.rb → pix_request/pix_request.rb} +9 -2
- data/lib/{pixreversal → pix_reversal}/log.rb +1 -1
- data/lib/starkinfra.rb +83 -59
- data/lib/utils/parse.rb +2 -2
- data/lib/utils/return_id.rb +24 -0
- data/lib/webhook/webhook.rb +2 -2
- metadata +87 -67
- /data/lib/{cardmethod/cardmethod.rb → card_method/card_method.rb} +0 -0
- /data/lib/{creditholmes/creditholmes.rb → credit_holmes/credit_holmes.rb} +0 -0
- /data/lib/{creditnote → credit_note}/invoice/description.rb +0 -0
- /data/lib/{creditnote → credit_note}/invoice/discount.rb +0 -0
- /data/lib/{creditnote → credit_note}/invoice/invoice.rb +0 -0
- /data/lib/{creditnote → credit_note}/transfer.rb +0 -0
- /data/lib/{creditpreview/creditnotepreview.rb → credit_preview/credit_note_preview.rb} +0 -0
- /data/lib/{creditpreview/creditpreview.rb → credit_preview/credit_preview.rb} +0 -0
- /data/lib/{creditsigner/creditsigner.rb → credit_signer/credit_signer.rb} +0 -0
- /data/lib/{dynamicbrcode/dynamicbrcode.rb → dynamic_brcode/dynamic_brcode.rb} +0 -0
- /data/lib/{individualdocument/individualdocument.rb → individual_document/individual_document.rb} +0 -0
- /data/lib/{individualidentity/individualidentity.rb → individual_identity/individual_identity.rb} +0 -0
- /data/lib/{issuingdesign/issuingdesign.rb → issuing_design/issuing_design.rb} +0 -0
- /data/lib/{issuingembossingkit/issuingembossingkit.rb → issuing_embossing_kit/issuing_embossing_kit.rb} +0 -0
- /data/lib/{issuingembossingrequest/issuingembossingrequest.rb → issuing_embossing_request/issuing_embossing_request.rb} +0 -0
- /data/lib/{issuingholder/issuingholder.rb → issuing_holder/issuing_holder.rb} +0 -0
- /data/lib/{issuinginvoice/issuinginvoice.rb → issuing_invoice/issuing_invoice.rb} +0 -0
- /data/lib/{issuingrestock/issuingrestock.rb → issuing_restock/issuing_restock.rb} +0 -0
- /data/lib/{issuingtransaction/issuingtransaction.rb → issuing_transaction/issuing_transaction.rb} +0 -0
- /data/lib/{issuingwithdrawal/issuingwithdrawal.rb → issuing_withdrawal/issuing_withdrawal.rb} +0 -0
- /data/lib/{merchantcountry/merchantcountry.rb → merchant_country/merchant_country.rb} +0 -0
- /data/lib/{pixbalance/pixbalance.rb → pix_balance/pix_balance.rb} +0 -0
- /data/lib/{pixclaim/pixclaim.rb → pix_claim/pix_claim.rb} +0 -0
- /data/lib/{pixdirector/pixdirector.rb → pix_director/pix_director.rb} +0 -0
- /data/lib/{pixdomain → pix_domain}/certificate.rb +0 -0
- /data/lib/{pixdomain/pixdomain.rb → pix_domain/pix_domain.rb} +0 -0
- /data/lib/{pixkey/pixkey.rb → pix_key/pix_key.rb} +0 -0
- /data/lib/{pixreversal/pixreversal.rb → pix_reversal/pix_reversal.rb} +0 -0
- /data/lib/{pixstatement/pixstatement.rb → pix_statement/pix_statement.rb} +0 -0
- /data/lib/{staticbrcode/staticbrcode.rb → static_brcode/static_brcode.rb} +0 -0
|
@@ -0,0 +1,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]: end_to_end_id or return_id of the transaction being reported. ex: 'E20018183202201201450u34sDGd19lz'
|
|
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,6 +15,8 @@ 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.
|
|
@@ -29,18 +31,24 @@ module StarkInfra
|
|
|
29
31
|
# - reported_by [string]: agent that reported the PixInfraction. Options: 'debited', 'credited'.
|
|
30
32
|
# - result [string]: result after the analysis of the PixInfraction by the receiving party. Options: 'agreed', 'disagreed'
|
|
31
33
|
# - status [string]: current PixInfraction status. Options: 'created', 'failed', 'delivered', 'closed', 'canceled'.
|
|
34
|
+
# - amount [integer]: amount in cents of the reported transaction. ex: 11234 (= R$ 112.34)
|
|
35
|
+
# - dispute_id [string]: id of the PixDispute associated with the PixInfraction. ex: '5656565656565656'
|
|
32
36
|
# - created [DateTime]: creation datetime for the PixInfraction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
33
37
|
# - updated [DateTime]: latest update datetime for the PixInfraction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
34
38
|
class PixInfraction < StarkCore::Utils::Resource
|
|
35
|
-
attr_reader :reference_id, :type, :
|
|
36
|
-
:debited_bank_code, :reported_by, :result, :status, :
|
|
39
|
+
attr_reader :reference_id, :type, :operator_email, :operator_phone, :description, :tags, :id, :credited_bank_code,
|
|
40
|
+
:flow, :analysis, :debited_bank_code, :reported_by, :result, :status, :amount, :dispute_id,
|
|
41
|
+
:created, :updated
|
|
37
42
|
def initialize(
|
|
38
|
-
reference_id:, type:, description: nil, id: nil, tags: nil,
|
|
39
|
-
|
|
43
|
+
reference_id:, type:, operator_email:, operator_phone:, description: nil, id: nil, tags: nil,
|
|
44
|
+
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
|
|
40
46
|
)
|
|
41
47
|
super(id)
|
|
42
48
|
@reference_id = reference_id
|
|
43
49
|
@type = type
|
|
50
|
+
@operator_email = operator_email
|
|
51
|
+
@operator_phone = operator_phone
|
|
44
52
|
@description = description
|
|
45
53
|
@tags = tags
|
|
46
54
|
@credited_bank_code = credited_bank_code
|
|
@@ -50,6 +58,8 @@ module StarkInfra
|
|
|
50
58
|
@reported_by = reported_by
|
|
51
59
|
@result = result
|
|
52
60
|
@status = status
|
|
61
|
+
@amount = amount
|
|
62
|
+
@dispute_id = dispute_id
|
|
53
63
|
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
54
64
|
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
|
55
65
|
end
|
|
@@ -200,6 +210,8 @@ module StarkInfra
|
|
|
200
210
|
id: json['id'],
|
|
201
211
|
reference_id: json['reference_id'],
|
|
202
212
|
type: json['type'],
|
|
213
|
+
operator_email: json['operator_email'],
|
|
214
|
+
operator_phone: json['operator_phone'],
|
|
203
215
|
description: json['description'],
|
|
204
216
|
tags: json['tags'],
|
|
205
217
|
credited_bank_code: json['credited_bank_code'],
|
|
@@ -209,6 +221,8 @@ module StarkInfra
|
|
|
209
221
|
reported_by: json['reported_by'],
|
|
210
222
|
result: json['result'],
|
|
211
223
|
status: json['status'],
|
|
224
|
+
amount: json['amount'],
|
|
225
|
+
dispute_id: json['dispute_id'],
|
|
212
226
|
created: json['created'],
|
|
213
227
|
updated: json['updated']
|
|
214
228
|
)
|
|
@@ -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
|