starkinfra 0.0.3 → 0.2.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 +121 -0
- data/lib/cardmethod/cardmethod.rb +56 -0
- data/lib/creditnote/creditnote.rb +58 -341
- data/lib/creditnote/invoice/description.rb +51 -0
- data/lib/creditnote/invoice/discount.rb +49 -0
- data/lib/creditnote/invoice/invoice.rb +123 -0
- data/lib/creditnote/log.rb +2 -2
- data/lib/creditnote/transfer.rb +90 -0
- data/lib/creditpreview/creditnotepreview.rb +85 -0
- data/lib/creditpreview/creditpreview.rb +83 -0
- data/lib/creditsigner/creditsigner.rb +57 -0
- data/lib/dynamicbrcode/dynamicbrcode.rb +350 -0
- data/lib/event/attempt.rb +4 -3
- data/lib/event/event.rb +10 -10
- data/lib/issuingbalance/issuingbalance.rb +4 -4
- data/lib/issuingcard/issuingcard.rb +40 -36
- data/lib/issuingcard/log.rb +3 -3
- data/lib/issuingholder/issuingholder.rb +14 -9
- data/lib/issuingholder/log.rb +3 -3
- data/lib/issuinginvoice/issuinginvoice.rb +24 -10
- data/lib/issuinginvoice/log.rb +3 -3
- data/lib/issuingproduct/issuingproduct.rb +86 -0
- data/lib/issuingpurchase/issuingpurchase.rb +100 -24
- data/lib/issuingpurchase/log.rb +2 -2
- data/lib/issuingrule/issuingrule.rb +74 -30
- data/lib/issuingtransaction/issuingtransaction.rb +6 -8
- data/lib/issuingwithdrawal/issuingwithdrawal.rb +11 -7
- data/lib/merchantcategory/merchantcategory.rb +63 -0
- data/lib/merchantcountry/merchantcountry.rb +59 -0
- data/lib/pixbalance/pixbalance.rb +5 -5
- data/lib/pixchargeback/log.rb +3 -3
- data/lib/pixchargeback/pixchargeback.rb +32 -20
- data/lib/pixclaim/log.rb +8 -11
- data/lib/pixclaim/pixclaim.rb +43 -32
- data/lib/pixdirector/pixdirector.rb +9 -11
- data/lib/pixdomain/certificate.rb +1 -1
- data/lib/pixdomain/pixdomain.rb +4 -4
- data/lib/pixinfraction/log.rb +2 -2
- data/lib/pixinfraction/pixinfraction.rb +21 -13
- data/lib/pixkey/log.rb +5 -5
- data/lib/pixkey/pixkey.rb +12 -10
- data/lib/pixrequest/log.rb +2 -2
- data/lib/pixrequest/pixrequest.rb +51 -21
- data/lib/pixreversal/log.rb +2 -2
- data/lib/pixreversal/pixreversal.rb +48 -20
- data/lib/pixstatement/pixstatement.rb +12 -7
- data/lib/starkinfra.rb +27 -15
- data/lib/staticbrcode/staticbrcode.rb +164 -0
- data/lib/user/project.rb +1 -1
- data/lib/utils/api.rb +1 -0
- data/lib/utils/parse.rb +7 -3
- data/lib/utils/request.rb +1 -1
- data/lib/utils/resource.rb +1 -1
- data/lib/utils/rest.rb +1 -2
- data/lib/utils/sub_resource.rb +21 -22
- data/lib/webhook/webhook.rb +3 -3
- metadata +16 -4
- data/lib/issuingauthorization/issuingauthorization.rb +0 -141
- data/lib/issuingbin/issuingbin.rb +0 -89
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('../utils/resource')
|
4
3
|
require_relative('../utils/rest')
|
5
4
|
require_relative('../utils/checks')
|
5
|
+
require_relative('../utils/resource')
|
6
6
|
|
7
7
|
module StarkInfra
|
8
8
|
# # IssuingRule object
|
@@ -12,47 +12,91 @@ module StarkInfra
|
|
12
12
|
# ## Parameters (required):
|
13
13
|
# - name [string]: rule name. ex: 'Travel' or 'Food'
|
14
14
|
# - amount [integer]: maximum amount that can be spent in the informed interval. ex: 200000 (= R$ 2000.00)
|
15
|
-
#
|
15
|
+
#
|
16
16
|
# ## Parameters (optional):
|
17
|
+
# - id [string, default nil]: unique id returned when an IssuingRule is created, used to update a specific IssuingRule. ex: '5656565656565656'
|
18
|
+
# - interval [string, default 'lifetime']: interval after which the rule amount counter will be reset to 0. ex: 'instant', 'day', 'week', 'month', 'year' or 'lifetime'
|
17
19
|
# - currency_code [string, default 'BRL']: code of the currency that the rule amount refers to. ex: 'BRL' or 'USD'
|
18
|
-
# - categories [list of
|
19
|
-
# - countries [list of
|
20
|
-
# - methods [list of
|
20
|
+
# - categories [list of MerchantCategories, default nil]: merchant categories accepted by the rule. ex: [MerchantCategory(code='fastFoodRestaurants')]
|
21
|
+
# - countries [list of MerchantCountries, default nil]: countries accepted by the rule. ex: [MerchantCountry(code='BRA')]
|
22
|
+
# - methods [list of CardMethods, default nil]: card purchase methods accepted by the rule. ex: [CardMethod(code='magstripe')]
|
23
|
+
#
|
21
24
|
# ## Attributes (expanded return-only):
|
22
25
|
# - counter_amount [integer]: current rule spent amount. ex: 1000
|
23
26
|
# - currency_symbol [string]: currency symbol. ex: 'R$'
|
24
27
|
# - currency_name [string]: currency name. ex: 'Brazilian Real'
|
25
|
-
# ## Attributes (return-only):
|
26
|
-
# - id [string]: unique id returned when Rule is created. ex: '5656565656565656'
|
27
28
|
class IssuingRule < StarkInfra::Utils::Resource
|
28
|
-
attr_reader :name, :interval, :amount, :currency_code, :counter_amount, :currency_name, :currency_symbol,
|
29
|
-
|
30
|
-
|
29
|
+
attr_reader :name, :interval, :amount, :currency_code, :counter_amount, :currency_name, :currency_symbol,
|
30
|
+
:categories, :countries, :methods
|
31
|
+
def initialize(
|
32
|
+
name:, amount:, id: nil, interval: nil, currency_code: nil, categories: nil, countries: nil, methods: nil,
|
33
|
+
counter_amount: nil, currency_symbol: nil, currency_name: nil
|
31
34
|
)
|
32
35
|
super(id)
|
33
36
|
@name = name
|
34
|
-
@interval = interval
|
35
37
|
@amount = amount
|
38
|
+
@interval = interval
|
36
39
|
@currency_code = currency_code
|
40
|
+
@categories = IssuingRule.parse_categories(categories)
|
41
|
+
@countries = IssuingRule.parse_categories(countries)
|
42
|
+
@methods = IssuingRule.parse_categories(methods)
|
37
43
|
@counter_amount = counter_amount
|
38
|
-
@currency_name = currency_name
|
39
44
|
@currency_symbol = currency_symbol
|
40
|
-
@
|
41
|
-
|
42
|
-
|
45
|
+
@currency_name = currency_name
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.parse_categories(categories)
|
49
|
+
resource_maker = StarkInfra::MerchantCategory.resource[:resource_maker]
|
50
|
+
return categories if categories.nil?
|
51
|
+
|
52
|
+
parsed_categories = []
|
53
|
+
categories.each do |category|
|
54
|
+
unless category.is_a? MerchantCategory
|
55
|
+
category = StarkInfra::Utils::API.from_api_json(resource_maker, category)
|
56
|
+
end
|
57
|
+
parsed_categories << category
|
58
|
+
end
|
59
|
+
parsed_categories
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.parse_countries(countries)
|
63
|
+
resource_maker = StarkInfra::MerchantCountry.resource[:resource_maker]
|
64
|
+
return countries if countries.nil?
|
65
|
+
|
66
|
+
parsed_countries = []
|
67
|
+
countries.each do |country|
|
68
|
+
unless country.is_a? MerchantCountry
|
69
|
+
country = StarkInfra::Utils::API.from_api_json(resource_maker, country)
|
70
|
+
end
|
71
|
+
parsed_countries << country
|
72
|
+
end
|
73
|
+
parsed_countries
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.parse_methods(methods)
|
77
|
+
resource_maker = StarkInfra::CardMethod.resource[:resource_maker]
|
78
|
+
return methods if methods.nil?
|
79
|
+
|
80
|
+
parsed_methods = []
|
81
|
+
methods.each do |method|
|
82
|
+
unless method.is_a? CardMethod
|
83
|
+
method = StarkInfra::Utils::API.from_api_json(resource_maker, method)
|
84
|
+
end
|
85
|
+
parsed_methods << method
|
86
|
+
end
|
87
|
+
parsed_methods
|
43
88
|
end
|
44
89
|
|
45
90
|
def self.parse_rules(rules)
|
46
|
-
parsed_rules = []
|
47
91
|
rule_maker = StarkInfra::IssuingRule.resource[:resource_maker]
|
48
92
|
return rules if rules.nil?
|
49
93
|
|
94
|
+
parsed_rules = []
|
50
95
|
rules.each do |rule|
|
51
|
-
|
52
|
-
|
53
|
-
next
|
96
|
+
unless rule.is_a? IssuingRule
|
97
|
+
rule = StarkInfra::Utils::API.from_api_json(rule_maker, rule)
|
54
98
|
end
|
55
|
-
parsed_rules
|
99
|
+
parsed_rules << rule
|
56
100
|
end
|
57
101
|
parsed_rules
|
58
102
|
end
|
@@ -62,16 +106,16 @@ module StarkInfra
|
|
62
106
|
resource_name: 'IssuingRule',
|
63
107
|
resource_maker: proc { |json|
|
64
108
|
IssuingRule.new(
|
65
|
-
name: json[
|
66
|
-
|
67
|
-
|
68
|
-
currency_code: json[
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
109
|
+
name: json['name'],
|
110
|
+
amount: json['amount'],
|
111
|
+
interval: json['interval'],
|
112
|
+
currency_code: json['currency_code'],
|
113
|
+
categories: json['categories'],
|
114
|
+
countries: json['countries'],
|
115
|
+
methods: json['methods'],
|
116
|
+
counter_amount: json['counter_amount'],
|
117
|
+
currency_symbol: json['currency_symbol'],
|
118
|
+
currency_name: json['currency_name']
|
75
119
|
)
|
76
120
|
}
|
77
121
|
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('../utils/resource')
|
4
3
|
require_relative('../utils/rest')
|
5
4
|
require_relative('../utils/checks')
|
5
|
+
require_relative('../utils/resource')
|
6
6
|
|
7
7
|
module StarkInfra
|
8
8
|
# # IssuingTransaction object
|
@@ -20,9 +20,7 @@ module StarkInfra
|
|
20
20
|
class IssuingTransaction < StarkInfra::Utils::Resource
|
21
21
|
attr_reader :id, :amount, :balance, :description, :source, :tags, :created
|
22
22
|
|
23
|
-
def initialize(
|
24
|
-
id: nil, amount: nil, balance: nil, description: nil, source: nil, tags: nil, created: nil
|
25
|
-
)
|
23
|
+
def initialize(id: nil, amount: nil, balance: nil, description: nil, source: nil, tags: nil, created: nil)
|
26
24
|
super(id)
|
27
25
|
@amount = amount
|
28
26
|
@balance = balance
|
@@ -54,11 +52,11 @@ module StarkInfra
|
|
54
52
|
#
|
55
53
|
# ## Parameters (optional):
|
56
54
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
57
|
-
# - external_ids [list of strings, default
|
55
|
+
# - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
|
58
56
|
# - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
59
57
|
# - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
60
58
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'approved', 'canceled', 'denied', 'confirmed' or 'voided'
|
61
|
-
# - ids [list of strings, default
|
59
|
+
# - ids [list of strings, default nil]: purchase IDs
|
62
60
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
63
61
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
64
62
|
#
|
@@ -87,12 +85,12 @@ module StarkInfra
|
|
87
85
|
# ## Parameters (optional):
|
88
86
|
# - cursor [string, default nil]: cursor returned on the previous page function call.
|
89
87
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
90
|
-
# - external_ids [list of strings, default nil: external IDs. ex: ['5656565656565656', '4545454545454545']
|
88
|
+
# - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
|
91
89
|
# - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
92
90
|
# - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
93
91
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'approved', 'canceled', 'denied', 'confirmed' or 'voided'
|
94
92
|
# - ids [list of strings, default nil]: purchase IDs
|
95
|
-
# - limit [integer, default
|
93
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
96
94
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
97
95
|
#
|
98
96
|
# ## Return:
|
@@ -1,21 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('../utils/resource')
|
4
3
|
require_relative('../utils/rest')
|
5
4
|
require_relative('../utils/checks')
|
5
|
+
require_relative('../utils/resource')
|
6
6
|
|
7
7
|
module StarkInfra
|
8
8
|
# # IssuingWithdrawal object
|
9
9
|
#
|
10
10
|
# The IssuingWithdrawal objects created in your Workspace return cash from your Issuing balance to your Banking balance.
|
11
11
|
#
|
12
|
+
# When you initialize a IssuingWithdrawal, the entity will not be automatically
|
13
|
+
# created in the Stark Infra API. The 'create' function sends the objects
|
14
|
+
# to the Stark Infra API and returns the created object.
|
15
|
+
#
|
12
16
|
# ## Parameters (required):
|
13
17
|
# - amount [integer]: IssuingWithdrawal value in cents. Minimum = 0 (any value will be accepted). ex: 1234 (= R$ 12.34)
|
14
18
|
# - external_id [string] IssuingWithdrawal external ID. ex: '12345'
|
15
19
|
# - description [string]: IssuingWithdrawal description. ex: 'sending money back'
|
16
20
|
#
|
17
21
|
# ## Parameters (optional):
|
18
|
-
# - tags [list of strings, default
|
22
|
+
# - tags [list of strings, default nil]: list of strings for tagging. ex: ['tony', 'stark']
|
19
23
|
#
|
20
24
|
# ## Attributes (return-only):
|
21
25
|
# - id [string]: unique id returned when IssuingWithdrawal is created. ex: '5656565656565656'
|
@@ -36,8 +40,8 @@ module StarkInfra
|
|
36
40
|
@tags = tags
|
37
41
|
@transaction_id = transaction_id
|
38
42
|
@issuing_transaction_id = issuing_transaction_id
|
39
|
-
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
40
43
|
@updated = StarkInfra::Utils::Checks.check_datetime(updated)
|
44
|
+
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
41
45
|
end
|
42
46
|
|
43
47
|
# # Create an IssuingWithdrawal
|
@@ -78,7 +82,7 @@ module StarkInfra
|
|
78
82
|
#
|
79
83
|
# ## Parameters (optional):
|
80
84
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
81
|
-
# - external_ids [list of strings, default
|
85
|
+
# - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
|
82
86
|
# - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
83
87
|
# - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
84
88
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
@@ -106,8 +110,8 @@ module StarkInfra
|
|
106
110
|
#
|
107
111
|
# ## Parameters (optional):
|
108
112
|
# - cursor [string, default nil]: cursor returned on the previous page function call.
|
109
|
-
# - limit [integer, default
|
110
|
-
# - external_ids [list of strings, default
|
113
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
114
|
+
# - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
|
111
115
|
# - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
112
116
|
# - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
113
117
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
@@ -136,11 +140,11 @@ module StarkInfra
|
|
136
140
|
resource_name: 'IssuingWithdrawal',
|
137
141
|
resource_maker: proc { |json|
|
138
142
|
IssuingWithdrawal.new(
|
143
|
+
id: json['id'],
|
139
144
|
amount: json['amount'],
|
140
145
|
external_id: json['external_id'],
|
141
146
|
description: json['description'],
|
142
147
|
tags: json['tags'],
|
143
|
-
id: json['id'],
|
144
148
|
transaction_id: json['transaction_id'],
|
145
149
|
issuing_transaction_id: json['issuing_transaction_id'],
|
146
150
|
updated: json['updated'],
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/rest')
|
4
|
+
require_relative('../utils/sub_resource')
|
5
|
+
|
6
|
+
module StarkInfra
|
7
|
+
# # MerchantCategory object
|
8
|
+
#
|
9
|
+
# MerchantCategory's codes and types are used to define categories filters in IssuingRules.
|
10
|
+
#
|
11
|
+
# A MerchantCategory filter must define exactly one parameter between code and type.
|
12
|
+
# A type, such as 'food', 'services', etc., defines an entire group of merchant codes,
|
13
|
+
# whereas a code only specifies a specific MCC.
|
14
|
+
#
|
15
|
+
# ## Parameters (conditionally required):
|
16
|
+
# - code [string, default nil]: category's code. ex: 'veterinaryServices', 'fastFoodRestaurants'
|
17
|
+
# - type [string, default nil]: category's type. ex: 'pets', 'food'
|
18
|
+
#
|
19
|
+
# Attributes (return-only):
|
20
|
+
# - name [string]: category's name. ex: 'Veterinary services', 'Fast food restaurants'
|
21
|
+
# - number [string]: category's number. ex: '742', '5814'
|
22
|
+
class MerchantCategory < StarkInfra::Utils::SubResource
|
23
|
+
attr_reader :code, :type, :name, :number
|
24
|
+
def initialize(code:, type:, name: nil, number: nil)
|
25
|
+
@code = code
|
26
|
+
@type = type
|
27
|
+
@name = name
|
28
|
+
@number = number
|
29
|
+
end
|
30
|
+
|
31
|
+
# # Retrieve MerchantCategories
|
32
|
+
#
|
33
|
+
# Receive a generator of MerchantCategory objects available in the Stark Infra API
|
34
|
+
#
|
35
|
+
# ## Parameters (optional):
|
36
|
+
# - search [string, default nil]: keyword to search for code, name, number or short_code
|
37
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
38
|
+
#
|
39
|
+
# ## Return:
|
40
|
+
# - generator of MerchantCategory objects with updated attributes
|
41
|
+
def self.query(search: nil, user: nil)
|
42
|
+
StarkInfra::Utils::Rest.get_stream(
|
43
|
+
search: search,
|
44
|
+
user: user,
|
45
|
+
**resource
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.resource
|
50
|
+
{
|
51
|
+
resource_name: 'MerchantCategory',
|
52
|
+
resource_maker: proc { |json|
|
53
|
+
MerchantCategory.new(
|
54
|
+
code: json['code'],
|
55
|
+
type: json['type'],
|
56
|
+
name: json['name'],
|
57
|
+
number: json['number']
|
58
|
+
)
|
59
|
+
}
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/rest')
|
4
|
+
require_relative('../utils/sub_resource')
|
5
|
+
|
6
|
+
module StarkInfra
|
7
|
+
# # MerchantCountry object
|
8
|
+
#
|
9
|
+
# MerchantCountry's codes are used to define countries filters in IssuingRules.
|
10
|
+
#
|
11
|
+
# ## Parameters (required):
|
12
|
+
# - code [string]: country's code. ex: 'BRA'
|
13
|
+
#
|
14
|
+
# Attributes (return-only):
|
15
|
+
# - name [string]: country's name. ex: 'Brazil'
|
16
|
+
# - number [string]: country's number. ex: '076'
|
17
|
+
# - short_code [string]: country's short code. ex: 'BR'
|
18
|
+
class MerchantCountry < StarkInfra::Utils::SubResource
|
19
|
+
attr_reader :code, :short_code, :name, :number
|
20
|
+
def initialize(code:, name: nil, number: nil, short_code: nil)
|
21
|
+
@code = code
|
22
|
+
@name = name
|
23
|
+
@number = number
|
24
|
+
@short_code = short_code
|
25
|
+
end
|
26
|
+
|
27
|
+
# # Retrieve MerchantCountries
|
28
|
+
#
|
29
|
+
# Receive a generator of MerchantCountry objects available in the Stark Infra API
|
30
|
+
#
|
31
|
+
# ## Parameters (optional):
|
32
|
+
# - search [string, default nil]: keyword to search for code, name, number or short_code
|
33
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
34
|
+
#
|
35
|
+
# ## Return:
|
36
|
+
# - generator of MerchantCountry objects with updated attributes
|
37
|
+
def self.query(search: nil, user: nil)
|
38
|
+
StarkInfra::Utils::Rest.get_stream(
|
39
|
+
search: search,
|
40
|
+
user: user,
|
41
|
+
**resource
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.resource
|
46
|
+
{
|
47
|
+
resource_name: 'MerchantCountry',
|
48
|
+
resource_maker: proc { |json|
|
49
|
+
MerchantCountry.new(
|
50
|
+
code: json['code'],
|
51
|
+
name: json['name'],
|
52
|
+
number: json['number'],
|
53
|
+
short_code: json['short_code']
|
54
|
+
)
|
55
|
+
}
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('../utils/resource')
|
4
3
|
require_relative('../utils/rest')
|
5
4
|
require_relative('../utils/checks')
|
5
|
+
require_relative('../utils/resource')
|
6
6
|
|
7
7
|
module StarkInfra
|
8
8
|
# # PixBalance object
|
@@ -18,8 +18,8 @@ module StarkInfra
|
|
18
18
|
# - currency [string]: currency of the current workspace. Expect others to be added eventually. ex: 'BRL'
|
19
19
|
# - updated [DateTime]: latest update datetime for the balance. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
20
20
|
class PixBalance < StarkInfra::Utils::Resource
|
21
|
-
attr_reader :amount, :currency, :updated
|
22
|
-
def initialize(
|
21
|
+
attr_reader :id, :amount, :currency, :updated
|
22
|
+
def initialize(id: nil, amount: nil, currency: nil, updated: nil)
|
23
23
|
super(id)
|
24
24
|
@amount = amount
|
25
25
|
@currency = currency
|
@@ -44,10 +44,10 @@ module StarkInfra
|
|
44
44
|
resource_name: 'PixBalance',
|
45
45
|
resource_maker: proc { |json|
|
46
46
|
PixBalance.new(
|
47
|
+
id: json['id'],
|
47
48
|
amount: json['amount'],
|
48
49
|
currency: json['currency'],
|
49
|
-
updated: json['updated']
|
50
|
-
id: json['id']
|
50
|
+
updated: json['updated']
|
51
51
|
)
|
52
52
|
}
|
53
53
|
}
|
data/lib/pixchargeback/log.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('
|
3
|
+
require_relative('pixchargeback')
|
4
4
|
require_relative('../utils/rest')
|
5
5
|
require_relative('../utils/checks')
|
6
|
-
require_relative('
|
6
|
+
require_relative('../utils/resource')
|
7
7
|
|
8
8
|
module StarkInfra
|
9
9
|
class PixChargeback
|
@@ -44,7 +44,7 @@ module StarkInfra
|
|
44
44
|
def self.get(id, user: nil)
|
45
45
|
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
# # Retrieve Logs
|
49
49
|
#
|
50
50
|
# Receive a generator of Log objects previously created in the Stark Infra API
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('../utils/resource')
|
4
3
|
require_relative('../utils/rest')
|
5
4
|
require_relative('../utils/checks')
|
5
|
+
require_relative('../utils/resource')
|
6
6
|
|
7
7
|
module StarkInfra
|
8
8
|
# # PixChargeback object
|
@@ -10,8 +10,10 @@ module StarkInfra
|
|
10
10
|
# A Pix chargeback can be created when fraud is detected on a transaction or a system malfunction
|
11
11
|
# results in an erroneous transaction.
|
12
12
|
# It notifies another participant of your request to reverse the payment they have received.
|
13
|
+
#
|
13
14
|
# When you initialize a PixChargeback, the entity will not be automatically
|
14
15
|
# created in the Stark Infra API. The 'create' function sends the objects
|
16
|
+
# to the Stark Infra API and returns the created object.
|
15
17
|
#
|
16
18
|
# ## Parameters (required):
|
17
19
|
# - amount [integer]: amount in cents to be reversed. ex: 11234 (= R$ 112.34)
|
@@ -20,40 +22,41 @@ module StarkInfra
|
|
20
22
|
#
|
21
23
|
# ## Parameters (optional):
|
22
24
|
# - description [string, default nil]: description for the PixChargeback. ex: 'Payment for service #1234'
|
25
|
+
# - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
|
23
26
|
#
|
24
27
|
# ## Attributes (return-only):
|
25
|
-
# - id [string]: unique id returned when PixChargeback is created. ex: '5656565656565656'
|
28
|
+
# - id [string]: unique id returned when the PixChargeback is created. ex: '5656565656565656'
|
26
29
|
# - analysis [string]: analysis that led to the result.
|
27
|
-
# - bacen_id [string]: central bank's unique UUID that identifies the PixChargeback.
|
28
30
|
# - sender_bank_code [string]: bank_code of the Pix participant that created the PixChargeback. ex: '20018183'
|
29
31
|
# - receiver_bank_code [string]: bank_code of the Pix participant that received the PixChargeback. ex: '20018183'
|
30
32
|
# - rejection_reason [string]: reason for the rejection of the Pix chargeback. Options: 'noBalance', 'accountClosed', 'unableToReverse'
|
31
33
|
# - reversal_reference_id [string]: return id of the reversal transaction. ex: 'D20018183202202030109X3OoBHG74wo'.
|
32
|
-
# - id [string]: unique id returned when the PixChargeback is created. ex: '5656565656565656'
|
33
34
|
# - result [string]: result after the analysis of the PixChargeback by the receiving party. Options: 'rejected', 'accepted', 'partiallyAccepted'
|
35
|
+
# - flow [string]: direction of the Pix Chargeback. Options: 'in' for received chargebacks, 'out' for chargebacks you requested
|
34
36
|
# - status [string]: current PixChargeback status. Options: 'created', 'failed', 'delivered', 'closed', 'canceled'.
|
35
37
|
# - created [DateTime]: creation datetime for the PixChargeback. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
36
38
|
# - updated [DateTime]: latest update datetime for the PixChargeback. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
37
39
|
class PixChargeback < StarkInfra::Utils::Resource
|
38
|
-
attr_reader :amount, :reference_id, :reason, :description, :
|
39
|
-
:receiver_bank_code, :rejection_reason, :reversal_reference_id, :result, :status, :created, :updated
|
40
|
+
attr_reader :amount, :reference_id, :reason, :description, :tags, :id, :analysis, :sender_bank_code,
|
41
|
+
:receiver_bank_code, :rejection_reason, :reversal_reference_id, :result, :flow, :status, :created, :updated
|
40
42
|
def initialize(
|
41
|
-
amount:, reference_id:, reason:, description: nil, id: nil, analysis: nil,
|
42
|
-
|
43
|
-
|
43
|
+
amount:, reference_id:, reason:, description: nil, tags: nil, id: nil, analysis: nil, sender_bank_code: nil,
|
44
|
+
receiver_bank_code: nil, rejection_reason: nil, reversal_reference_id: nil, result: nil, flow: nil, status: nil,
|
45
|
+
created: nil, updated: nil
|
44
46
|
)
|
45
47
|
super(id)
|
46
48
|
@amount = amount
|
47
49
|
@reference_id = reference_id
|
48
50
|
@reason = reason
|
49
51
|
@description = description
|
52
|
+
@tags = tags
|
50
53
|
@analysis = analysis
|
51
|
-
@bacen_id = bacen_id
|
52
54
|
@sender_bank_code = sender_bank_code
|
53
55
|
@receiver_bank_code = receiver_bank_code
|
54
56
|
@rejection_reason = rejection_reason
|
55
57
|
@reversal_reference_id = reversal_reference_id
|
56
58
|
@result = result
|
59
|
+
@flow = flow
|
57
60
|
@status = status
|
58
61
|
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
59
62
|
@updated = StarkInfra::Utils::Checks.check_datetime(updated)
|
@@ -61,10 +64,10 @@ module StarkInfra
|
|
61
64
|
|
62
65
|
# # Create PixChargebacks
|
63
66
|
#
|
64
|
-
#
|
67
|
+
# Create PixChargebacks in the Stark Infra API
|
65
68
|
#
|
66
69
|
# ## Parameters (required):
|
67
|
-
# - chargebacks [list of PixChargeback objects]: list of PixChargeback objects to be created in the API.
|
70
|
+
# - chargebacks [list of PixChargeback objects]: list of PixChargeback objects to be created in the API.
|
68
71
|
#
|
69
72
|
# ## Parameters (optional):
|
70
73
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
@@ -75,9 +78,9 @@ module StarkInfra
|
|
75
78
|
StarkInfra::Utils::Rest.post(entities: chargebacks, user: user, **resource)
|
76
79
|
end
|
77
80
|
|
78
|
-
# # Retrieve a
|
81
|
+
# # Retrieve a PixChargeback object
|
79
82
|
#
|
80
|
-
#
|
83
|
+
# Retrieve a PixChargeback object linked to your Workspace in the Stark Infra API using its id.
|
81
84
|
#
|
82
85
|
# ## Parameters (required):
|
83
86
|
# - id [string]: object unique id. ex: '5656565656565656'
|
@@ -101,11 +104,13 @@ module StarkInfra
|
|
101
104
|
# - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
|
102
105
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
|
103
106
|
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
107
|
+
# - flow [string, default nil]: direction of the Pix Chargeback. Options: 'in' for received chargebacks, 'out' for chargebacks you requested
|
108
|
+
# - tags [list of strings, default nil]: filter for tags of retrieved objects. ex: ['travel', 'food']
|
104
109
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
105
110
|
#
|
106
111
|
# ## Return:
|
107
112
|
# - generator of PixChargeback objects with updated attributes
|
108
|
-
def self.query(limit: nil, after: nil, before: nil, status: nil, ids: nil, user: nil)
|
113
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, ids: nil, flow: nil, tags: nil, user: nil)
|
109
114
|
after = StarkInfra::Utils::Checks.check_date(after)
|
110
115
|
before = StarkInfra::Utils::Checks.check_date(before)
|
111
116
|
StarkInfra::Utils::Rest.get_stream(
|
@@ -114,6 +119,8 @@ module StarkInfra
|
|
114
119
|
before: before,
|
115
120
|
status: status,
|
116
121
|
ids: ids,
|
122
|
+
flow: flow,
|
123
|
+
tags: tags,
|
117
124
|
user: user,
|
118
125
|
**resource
|
119
126
|
)
|
@@ -131,12 +138,14 @@ module StarkInfra
|
|
131
138
|
# - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
|
132
139
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
|
133
140
|
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
141
|
+
# - flow [string, default nil]: direction of the Pix Chargeback. Options: 'in' for received chargebacks, 'out' for chargebacks you requested
|
142
|
+
# - tags [list of strings, default nil]: filter for tags of retrieved objects. ex: ['travel', 'food']
|
134
143
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
135
144
|
#
|
136
145
|
# ## Return:
|
137
146
|
# - list of PixChargeback objects with updated attributes
|
138
147
|
# - cursor to retrieve the next page of PixChargeback objects
|
139
|
-
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil, user: nil)
|
148
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil, flow: nil, tags: nil, user: nil)
|
140
149
|
after = StarkInfra::Utils::Checks.check_date(after)
|
141
150
|
before = StarkInfra::Utils::Checks.check_date(before)
|
142
151
|
StarkInfra::Utils::Rest.get_page(
|
@@ -146,6 +155,8 @@ module StarkInfra
|
|
146
155
|
before: before,
|
147
156
|
status: status,
|
148
157
|
ids: ids,
|
158
|
+
flow: flow,
|
159
|
+
tags: tags,
|
149
160
|
user: user,
|
150
161
|
**resource
|
151
162
|
)
|
@@ -157,7 +168,7 @@ module StarkInfra
|
|
157
168
|
#
|
158
169
|
# ## Parameters (required):
|
159
170
|
# - id [string]: PixChargeback unique id. ex: '5656565656565656'
|
160
|
-
# - result [string]: result of the PixChargeback. Options: 'rejected', 'accepted', 'partiallyAccepted'.
|
171
|
+
# - result [string]: result after the analysis of the PixChargeback. Options: 'rejected', 'accepted', 'partiallyAccepted'.
|
161
172
|
#
|
162
173
|
# ## Parameters (conditionally required):
|
163
174
|
# - rejection_reason [string, default nil]: if the PixChargeback is rejected a reason is required. Options: 'noBalance', 'accountClosed', 'unableToReverse',
|
@@ -174,8 +185,8 @@ module StarkInfra
|
|
174
185
|
id: id,
|
175
186
|
result: result,
|
176
187
|
rejection_reason: rejection_reason,
|
177
|
-
analysis: analysis,
|
178
188
|
reversal_reference_id: reversal_reference_id,
|
189
|
+
analysis: analysis,
|
179
190
|
user: user,
|
180
191
|
**resource
|
181
192
|
)
|
@@ -202,18 +213,19 @@ module StarkInfra
|
|
202
213
|
resource_name: 'PixChargeback',
|
203
214
|
resource_maker: proc { |json|
|
204
215
|
PixChargeback.new(
|
216
|
+
id: json['id'],
|
205
217
|
amount: json['amount'],
|
206
218
|
reference_id: json['reference_id'],
|
207
219
|
reason: json['reason'],
|
208
220
|
description: json['description'],
|
209
|
-
|
221
|
+
tags: json['tags'],
|
210
222
|
analysis: json['analysis'],
|
211
|
-
bacen_id: json['bacen_id'],
|
212
223
|
sender_bank_code: json['sender_bank_code'],
|
213
224
|
receiver_bank_code: json['receiver_bank_code'],
|
214
225
|
rejection_reason: json['rejection_reason'],
|
215
226
|
reversal_reference_id: json['reversal_reference_id'],
|
216
227
|
result: json['result'],
|
228
|
+
flow: json['flow'],
|
217
229
|
status: json['status'],
|
218
230
|
created: json['created'],
|
219
231
|
updated: json['updated']
|