starkbank 2.9.0 → 2.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0dc58311d66ee8900115301e82e6ffdeb7ff667b845a67c7ec42de2d00533ed
4
- data.tar.gz: ff84f801db89c14d69e21e287ace3f804c1aed4ca8bd5ea546a5047aec6c221e
3
+ metadata.gz: 9571bfbacd93d4716d5e3b0135d3db8ec76caa565938f602f44e43ab717c7dff
4
+ data.tar.gz: 288fedf58500ee29541406ede7b9c102063ca4967138a09a81f017ceaf52ba03
5
5
  SHA512:
6
- metadata.gz: 4456311856c14f16b8076060fececadb8437b8f379f7ed725a1655381e1dec5ba4f970878c3e1bc12b9569be766e638c8c2667bf29e6ea75d061c2b1b8d50a41
7
- data.tar.gz: 5f4293cc4fe23711f6bd1b015771dfb5fb4949803c810fd60eb1f12e1af4361936ff1e6388cebe96e660c6fa8d9e8e4cbe092d885f8282af61024e4fb5b8db57
6
+ metadata.gz: e98c7542080e894d92dfbcd88dbaefd08823bb5339f5b5957e2d32760a92f06c8a2f04f816b78ed5f1cddd0de1a2c53d6093efea11f9a11d98ab61982c28278c
7
+ data.tar.gz: 94df51cee5a7b90b7ed502882aaf7ad5c373255c0db7f5744fe20ba8ff9f73089574d90e7081f29670241f2ea6684cd97a0657dcc461b20a4dff60fa850465e6
@@ -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 = @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
@@ -18,19 +18,13 @@ module StarkBank
18
18
  # - owner_type [string]: DICT key owner type. ex 'naturalPerson' or 'legalPerson'
19
19
  # - bank_name [string]: bank name associated with the DICT key. ex: 'Stark Bank'
20
20
  # - ispb [string]: bank ISPB associated with the DICT key. ex: '20018183'
21
- # - branch_code [string]: bank account branch code associated with the DICT key. ex: '9585'
22
- # - account_number [string]: bank account number associated with the DICT key. ex: '9828282578010513'
23
- # - account_type [string]: bank account type associated with the DICT key. ex: 'checking', 'saving', 'salary' or 'payment'
21
+ # - branch_code [string]: encrypted bank account branch code associated with the DICT key. ex: 'ZW5jcnlwdGVkLWJyYW5jaC1jb2Rl'
22
+ # - account_number [string]: encrypted bank account number associated with the DICT key. ex: 'ZW5jcnlwdGVkLWFjY291bnQtbnVtYmVy'
23
+ # - account_type [string]: bank account type associated with the DICT key. ex: 'checking', 'savings', 'salary' or 'payment'
24
24
  # - status [string]: current DICT key status. ex: 'created', 'registered', 'canceled' or 'failed'
25
- # - account_created [DateTime or string]: creation datetime of the bank account associated with the DICT key. ex: '2020-11-05T14:55:08.812665+00:00'
26
- # - owned [DateTime or string]: datetime since when the current owner hold this DICT key. ex : '2020-11-05T14:55:08.812665+00:00'
27
- # - created [DateTime or string]: creation datetime for the DICT key. ex: '2020-03-10 10:30:00.000'
28
25
  class DictKey < StarkCore::Utils::Resource
29
26
  attr_reader :id, :type, :name, :tax_id, :owner_type, :bank_name, :ispb, :branch_code, :account_number, :account_type, :status, :account_created, :owned, :created
30
- def initialize(
31
- id:, type:, name:, tax_id:, owner_type:, bank_name:, ispb:, branch_code:, account_number:,
32
- account_type:, status:, account_created:, owned:, created:
33
- )
27
+ def initialize(id:, type:, name:, tax_id:, owner_type:, bank_name:, ispb:, branch_code:, account_number:, account_type:, status:)
34
28
  super(id)
35
29
  @type = type
36
30
  @name = name
@@ -42,9 +36,6 @@ module StarkBank
42
36
  @account_number = account_number
43
37
  @account_type = account_type
44
38
  @status = status
45
- @account_created = StarkCore::Utils::Checks.check_datetime(account_created)
46
- @owned = StarkCore::Utils::Checks.check_datetime(owned)
47
- @created = StarkCore::Utils::Checks.check_datetime(created)
48
39
  end
49
40
 
50
41
  # # Retrieve a specific DictKey
@@ -141,10 +132,7 @@ module StarkBank
141
132
  branch_code: json['branch_code'],
142
133
  account_number: json['account_number'],
143
134
  type: json['type'],
144
- status: json['status'],
145
- account_created: json['account_created'],
146
- owned: json['owned'],
147
- created: json['created']
135
+ status: json['status']
148
136
  )
149
137
  }
150
138
  }
@@ -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'],
@@ -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
@@ -14,8 +14,6 @@ module StarkBank
14
14
  # - name [string]: Payment receiver name. ex: 'Tony Stark'
15
15
  # - tax_id [string]: Payment receiver tax ID. ex: '012.345.678-90'
16
16
  # - bank_code [string]: Payment receiver bank code. ex: '20018183'
17
- # - branch_code [string]: Payment receiver branch code. ex: '0001'
18
- # - account_number [string]: Payment receiver account number. ex: '1234567'
19
17
  # - account_type [string]: Payment receiver account type. ex: 'checking'
20
18
  # - allow_change [bool]: If True, the payment is able to receive amounts that are different from the nominal one. ex: True or False
21
19
  # - amount [integer]: Value in cents that this payment is expecting to receive. If 0, any value is accepted. ex: 123 (= R$1,23)
@@ -26,14 +24,12 @@ module StarkBank
26
24
  # - discount_amount [integer]: Current discount value in cents that this payment is expecting. ex: 123 (= R$1,23)
27
25
  # - reconciliation_id [string]: Reconciliation ID linked to this payment. ex: 'txId', 'payment-123'
28
26
  class BrcodePreview < StarkCore::Utils::SubResource
29
- attr_reader :status, :name, :tax_id, :bank_code, :branch_code, :account_number, :account_type, :allow_change, :amount, :nominal_amount, :interest_amount, :fine_amount, :reduction_amount, :discount_amount, :reconciliation_id
30
- def initialize(status:, name:, tax_id:, bank_code:, branch_code:, account_number:, account_type:, allow_change:, amount:, nominal_amount:, interest_amount:, fine_amount:, reduction_amount:, discount_amount:, reconciliation_id:)
27
+ attr_reader :status, :name, :tax_id, :bank_code, :account_type, :allow_change, :amount, :nominal_amount, :interest_amount, :fine_amount, :reduction_amount, :discount_amount, :reconciliation_id
28
+ def initialize(status:, name:, tax_id:, bank_code:, account_type:, allow_change:, amount:, nominal_amount:, interest_amount:, fine_amount:, reduction_amount:, discount_amount:, reconciliation_id:)
31
29
  @status = status
32
30
  @name = name
33
31
  @tax_id = tax_id
34
32
  @bank_code = bank_code
35
- @branch_code = branch_code
36
- @account_number = account_number
37
33
  @account_type = account_type
38
34
  @allow_change = allow_change
39
35
  @amount = amount
@@ -54,8 +50,6 @@ module StarkBank
54
50
  name: json['name'],
55
51
  tax_id: json['tax_id'],
56
52
  bank_code: json['bank_code'],
57
- branch_code: json['branch_code'],
58
- account_number: json['account_number'],
59
53
  account_type: json['account_type'],
60
54
  allow_change: json['allow_change'],
61
55
  amount: json['amount'],
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.9.0'
62
+ SDK_VERSION = '2.11.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.9.0
4
+ version: 2.11.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-04 00:00:00.000000000 Z
11
+ date: 2023-09-18 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