starkbank 2.9.0 → 2.10.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/corporate_purchase/log.rb +5 -2
- data/lib/corporate_rule/corporaterule.rb +5 -2
- data/lib/darf_payment/darf_payment.rb +1 -1
- data/lib/invoice/invoice.rb +5 -2
- data/lib/invoice/rule.rb +46 -0
- data/lib/starkbank.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b3c14df2e63024dc300445af57b93d5d7c03fbe7e40efc79f4b130684982118
|
4
|
+
data.tar.gz: 621f032aa81a0c42d8d8df9491d5c66dfa1938207a9f68920d0f4abe7356cdef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e8317904c404ed9a8051169e0079d705224bbea35cf7c735b3f164c955cf212494c76fb3fbfbc74f0f75b89c7b55194ffac31e0efde0b2002ddb886029930b6
|
7
|
+
data.tar.gz: 6f9c6037b10ae646945aa1163b5e64fb7ac70303767a12976a91ffa167bd8453dd7b0f7b32fece994bc6b976632ee67a5860c24a215135129ea4b535d354cdff
|
@@ -14,15 +14,17 @@ module StarkBank
|
|
14
14
|
# ## Attributes (return-only):
|
15
15
|
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
16
16
|
# - purchase [CorporatePurchase]: CorporatePurchase entity to which the log refers to.
|
17
|
+
# - description [string]: purchase descriptions. ex: 'my_description'
|
17
18
|
# - corporate_transaction_id [string]: transaction ID related to the CorporateCard.
|
18
19
|
# - errors [list of strings]: list of errors linked to this CorporatePurchase event
|
19
20
|
# - type [string]: type of the CorporatePurchase event which triggered the log creation. ex: 'approved', 'canceled', 'confirmed', 'denied', 'reversed', 'voided'.
|
20
21
|
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
21
22
|
class Log < StarkCore::Utils::Resource
|
22
|
-
attr_reader :id, :purchase, :corporate_transaction_id, :errors, :type, :created
|
23
|
-
def initialize(id: nil, purchase: nil, corporate_transaction_id: nil, errors: nil, type: nil, created: nil)
|
23
|
+
attr_reader :id, :purchase, :description, :corporate_transaction_id, :errors, :type, :created
|
24
|
+
def initialize(id: nil, purchase: nil, description: nil, corporate_transaction_id: nil, errors: nil, type: nil, created: nil)
|
24
25
|
super(id)
|
25
26
|
@purchase = purchase
|
27
|
+
@description = description
|
26
28
|
@corporate_transaction_id = corporate_transaction_id
|
27
29
|
@errors = errors
|
28
30
|
@type = type
|
@@ -117,6 +119,7 @@ module StarkBank
|
|
117
119
|
Log.new(
|
118
120
|
id: json['id'],
|
119
121
|
purchase: StarkCore::Utils::API.from_api_json(request_maker, json['purchase']),
|
122
|
+
description: json['description'],
|
120
123
|
corporate_transaction_id: json['corporate_transaction_id'],
|
121
124
|
errors: json['errors'],
|
122
125
|
type: json['type'],
|
@@ -14,6 +14,7 @@ module StarkBank
|
|
14
14
|
# ## Parameters (optional):
|
15
15
|
# - interval [string, default 'lifetime']: interval after which the rule amount counter will be reset to 0. ex: 'instant', 'day', 'week', 'month', 'year' or 'lifetime'
|
16
16
|
# - schedule [string, default nil]: schedule time for user to spend. ex: "every monday, wednesday from 00:00 to 23:59 in America/Sao_Paulo"
|
17
|
+
# - purposes [list of string, default []]: list of strings representing the allowed purposes for card purchases, you can use this to restrict ATM withdrawals. ex: ["purchase", "withdrawal"]
|
17
18
|
# - currency_code [string, default 'BRL']: code of the currency that the rule amount refers to. ex: 'BRL' or 'USD'
|
18
19
|
# - categories [list of MerchantCategories, default nil]: merchant categories accepted by the rule. ex: [MerchantCategory(code='fastFoodRestaurants')]
|
19
20
|
# - countries [list of MerchantCountries, default nil]: countries accepted by the rule. ex: [MerchantCountry(code='BRA')]
|
@@ -25,10 +26,10 @@ module StarkBank
|
|
25
26
|
# - currency_symbol [string]: currency symbol. ex: 'R$'
|
26
27
|
# - currency_name [string]: currency name. ex: 'Brazilian Real'
|
27
28
|
class CorporateRule < StarkCore::Utils::Resource
|
28
|
-
attr_reader :name, :interval, :amount, :currency_code, :counter_amount, :currency_name, :currency_symbol,
|
29
|
+
attr_reader :name, :interval, :amount, :currency_code, :counter_amount, :schedule, :purposes, :currency_name, :currency_symbol,
|
29
30
|
:categories, :countries, :methods
|
30
31
|
def initialize(
|
31
|
-
name:, amount:, id: nil, interval: nil, schedule: nil, currency_code: nil, categories: nil, countries: nil, methods: nil,
|
32
|
+
name:, amount:, id: nil, interval: nil, schedule: nil, purposes: nil, currency_code: nil, categories: nil, countries: nil, methods: nil,
|
32
33
|
counter_amount: nil, currency_symbol: nil, currency_name: nil
|
33
34
|
)
|
34
35
|
super(id)
|
@@ -36,6 +37,7 @@ module StarkBank
|
|
36
37
|
@amount = amount
|
37
38
|
@interval = interval
|
38
39
|
@schedule = schedule
|
40
|
+
@purposes = purposes
|
39
41
|
@currency_code = currency_code
|
40
42
|
@categories = CorporateRule.parse_categories(categories)
|
41
43
|
@countries = CorporateRule.parse_categories(countries)
|
@@ -110,6 +112,7 @@ module StarkBank
|
|
110
112
|
amount: json['amount'],
|
111
113
|
interval: json['interval'],
|
112
114
|
schedule: json['schedule'],
|
115
|
+
purposes: json['purposes'],
|
113
116
|
currency_code: json['currency_code'],
|
114
117
|
categories: json['categories'],
|
115
118
|
countries: json['countries'],
|
@@ -56,7 +56,7 @@ module StarkBank
|
|
56
56
|
@amount = amount
|
57
57
|
@nominal_amount = nominal_amount
|
58
58
|
@fee = fee
|
59
|
-
@transaction_ids =
|
59
|
+
@transaction_ids = transaction_ids
|
60
60
|
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
61
61
|
@created = StarkCore::Utils::Checks.check_datetime(created)
|
62
62
|
end
|
data/lib/invoice/invoice.rb
CHANGED
@@ -24,6 +24,7 @@ module StarkBank
|
|
24
24
|
# - fine [float, default 0.0]: Invoice fine for overdue payment in %. ex: 2.5
|
25
25
|
# - interest [float, default 0.0]: Invoice monthly interest for overdue payment in %. ex: 5.2
|
26
26
|
# - discounts [list of hashes, default nil]: list of hashes with 'percentage':float and 'due':DateTime or string pairs
|
27
|
+
# - rules [list of Invoice::Rule, default []]: list of Invoice::Rule objects for modifying invoice behavior. ex: [Invoice::Rule(key="allowedTaxIds", value=[ "012.345.678-90", "45.059.493/0001-73" ])]
|
27
28
|
# - descriptions [list of hashes, default nil]: list of hashes with 'key':string and 'value':string pairs
|
28
29
|
# - tags [list of strings, default nil]: list of strings for tagging
|
29
30
|
#
|
@@ -42,9 +43,9 @@ module StarkBank
|
|
42
43
|
# - created [DateTime]: creation datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
43
44
|
# - updated [DateTime]: latest update datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
44
45
|
class Invoice < StarkCore::Utils::Resource
|
45
|
-
attr_reader :amount, :tax_id, :name, :due, :expiration, :fine, :interest, :discounts, :tags, :pdf, :link, :descriptions, :nominal_amount, :fine_amount, :interest_amount, :discount_amount, :id, :brcode, :fee, :status, :transaction_ids, :created, :updated
|
46
|
+
attr_reader :amount, :tax_id, :name, :due, :expiration, :fine, :interest, :discounts, :rules, :tags, :pdf, :link, :descriptions, :nominal_amount, :fine_amount, :interest_amount, :discount_amount, :id, :brcode, :fee, :status, :transaction_ids, :created, :updated
|
46
47
|
def initialize(
|
47
|
-
amount:, tax_id:, name:, due: nil, expiration: nil, fine: nil, interest: nil, discounts: nil,
|
48
|
+
amount:, tax_id:, name:, due: nil, expiration: nil, fine: nil, interest: nil, discounts: nil, rules: nil,
|
48
49
|
tags: nil, pdf: nil, link: nil, descriptions: nil, nominal_amount: nil, fine_amount: nil, interest_amount: nil,
|
49
50
|
discount_amount: nil, id: nil, brcode: nil, fee: nil, status: nil, transaction_ids: nil, created: nil, updated: nil
|
50
51
|
)
|
@@ -60,6 +61,7 @@ module StarkBank
|
|
60
61
|
@pdf = pdf
|
61
62
|
@link = link
|
62
63
|
@descriptions = descriptions
|
64
|
+
@rules = StarkBank::Invoice::Rule.parse_rules(rules)
|
63
65
|
@nominal_amount = nominal_amount
|
64
66
|
@fine_amount = fine_amount
|
65
67
|
@interest_amount = interest_amount
|
@@ -256,6 +258,7 @@ module StarkBank
|
|
256
258
|
fine: json['fine'],
|
257
259
|
interest: json['interest'],
|
258
260
|
discounts: json['discounts'],
|
261
|
+
rules: json['rules'],
|
259
262
|
tags: json['tags'],
|
260
263
|
pdf: json['pdf'],
|
261
264
|
link: json['link'],
|
data/lib/invoice/rule.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative('../utils/rest')
|
2
|
+
|
3
|
+
module StarkBank
|
4
|
+
class Invoice
|
5
|
+
# # Invoice::Rule object
|
6
|
+
#
|
7
|
+
# The Invoice::Rule object modifies the behavior of Invoice objects when passed as an argument upon their creation.
|
8
|
+
#
|
9
|
+
# ## Parameters (required):
|
10
|
+
# - key [string]: Rule to be customized, describes what Invoice behavior will be altered. ex: "allowedTaxIds"
|
11
|
+
# - value [list of string]: Value of the rule. ex: ['012.345.678-90', '45.059.493/0001-73']
|
12
|
+
class Rule < StarkCore::Utils::SubResource
|
13
|
+
attr_reader :key, :value
|
14
|
+
def initialize(key:, value:)
|
15
|
+
@key = key
|
16
|
+
@value = value
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.parse_rules(rules)
|
20
|
+
resource_maker = StarkBank::Invoice::Rule.resource[:resource_maker]
|
21
|
+
return rules if rules.nil?
|
22
|
+
|
23
|
+
parsed_rules = []
|
24
|
+
rules.each do |rule|
|
25
|
+
unless rule.is_a? Rule
|
26
|
+
rule = StarkCore::Utils::API.from_api_json(resource_maker, rule)
|
27
|
+
end
|
28
|
+
parsed_rules << rule
|
29
|
+
end
|
30
|
+
return parsed_rules
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.resource
|
34
|
+
{
|
35
|
+
resource_name: 'Rule',
|
36
|
+
resource_maker: proc { |json|
|
37
|
+
Rule.new(
|
38
|
+
key: json['key'],
|
39
|
+
value: json['value']
|
40
|
+
)
|
41
|
+
}
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/starkbank.rb
CHANGED
@@ -5,6 +5,7 @@ require_relative('balance/balance')
|
|
5
5
|
require_relative('transaction/transaction')
|
6
6
|
require_relative('invoice/invoice')
|
7
7
|
require_relative('invoice/log')
|
8
|
+
require_relative('invoice/rule')
|
8
9
|
require_relative('invoice/payment')
|
9
10
|
require_relative('dict_key/dict_key')
|
10
11
|
require_relative('dynamic_brcode/dynamic_brcode')
|
@@ -58,7 +59,7 @@ require_relative('institution/institution')
|
|
58
59
|
module StarkBank
|
59
60
|
|
60
61
|
API_VERSION = 'v2'
|
61
|
-
SDK_VERSION = '2.
|
62
|
+
SDK_VERSION = '2.10.0'
|
62
63
|
HOST = "bank"
|
63
64
|
public_constant :API_VERSION, :SDK_VERSION, :HOST;
|
64
65
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starkbank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- starkbank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: starkcore
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/invoice/invoice.rb
|
109
109
|
- lib/invoice/log.rb
|
110
110
|
- lib/invoice/payment.rb
|
111
|
+
- lib/invoice/rule.rb
|
111
112
|
- lib/merchant_category/merchantcategory.rb
|
112
113
|
- lib/merchant_country/merchantcountry.rb
|
113
114
|
- lib/payment_preview/boleto_preview.rb
|