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,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('../utils/rest')
|
|
5
|
+
|
|
6
|
+
module StarkInfra
|
|
7
|
+
# # IssuingTokenRequest object
|
|
8
|
+
#
|
|
9
|
+
# The IssuingTokenRequest object displays the necessary information to proceed with the card tokenization.
|
|
10
|
+
#
|
|
11
|
+
# ## Parameters (required):
|
|
12
|
+
# - card_id [string]: card id to be tokenized. ex: '5734340247945216'
|
|
13
|
+
# - wallet_id [string]: desired wallet to be integrated. ex: 'google'
|
|
14
|
+
# - method_code [string]: method code. ex: 'app' or 'manual'
|
|
15
|
+
#
|
|
16
|
+
# ## Attributes (return-only):
|
|
17
|
+
# - content [string]: token request content. ex: 'eyJwdWJsaWNLZXlGaW5nZXJwcmludCI6ICJlNTNiZThjZTRhYWQxNWU2OWNmMjExOTA5Mjk4YzJkOTE0O...'
|
|
18
|
+
# - signature [string]: token request signature. ex: 'eyJwdWJsaWNLZXlGaW5nZXJwcmludCI6ICJlNTNiZThjZTRhYWQxNWU2OWNmMjExOTA5Mjk4YzJkOTE0O...'
|
|
19
|
+
# - metadata [hash]: hash object used to store additional information about the IssuingTokenRequest object.
|
|
20
|
+
class IssuingTokenRequest < StarkCore::Utils::SubResource
|
|
21
|
+
attr_reader :card_id, :wallet_id, :method_code, :content, :signature, :metadata
|
|
22
|
+
def initialize(card_id:, wallet_id:, method_code:, content: nil, signature: nil, metadata: nil)
|
|
23
|
+
@card_id = card_id
|
|
24
|
+
@wallet_id = wallet_id
|
|
25
|
+
@method_code = method_code
|
|
26
|
+
@content = content
|
|
27
|
+
@signature = signature
|
|
28
|
+
@metadata = metadata
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# # Create an IssuingTokenRequest object
|
|
32
|
+
#
|
|
33
|
+
# Send an IssuingTokenRequest object to Stark Infra API to create the payload to proceed with the card tokenization
|
|
34
|
+
#
|
|
35
|
+
# ## Parameters (required):
|
|
36
|
+
# - request [IssuingTokenRequest object]: IssuingTokenRequest object to the API to generate the payload
|
|
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
|
+
# - IssuingTokenRequest object with updated attributes
|
|
43
|
+
def self.create(request, user: nil)
|
|
44
|
+
StarkInfra::Utils::Rest.post_single(entity: request, user: user, **resource)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.resource
|
|
48
|
+
{
|
|
49
|
+
resource_name: 'IssuingTokenRequest',
|
|
50
|
+
resource_maker: proc { |json|
|
|
51
|
+
IssuingTokenRequest.new(
|
|
52
|
+
card_id: json['card_id'],
|
|
53
|
+
wallet_id: json['wallet_id'],
|
|
54
|
+
method_code: json['method_code'],
|
|
55
|
+
content: json['content'],
|
|
56
|
+
signature: json['signature'],
|
|
57
|
+
metadata: json['metadata']
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -19,13 +19,15 @@ module StarkInfra
|
|
|
19
19
|
# Attributes (return-only):
|
|
20
20
|
# - name [string]: category's name. ex: 'Veterinary services', 'Fast food restaurants'
|
|
21
21
|
# - number [string]: category's number. ex: '742', '5814'
|
|
22
|
+
# - group [string]: category's group. ex: 'pets', 'food'
|
|
22
23
|
class MerchantCategory < StarkCore::Utils::SubResource
|
|
23
|
-
attr_reader :code, :type, :name, :number
|
|
24
|
-
def initialize(code:, type:, name: nil, number: nil)
|
|
24
|
+
attr_reader :code, :type, :name, :number, :group
|
|
25
|
+
def initialize(code:, type:, name: nil, number: nil, group: nil)
|
|
25
26
|
@code = code
|
|
26
27
|
@type = type
|
|
27
28
|
@name = name
|
|
28
29
|
@number = number
|
|
30
|
+
@group = group
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
# # Retrieve MerchantCategories
|
|
@@ -54,7 +56,8 @@ module StarkInfra
|
|
|
54
56
|
code: json['code'],
|
|
55
57
|
type: json['type'],
|
|
56
58
|
name: json['name'],
|
|
57
|
-
number: json['number']
|
|
59
|
+
number: json['number'],
|
|
60
|
+
group: json['group']
|
|
58
61
|
)
|
|
59
62
|
}
|
|
60
63
|
}
|
|
@@ -33,15 +33,25 @@ module StarkInfra
|
|
|
33
33
|
# - result [string]: result after the analysis of the PixChargeback by the receiving party. Options: 'rejected', 'accepted', 'partiallyAccepted'
|
|
34
34
|
# - flow [string]: direction of the Pix Chargeback. Options: 'in' for received chargebacks, 'out' for chargebacks you requested
|
|
35
35
|
# - status [string]: current PixChargeback status. Options: 'created', 'failed', 'delivered', 'closed', 'canceled'.
|
|
36
|
+
# - dispute_id [string]: id of the dispute associated with the PixChargeback. ex: '5656565656565656'
|
|
37
|
+
# - is_monitoring_required [bool]: indicates if monitoring is required for this chargeback. ex: true
|
|
38
|
+
# - reversal_account_number [string]: account number for the reversal transaction. ex: '876543-2'
|
|
39
|
+
# - reversal_account_type [string]: account type for the reversal transaction. ex: 'checking'
|
|
40
|
+
# - reversal_bank_code [string]: bank code for the reversal transaction. ex: '20018183'
|
|
41
|
+
# - reversal_branch_code [string]: branch code for the reversal transaction. ex: '1357-9'
|
|
42
|
+
# - reversal_tax_id [string]: tax ID for the reversal transaction. ex: '01234567890'
|
|
36
43
|
# - created [DateTime]: creation datetime for the PixChargeback. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
37
44
|
# - updated [DateTime]: latest update datetime for the PixChargeback. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
38
45
|
class PixChargeback < StarkCore::Utils::Resource
|
|
39
46
|
attr_reader :amount, :reference_id, :reason, :description, :tags, :id, :analysis, :sender_bank_code,
|
|
40
|
-
:receiver_bank_code, :rejection_reason, :reversal_reference_id, :result, :flow, :status,
|
|
47
|
+
:receiver_bank_code, :rejection_reason, :reversal_reference_id, :result, :flow, :status,
|
|
48
|
+
:dispute_id, :is_monitoring_required, :reversal_account_number, :reversal_account_type,
|
|
49
|
+
:reversal_bank_code, :reversal_branch_code, :reversal_tax_id, :created, :updated
|
|
41
50
|
def initialize(
|
|
42
51
|
amount:, reference_id:, reason:, description: nil, tags: nil, id: nil, analysis: nil, sender_bank_code: nil,
|
|
43
52
|
receiver_bank_code: nil, rejection_reason: nil, reversal_reference_id: nil, result: nil, flow: nil, status: nil,
|
|
44
|
-
|
|
53
|
+
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
|
|
45
55
|
)
|
|
46
56
|
super(id)
|
|
47
57
|
@amount = amount
|
|
@@ -57,6 +67,13 @@ module StarkInfra
|
|
|
57
67
|
@result = result
|
|
58
68
|
@flow = flow
|
|
59
69
|
@status = status
|
|
70
|
+
@dispute_id = dispute_id
|
|
71
|
+
@is_monitoring_required = is_monitoring_required
|
|
72
|
+
@reversal_account_number = reversal_account_number
|
|
73
|
+
@reversal_account_type = reversal_account_type
|
|
74
|
+
@reversal_bank_code = reversal_bank_code
|
|
75
|
+
@reversal_branch_code = reversal_branch_code
|
|
76
|
+
@reversal_tax_id = reversal_tax_id
|
|
60
77
|
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
61
78
|
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
|
62
79
|
end
|
|
@@ -226,6 +243,13 @@ module StarkInfra
|
|
|
226
243
|
result: json['result'],
|
|
227
244
|
flow: json['flow'],
|
|
228
245
|
status: json['status'],
|
|
246
|
+
dispute_id: json['dispute_id'],
|
|
247
|
+
is_monitoring_required: json['is_monitoring_required'],
|
|
248
|
+
reversal_account_number: json['reversal_account_number'],
|
|
249
|
+
reversal_account_type: json['reversal_account_type'],
|
|
250
|
+
reversal_bank_code: json['reversal_bank_code'],
|
|
251
|
+
reversal_branch_code: json['reversal_branch_code'],
|
|
252
|
+
reversal_tax_id: json['reversal_tax_id'],
|
|
229
253
|
created: json['created'],
|
|
230
254
|
updated: json['updated']
|
|
231
255
|
)
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('pix_dispute')
|
|
5
|
+
require_relative('../utils/rest')
|
|
6
|
+
|
|
7
|
+
module StarkInfra
|
|
8
|
+
class PixDispute
|
|
9
|
+
# # PixDispute::Log object
|
|
10
|
+
#
|
|
11
|
+
# Every time a PixDispute entity is modified, a corresponding PixDispute::Log
|
|
12
|
+
# is generated for the entity. This log is never generated by the user.
|
|
13
|
+
#
|
|
14
|
+
# ## Attributes (return-only):
|
|
15
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
|
16
|
+
# - dispute [PixDispute]: PixDispute entity to which the log refers to.
|
|
17
|
+
# - type [string]: type of the PixDispute event which triggered the log creation. ex: 'created', 'delivered', 'analysed'
|
|
18
|
+
# - errors [list of strings]: list of errors linked to this PixDispute event.
|
|
19
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
20
|
+
class Log < StarkCore::Utils::Resource
|
|
21
|
+
attr_reader :id, :dispute, :type, :errors, :created
|
|
22
|
+
def initialize(id:, dispute:, type:, errors:, created:)
|
|
23
|
+
super(id)
|
|
24
|
+
@dispute = dispute
|
|
25
|
+
@type = type
|
|
26
|
+
@errors = errors
|
|
27
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# # Retrieve a specific PixDispute::Log
|
|
31
|
+
#
|
|
32
|
+
# Receive a single PixDispute::Log object previously created by the Stark Infra API by passing 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
|
+
# - PixDispute::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 PixDispute::Logs
|
|
47
|
+
#
|
|
48
|
+
# Receive a generator of PixDispute::Log objects previously created in the Stark Infra API
|
|
49
|
+
#
|
|
50
|
+
# ## Parameters (optional):
|
|
51
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
|
52
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
53
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
54
|
+
# - types [list of strings, default nil]: filter retrieved objects by types. ex: ['analysed', 'delivered']
|
|
55
|
+
# - dispute_ids [list of strings, default nil]: list of PixDispute ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
56
|
+
# - ids [list of strings, default nil]: Log ids to filter PixDispute Logs. ex: ['5656565656565656']
|
|
57
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
58
|
+
#
|
|
59
|
+
# ## Return:
|
|
60
|
+
# - generator of PixDispute::Log objects with updated attributes
|
|
61
|
+
def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, dispute_ids: nil, user: nil)
|
|
62
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
63
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
64
|
+
StarkInfra::Utils::Rest.get_stream(
|
|
65
|
+
ids: ids,
|
|
66
|
+
limit: limit,
|
|
67
|
+
after: after,
|
|
68
|
+
before: before,
|
|
69
|
+
types: types,
|
|
70
|
+
dispute_ids: dispute_ids,
|
|
71
|
+
user: user,
|
|
72
|
+
**resource
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# # Retrieve paged PixDispute::Logs
|
|
77
|
+
#
|
|
78
|
+
# Receive a list of up to 100 PixDispute::Log objects previously created in the Stark Infra API and the cursor to the next page.
|
|
79
|
+
# Use this function instead of query if you want to manually page your logs.
|
|
80
|
+
#
|
|
81
|
+
# ## Parameters (optional):
|
|
82
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
|
83
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
|
84
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
85
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
86
|
+
# - types [list of strings, default nil]: filter retrieved objects by types. ex: ['analysed', 'delivered']
|
|
87
|
+
# - dispute_ids [list of strings, default nil]: list of PixDispute ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
88
|
+
# - ids [list of strings, default nil]: Log ids to filter PixDispute Logs. ex: ['5656565656565656']
|
|
89
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
90
|
+
#
|
|
91
|
+
# ## Return:
|
|
92
|
+
# - list of PixDispute::Log objects with updated attributes
|
|
93
|
+
# - cursor to retrieve the next page of Log objects
|
|
94
|
+
def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, dispute_ids: nil, user: nil)
|
|
95
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
96
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
97
|
+
StarkInfra::Utils::Rest.get_page(
|
|
98
|
+
cursor: cursor,
|
|
99
|
+
ids: ids,
|
|
100
|
+
limit: limit,
|
|
101
|
+
after: after,
|
|
102
|
+
before: before,
|
|
103
|
+
types: types,
|
|
104
|
+
dispute_ids: dispute_ids,
|
|
105
|
+
user: user,
|
|
106
|
+
**resource
|
|
107
|
+
)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def self.resource
|
|
111
|
+
dispute_maker = StarkInfra::PixDispute.resource[:resource_maker]
|
|
112
|
+
{
|
|
113
|
+
resource_name: 'PixDisputeLog',
|
|
114
|
+
resource_maker: proc { |json|
|
|
115
|
+
Log.new(
|
|
116
|
+
id: json['id'],
|
|
117
|
+
dispute: StarkCore::Utils::API.from_api_json(dispute_maker, json['dispute']),
|
|
118
|
+
type: json['type'],
|
|
119
|
+
errors: json['errors'],
|
|
120
|
+
created: json['created']
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('../utils/rest')
|
|
5
|
+
|
|
6
|
+
module StarkInfra
|
|
7
|
+
# # PixDispute object
|
|
8
|
+
#
|
|
9
|
+
# A PixDispute is a request to investigate a Pix transaction that is suspected of
|
|
10
|
+
# fraud or that resulted from a system malfunction. It maps the network of
|
|
11
|
+
# transactions linked to the reported one for analysis.
|
|
12
|
+
#
|
|
13
|
+
# When you initialize a PixDispute, the entity will not be automatically
|
|
14
|
+
# created in the Stark Infra API. The 'create' function sends a list of objects
|
|
15
|
+
# to the Stark Infra API and returns the list of created objects.
|
|
16
|
+
#
|
|
17
|
+
# ## Parameters (required):
|
|
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'
|
|
20
|
+
# - operator_email [string]: contact email of the operator responsible for the PixDispute. ex: 'ruby-sdk@starkinfra.com'
|
|
21
|
+
# - operator_phone [string]: contact phone number of the operator responsible for the PixDispute. ex: '+5511999999999'
|
|
22
|
+
#
|
|
23
|
+
# ## Parameters (conditionally required):
|
|
24
|
+
# - description [string, default nil]: details for the investigation. Required when method == 'other'; optional otherwise.
|
|
25
|
+
#
|
|
26
|
+
# ## Parameters (optional):
|
|
27
|
+
# - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
|
|
28
|
+
# - min_transaction_amount [integer, default nil]: minimum transaction amount considered for the graph creation. ex: 100
|
|
29
|
+
# - max_transaction_count [integer, default nil]: maximum number of transactions considered for the graph creation. ex: 10
|
|
30
|
+
# - max_hop_interval [integer, default nil]: mean time between transactions considered for the graph creation. ex: 3600
|
|
31
|
+
# - max_hop_count [integer, default nil]: depth considered for the graph creation. ex: 5
|
|
32
|
+
#
|
|
33
|
+
# ## Attributes (return-only):
|
|
34
|
+
# - id [string]: unique id returned when the PixDispute is created. ex: '5656565656565656'
|
|
35
|
+
# - bacen_id [string]: central bank's unique PixDispute id. ex: '817fc523-9e9d-40ab-9e53-dacb71454a05'
|
|
36
|
+
# - flow [string]: direction of the PixDispute. Options: 'in' for received disputes, 'out' for disputes you created.
|
|
37
|
+
# - status [string]: current PixDispute status. Options: 'created', 'delivered', 'analysed', 'processing', 'closed', 'failed', 'canceled'
|
|
38
|
+
# - transactions [list of PixDispute::Transaction objects]: list of Transaction objects linked to the PixDispute.
|
|
39
|
+
# - created [DateTime]: creation datetime for the PixDispute. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
40
|
+
# - updated [DateTime]: latest update datetime for the PixDispute. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
41
|
+
class PixDispute < StarkCore::Utils::Resource
|
|
42
|
+
attr_reader :reference_id, :method, :operator_email, :operator_phone, :description, :tags, :min_transaction_amount,
|
|
43
|
+
:max_transaction_count, :max_hop_interval, :max_hop_count, :id, :bacen_id, :flow, :status,
|
|
44
|
+
:transactions, :created, :updated
|
|
45
|
+
def initialize(
|
|
46
|
+
reference_id:, method:, operator_email:, operator_phone:, description: nil, tags: nil,
|
|
47
|
+
min_transaction_amount: nil, max_transaction_count: nil, max_hop_interval: nil, max_hop_count: nil,
|
|
48
|
+
id: nil, bacen_id: nil, flow: nil, status: nil, transactions: nil, created: nil, updated: nil
|
|
49
|
+
)
|
|
50
|
+
super(id)
|
|
51
|
+
@reference_id = reference_id
|
|
52
|
+
@method = method
|
|
53
|
+
@operator_email = operator_email
|
|
54
|
+
@operator_phone = operator_phone
|
|
55
|
+
@description = description
|
|
56
|
+
@tags = tags
|
|
57
|
+
@min_transaction_amount = min_transaction_amount
|
|
58
|
+
@max_transaction_count = max_transaction_count
|
|
59
|
+
@max_hop_interval = max_hop_interval
|
|
60
|
+
@max_hop_count = max_hop_count
|
|
61
|
+
@bacen_id = bacen_id
|
|
62
|
+
@flow = flow
|
|
63
|
+
@status = status
|
|
64
|
+
@transactions = PixDispute::Transaction.parse_transactions(transactions)
|
|
65
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
66
|
+
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# # Create PixDisputes
|
|
70
|
+
#
|
|
71
|
+
# Send a list of PixDispute objects for creation in the Stark Infra API
|
|
72
|
+
#
|
|
73
|
+
# ## Parameters (required):
|
|
74
|
+
# - disputes [list of PixDispute objects]: list of PixDispute objects to be created in the API.
|
|
75
|
+
#
|
|
76
|
+
# ## Parameters (optional):
|
|
77
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
78
|
+
#
|
|
79
|
+
# ## Return:
|
|
80
|
+
# - list of PixDispute objects with updated attributes
|
|
81
|
+
def self.create(disputes, user: nil)
|
|
82
|
+
StarkInfra::Utils::Rest.post(entities: disputes, user: user, **resource)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# # Retrieve a specific PixDispute
|
|
86
|
+
#
|
|
87
|
+
# Receive a single PixDispute object previously created in the Stark Infra API by passing its id
|
|
88
|
+
#
|
|
89
|
+
# ## Parameters (required):
|
|
90
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
|
91
|
+
#
|
|
92
|
+
# ## Parameters (optional):
|
|
93
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
94
|
+
#
|
|
95
|
+
# ## Return:
|
|
96
|
+
# - PixDispute object with updated attributes
|
|
97
|
+
def self.get(id, user: nil)
|
|
98
|
+
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# # Retrieve PixDisputes
|
|
102
|
+
#
|
|
103
|
+
# Receive a generator of PixDispute objects previously created in the Stark Infra API
|
|
104
|
+
#
|
|
105
|
+
# ## Parameters (optional):
|
|
106
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
|
107
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
108
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
109
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['created', 'delivered']
|
|
110
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
111
|
+
# - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
|
|
112
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
113
|
+
#
|
|
114
|
+
# ## Return:
|
|
115
|
+
# - generator of PixDispute objects with updated attributes
|
|
116
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, ids: nil, tags: nil, user: nil)
|
|
117
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
118
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
119
|
+
StarkInfra::Utils::Rest.get_stream(
|
|
120
|
+
limit: limit,
|
|
121
|
+
after: after,
|
|
122
|
+
before: before,
|
|
123
|
+
status: status,
|
|
124
|
+
ids: ids,
|
|
125
|
+
tags: tags,
|
|
126
|
+
user: user,
|
|
127
|
+
**resource
|
|
128
|
+
)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# # Retrieve paged PixDisputes
|
|
132
|
+
#
|
|
133
|
+
# Receive a list of up to 100 PixDispute objects previously created in the Stark Infra API and the cursor to the next page.
|
|
134
|
+
# Use this function instead of query if you want to manually page your disputes.
|
|
135
|
+
#
|
|
136
|
+
# ## Parameters (optional):
|
|
137
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
|
138
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
|
139
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
140
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
141
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['created', 'delivered']
|
|
142
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
143
|
+
# - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
|
|
144
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
145
|
+
#
|
|
146
|
+
# ## Return:
|
|
147
|
+
# - list of PixDispute objects with updated attributes
|
|
148
|
+
# - cursor to retrieve the next page of PixDispute objects
|
|
149
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil, tags: nil, user: nil)
|
|
150
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
151
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
152
|
+
StarkInfra::Utils::Rest.get_page(
|
|
153
|
+
cursor: cursor,
|
|
154
|
+
limit: limit,
|
|
155
|
+
after: after,
|
|
156
|
+
before: before,
|
|
157
|
+
status: status,
|
|
158
|
+
ids: ids,
|
|
159
|
+
tags: tags,
|
|
160
|
+
user: user,
|
|
161
|
+
**resource
|
|
162
|
+
)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# # Cancel a PixDispute entity
|
|
166
|
+
#
|
|
167
|
+
# Cancel a PixDispute entity previously created in the Stark Infra API
|
|
168
|
+
#
|
|
169
|
+
# ## Parameters (required):
|
|
170
|
+
# - id [string]: PixDispute unique id. ex: '5656565656565656'
|
|
171
|
+
#
|
|
172
|
+
# ## Parameters (optional):
|
|
173
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
174
|
+
#
|
|
175
|
+
# ## Return:
|
|
176
|
+
# - canceled PixDispute object
|
|
177
|
+
def self.cancel(id, user: nil)
|
|
178
|
+
StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def self.resource
|
|
182
|
+
{
|
|
183
|
+
resource_name: 'PixDispute',
|
|
184
|
+
resource_maker: proc { |json|
|
|
185
|
+
PixDispute.new(
|
|
186
|
+
id: json['id'],
|
|
187
|
+
reference_id: json['reference_id'],
|
|
188
|
+
method: json['method'],
|
|
189
|
+
operator_email: json['operator_email'],
|
|
190
|
+
operator_phone: json['operator_phone'],
|
|
191
|
+
description: json['description'],
|
|
192
|
+
tags: json['tags'],
|
|
193
|
+
min_transaction_amount: json['min_transaction_amount'],
|
|
194
|
+
max_transaction_count: json['max_transaction_count'],
|
|
195
|
+
max_hop_interval: json['max_hop_interval'],
|
|
196
|
+
max_hop_count: json['max_hop_count'],
|
|
197
|
+
bacen_id: json['bacen_id'],
|
|
198
|
+
flow: json['flow'],
|
|
199
|
+
status: json['status'],
|
|
200
|
+
transactions: json['transactions'],
|
|
201
|
+
created: json['created'],
|
|
202
|
+
updated: json['updated']
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
require_relative('transaction')
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
|
|
5
|
+
module StarkInfra
|
|
6
|
+
class PixDispute
|
|
7
|
+
# # PixDispute::Transaction object
|
|
8
|
+
#
|
|
9
|
+
# Transactions linked to a PixDispute as part of the graph analysis. This object
|
|
10
|
+
# is return-only; it is never created by the user.
|
|
11
|
+
#
|
|
12
|
+
# ## Attributes (return-only):
|
|
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)
|
|
16
|
+
# - receiver_type [string]: receiver's type. Options: 'individual', 'business'
|
|
17
|
+
# - receiver_tax_id_created [string]: receiver's taxId creation date (business type only).
|
|
18
|
+
# - receiver_account_created [string]: receiver's account creation date.
|
|
19
|
+
# - receiver_bank_code [string]: receiver's bank code. ex: '20018183'
|
|
20
|
+
# - receiver_id [string]: identifier of the accountholder in the graph.
|
|
21
|
+
# - sender_type [string]: sender's type. Options: 'individual', 'business'
|
|
22
|
+
# - sender_tax_id_created [string]: sender's taxId creation date (business type only).
|
|
23
|
+
# - sender_account_created [string]: sender's account creation date.
|
|
24
|
+
# - sender_bank_code [string]: sender's bank code. ex: '20018183'
|
|
25
|
+
# - sender_id [string]: identifier of the accountholder in the graph.
|
|
26
|
+
# - settled [DateTime]: settled datetime of the transaction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
27
|
+
class Transaction < StarkCore::Utils::SubResource
|
|
28
|
+
attr_reader :end_to_end_id, :amount, :nominal_amount, :receiver_type, :receiver_tax_id_created,
|
|
29
|
+
:receiver_account_created, :receiver_bank_code, :receiver_id, :sender_type, :sender_tax_id_created,
|
|
30
|
+
:sender_account_created, :sender_bank_code, :sender_id, :settled
|
|
31
|
+
def initialize(
|
|
32
|
+
end_to_end_id: nil, amount: nil, nominal_amount: nil, receiver_type: nil, receiver_tax_id_created: nil,
|
|
33
|
+
receiver_account_created: nil, receiver_bank_code: nil, receiver_id: nil, sender_type: nil,
|
|
34
|
+
sender_tax_id_created: nil, sender_account_created: nil, sender_bank_code: nil, sender_id: nil, settled: nil
|
|
35
|
+
)
|
|
36
|
+
@end_to_end_id = end_to_end_id
|
|
37
|
+
@amount = amount
|
|
38
|
+
@nominal_amount = nominal_amount
|
|
39
|
+
@receiver_type = receiver_type
|
|
40
|
+
@receiver_tax_id_created = receiver_tax_id_created
|
|
41
|
+
@receiver_account_created = receiver_account_created
|
|
42
|
+
@receiver_bank_code = receiver_bank_code
|
|
43
|
+
@receiver_id = receiver_id
|
|
44
|
+
@sender_type = sender_type
|
|
45
|
+
@sender_tax_id_created = sender_tax_id_created
|
|
46
|
+
@sender_account_created = sender_account_created
|
|
47
|
+
@sender_bank_code = sender_bank_code
|
|
48
|
+
@sender_id = sender_id
|
|
49
|
+
@settled = StarkCore::Utils::Checks.check_datetime(settled)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def self.parse_transactions(transactions)
|
|
53
|
+
resource_maker = StarkInfra::PixDispute::Transaction.resource[:resource_maker]
|
|
54
|
+
return transactions if transactions.nil?
|
|
55
|
+
|
|
56
|
+
parsed_transactions = []
|
|
57
|
+
transactions.each do |transaction|
|
|
58
|
+
unless transaction.is_a? Transaction
|
|
59
|
+
transaction = StarkCore::Utils::API.from_api_json(resource_maker, transaction)
|
|
60
|
+
end
|
|
61
|
+
parsed_transactions << transaction
|
|
62
|
+
end
|
|
63
|
+
parsed_transactions
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def self.resource
|
|
67
|
+
{
|
|
68
|
+
resource_name: 'PixDisputeTransaction',
|
|
69
|
+
resource_maker: proc { |json|
|
|
70
|
+
Transaction.new(
|
|
71
|
+
end_to_end_id: json['end_to_end_id'],
|
|
72
|
+
amount: json['amount'],
|
|
73
|
+
nominal_amount: json['nominal_amount'],
|
|
74
|
+
receiver_type: json['receiver_type'],
|
|
75
|
+
receiver_tax_id_created: json['receiver_tax_id_created'],
|
|
76
|
+
receiver_account_created: json['receiver_account_created'],
|
|
77
|
+
receiver_bank_code: json['receiver_bank_code'],
|
|
78
|
+
receiver_id: json['receiver_id'],
|
|
79
|
+
sender_type: json['sender_type'],
|
|
80
|
+
sender_tax_id_created: json['sender_tax_id_created'],
|
|
81
|
+
sender_account_created: json['sender_account_created'],
|
|
82
|
+
sender_bank_code: json['sender_bank_code'],
|
|
83
|
+
sender_id: json['sender_id'],
|
|
84
|
+
settled: json['settled']
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|