starkbank 2.6.0 → 2.8.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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/lib/balance/balance.rb +8 -8
  3. data/lib/boleto/boleto.rb +22 -19
  4. data/lib/boleto/log.rb +10 -10
  5. data/lib/boleto_holmes/boleto_holmes.rb +14 -14
  6. data/lib/boleto_holmes/log.rb +16 -13
  7. data/lib/boleto_payment/boleto_payment.rb +21 -18
  8. data/lib/boleto_payment/log.rb +10 -10
  9. data/lib/brcode_payment/brcode_payment.rb +23 -20
  10. data/lib/brcode_payment/log.rb +10 -10
  11. data/lib/brcode_payment/rule.rb +49 -0
  12. data/lib/darf_payment/darf_payment.rb +23 -21
  13. data/lib/darf_payment/log.rb +10 -10
  14. data/lib/deposit/deposit.rb +9 -9
  15. data/lib/deposit/log.rb +10 -10
  16. data/lib/dict_key/dict_key.rb +26 -27
  17. data/lib/dynamic_brcode/dynamic_brcode.rb +155 -0
  18. data/lib/error.rb +7 -40
  19. data/lib/event/attempt.rb +9 -9
  20. data/lib/event/event.rb +30 -56
  21. data/lib/institution/institution.rb +2 -3
  22. data/lib/invoice/invoice.rb +24 -23
  23. data/lib/invoice/log.rb +10 -10
  24. data/lib/invoice/payment.rb +1 -2
  25. data/lib/payment_preview/boleto_preview.rb +4 -5
  26. data/lib/payment_preview/brcode_preview.rb +2 -3
  27. data/lib/payment_preview/payment_preview.rb +10 -6
  28. data/lib/payment_preview/tax_preview.rb +2 -3
  29. data/lib/payment_preview/utility_preview.rb +2 -3
  30. data/lib/payment_request/payment_request.rb +22 -16
  31. data/lib/starkbank.rb +16 -5
  32. data/lib/tax_payment/log.rb +10 -10
  33. data/lib/tax_payment/tax_payment.rb +22 -19
  34. data/lib/transaction/transaction.rb +13 -13
  35. data/lib/transfer/log.rb +10 -10
  36. data/lib/transfer/rule.rb +49 -0
  37. data/lib/transfer/transfer.rb +30 -24
  38. data/lib/utility_payment/log.rb +10 -10
  39. data/lib/utility_payment/utility_payment.rb +26 -17
  40. data/lib/utils/parse.rb +35 -0
  41. data/lib/utils/rest.rb +132 -109
  42. data/lib/webhook/webhook.rb +5 -5
  43. data/lib/workspace/workspace.rb +38 -10
  44. metadata +15 -25
  45. data/lib/brcode_preview/brcode_preview.rb +0 -79
  46. data/lib/key.rb +0 -33
  47. data/lib/user/organization.rb +0 -54
  48. data/lib/user/project.rb +0 -37
  49. data/lib/user/user.rb +0 -20
  50. data/lib/utils/api.rb +0 -79
  51. data/lib/utils/cache.rb +0 -10
  52. data/lib/utils/case.rb +0 -21
  53. data/lib/utils/checks.rb +0 -101
  54. data/lib/utils/environment.rb +0 -13
  55. data/lib/utils/request.rb +0 -79
  56. data/lib/utils/resource.rb +0 -13
  57. data/lib/utils/sub_resource.rb +0 -28
  58. data/lib/utils/url.rb +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df05543973d4dbbc39842f117e914f0ab892e382637766bae66e58297bbbf639
4
- data.tar.gz: 56e8433e4d08637c893bf45cf717b798233619782ff6f1874ed01b5b74f4f45e
3
+ metadata.gz: 3a3493b760a1ff8ec3af45fbe6a7df82d3457f543c210857866db6b6d83ac393
4
+ data.tar.gz: 75a9e0260201fccd4fa39374bb671b8e93cc248e1e2d4b34d207ff5bdba66095
5
5
  SHA512:
6
- metadata.gz: 32c50715be122647ff026491515c953818c6d2570157088da4e7d27d5687686d305475c2c3711798f97aad70d1269f181f72f48bdb4e8fc379fff03b8408d88d
7
- data.tar.gz: b2a9b0d86a9e293c26f75649d0c2f2cf41e373f7503ac5edb59765bb9ab44bdf8f8e6231d236c104d524ecded335fd205bb8188ae822a2bf2572582dee21abae
6
+ metadata.gz: 4f238645203432793eb681b6e2292cbae27e75ba672ec08e157c5c5f2888924a3db0165d3be55154cd850091746f0c2e78d6fc9d667b619acc3b484708e9d975
7
+ data.tar.gz: 11e0dfc9d6568767f42b2b37641f822deb64b23c9845bdf1ab56f0c99f8b3a2c8c772dc6932490c4609f98b04feeb0332a8031d80e45c8d9de0b5d2fdf2d8fbd
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
3
+ require('starkcore')
4
4
  require_relative('../utils/rest')
5
- require_relative('../utils/checks')
5
+
6
6
 
7
7
  module StarkBank
8
8
  # # Balance object
@@ -13,17 +13,17 @@ module StarkBank
13
13
  # can be retrieved to see the available information.
14
14
  #
15
15
  # ## Attributes (return-only):
16
- # - id [string, default nil]: unique id returned when Balance is created. ex: '5656565656565656'
17
- # - amount [integer, default nil]: current balance amount of the workspace in cents. ex: 200 (= R$ 2.00)
18
- # - currency [string, default nil]: currency of the current workspace. Expect others to be added eventually. ex:'BRL'
19
- # - updated [DateTime, default nil]: update datetime for the balance. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
20
- class Balance < StarkBank::Utils::Resource
16
+ # - id [string]: unique id returned when Balance is created. ex: '5656565656565656'
17
+ # - amount [integer]: current balance amount of the workspace in cents. ex: 200 (= R$ 2.00)
18
+ # - currency [string]: currency of the current workspace. Expect others to be added eventually. ex:'BRL'
19
+ # - updated [DateTime]: update datetime for the balance. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
20
+ class Balance < StarkCore::Utils::Resource
21
21
  attr_reader :amount, :currency, :updated
22
22
  def initialize(amount:, currency:, updated:, id:)
23
23
  super(id)
24
24
  @amount = amount
25
25
  @currency = currency
26
- @updated = StarkBank::Utils::Checks.check_datetime(updated)
26
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
27
27
  end
28
28
 
29
29
  # # Retrieve the Balance object
data/lib/boleto/boleto.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
3
+ require('starkcore')
4
4
  require_relative('../utils/rest')
5
- require_relative('../utils/checks')
5
+
6
6
 
7
7
  module StarkBank
8
8
  # # Boleto object
@@ -34,21 +34,22 @@ module StarkBank
34
34
  # - tags [list of strings]: list of strings for tagging
35
35
  #
36
36
  # ## Attributes (return-only):
37
- # - id [string, default nil]: unique id returned when Boleto is created. ex: '5656565656565656'
38
- # - fee [integer, default nil]: fee charged when Boleto is paid. ex: 200 (= R$ 2.00)
39
- # - line [string, default nil]: generated Boleto line for payment. ex: '34191.09008 63571.277308 71444.640008 5 81960000000062'
40
- # - bar_code [string, default nil]: generated Boleto bar-code for payment. ex: '34195819600000000621090063571277307144464000'
41
- # - transaction_ids [list of strings, default nil]: ledger transaction ids linked to this boleto. ex: ['19827356981273']
42
- # - status [string, default nil]: current Boleto status. ex: 'registered' or 'paid'
43
- # - created [DateTime, default nil]: creation datetime for the Boleto. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
44
- # - our_number [string, default nil]: Reference number registered at the settlement bank. ex:'10131474'
45
- class Boleto < StarkBank::Utils::Resource
46
- attr_reader :amount, :name, :tax_id, :street_line_1, :street_line_2, :district, :city, :state_code, :zip_code, :due, :fine, :interest, :overdue_limit, :receiver_name, :receiver_tax_id, :tags, :descriptions, :discounts, :id, :fee, :line, :bar_code, :status, :transaction_ids, :created, :our_number
37
+ # - id [string]: unique id returned when Boleto is created. ex: '5656565656565656'
38
+ # - fee [integer]: fee charged when Boleto is paid. ex: 200 (= R$ 2.00)
39
+ # - line [string]: generated Boleto line for payment. ex: '34191.09008 63571.277308 71444.640008 5 81960000000062'
40
+ # - bar_code [string]: generated Boleto bar-code for payment. ex: '34195819600000000621090063571277307144464000'
41
+ # - transaction_ids [list of strings]: ledger transaction ids linked to this boleto. ex: ['19827356981273']
42
+ # - workspace_id [string]: ID of the Workspace where this Boleto was generated. ex: "4545454545454545"
43
+ # - status [string]: current Boleto status. ex: 'registered' or 'paid'
44
+ # - created [DateTime]: creation datetime for the Boleto. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
45
+ # - our_number [string]: Reference number registered at the settlement bank. ex:'10131474'
46
+ class Boleto < StarkCore::Utils::Resource
47
+ attr_reader :amount, :name, :tax_id, :street_line_1, :street_line_2, :district, :city, :state_code, :zip_code, :due, :fine, :interest, :overdue_limit, :receiver_name, :receiver_tax_id, :tags, :descriptions, :discounts, :id, :fee, :line, :bar_code, :status, :transaction_ids, :workspace_id, :created, :our_number
47
48
  def initialize(
48
49
  amount:, name:, tax_id:, street_line_1:, street_line_2:, district:, city:, state_code:, zip_code:,
49
50
  due: nil, fine: nil, interest: nil, overdue_limit: nil, receiver_name: nil, receiver_tax_id: nil,
50
51
  tags: nil, descriptions: nil, discounts: nil, id: nil, fee: nil, line: nil, bar_code: nil,
51
- status: nil, transaction_ids: nil, created: nil, our_number: nil
52
+ status: nil, transaction_ids: nil, workspace_id: nil, created: nil, our_number: nil
52
53
  )
53
54
  super(id)
54
55
  @amount = amount
@@ -60,7 +61,7 @@ module StarkBank
60
61
  @city = city
61
62
  @state_code = state_code
62
63
  @zip_code = zip_code
63
- @due = StarkBank::Utils::Checks.check_date(due)
64
+ @due = StarkCore::Utils::Checks.check_date(due)
64
65
  @fine = fine
65
66
  @interest = interest
66
67
  @overdue_limit = overdue_limit
@@ -74,7 +75,8 @@ module StarkBank
74
75
  @bar_code = bar_code
75
76
  @status = status
76
77
  @transaction_ids = transaction_ids
77
- @created = StarkBank::Utils::Checks.check_datetime(created)
78
+ @workspace_id = workspace_id
79
+ @created = StarkCore::Utils::Checks.check_datetime(created)
78
80
  @our_number = our_number
79
81
  end
80
82
 
@@ -144,8 +146,8 @@ module StarkBank
144
146
  # ## Return:
145
147
  # - generator of Boleto objects with updated attributes
146
148
  def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
147
- after = StarkBank::Utils::Checks.check_date(after)
148
- before = StarkBank::Utils::Checks.check_date(before)
149
+ after = StarkCore::Utils::Checks.check_date(after)
150
+ before = StarkCore::Utils::Checks.check_date(before)
149
151
  StarkBank::Utils::Rest.get_stream(
150
152
  limit: limit,
151
153
  after: after,
@@ -176,8 +178,8 @@ module StarkBank
176
178
  # ## Return:
177
179
  # - list of Boleto objects with updated attributes and cursor to retrieve the next page of Boleto objects
178
180
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
179
- after = StarkBank::Utils::Checks.check_date(after)
180
- before = StarkBank::Utils::Checks.check_date(before)
181
+ after = StarkCore::Utils::Checks.check_date(after)
182
+ before = StarkCore::Utils::Checks.check_date(before)
181
183
  return StarkBank::Utils::Rest.get_page(
182
184
  cursor: cursor,
183
185
  limit: limit,
@@ -236,6 +238,7 @@ module StarkBank
236
238
  bar_code: json['bar_code'],
237
239
  status: json['status'],
238
240
  transaction_ids: json['transaction_ids'],
241
+ workspace_id: json['workspace_id'],
239
242
  created: json['created'],
240
243
  our_number: json['our_number']
241
244
  )
data/lib/boleto/log.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
3
+ require('starkcore')
4
4
  require_relative('../utils/rest')
5
- require_relative('../utils/checks')
6
5
  require_relative('boleto')
7
6
 
7
+
8
8
  module StarkBank
9
9
  class Boleto
10
10
  # # Boleto::Log object
@@ -14,20 +14,20 @@ module StarkBank
14
14
  # user, but it can be retrieved to check additional information
15
15
  # on the Boleto.
16
16
  #
17
- # ## Attributes:
17
+ # ## Attributes (return-only):
18
18
  # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
19
19
  # - boleto [Boleto]: Boleto entity to which the log refers to.
20
20
  # - errors [list of strings]: list of errors linked to this Boleto event
21
21
  # - type [string]: type of the Boleto event which triggered the log creation. ex: 'registered' or 'paid'
22
22
  # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
23
- class Log < StarkBank::Utils::Resource
23
+ class Log < StarkCore::Utils::Resource
24
24
  attr_reader :id, :created, :type, :errors, :boleto
25
25
  def initialize(id:, created:, type:, errors:, boleto:)
26
26
  super(id)
27
27
  @type = type
28
28
  @errors = errors
29
29
  @boleto = boleto
30
- @created = StarkBank::Utils::Checks.check_datetime(created)
30
+ @created = StarkCore::Utils::Checks.check_datetime(created)
31
31
  end
32
32
 
33
33
  # # Retrieve a specific Log
@@ -61,8 +61,8 @@ module StarkBank
61
61
  # ## Return:
62
62
  # - list of Log objects with updated attributes
63
63
  def self.query(limit: nil, after: nil, before: nil, types: nil, boleto_ids: nil, user: nil)
64
- after = StarkBank::Utils::Checks.check_date(after)
65
- before = StarkBank::Utils::Checks.check_date(before)
64
+ after = StarkCore::Utils::Checks.check_date(after)
65
+ before = StarkCore::Utils::Checks.check_date(before)
66
66
  StarkBank::Utils::Rest.get_stream(
67
67
  limit: limit,
68
68
  after: after,
@@ -91,8 +91,8 @@ module StarkBank
91
91
  # ## Return:
92
92
  # - list of Log objects with updated attributes and cursor to retrieve the next page of Log objects
93
93
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, boleto_ids: nil, user: nil)
94
- after = StarkBank::Utils::Checks.check_date(after)
95
- before = StarkBank::Utils::Checks.check_date(before)
94
+ after = StarkCore::Utils::Checks.check_date(after)
95
+ before = StarkCore::Utils::Checks.check_date(before)
96
96
  return StarkBank::Utils::Rest.get_page(
97
97
  cursor: cursor,
98
98
  limit: limit,
@@ -115,7 +115,7 @@ module StarkBank
115
115
  created: json['created'],
116
116
  type: json['type'],
117
117
  errors: json['errors'],
118
- boleto: StarkBank::Utils::API.from_api_json(boleto_maker, json['boleto'])
118
+ boleto: StarkCore::Utils::API.from_api_json(boleto_maker, json['boleto'])
119
119
  )
120
120
  }
121
121
  }
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
3
+ require('starkcore')
4
4
  require_relative('../utils/rest')
5
- require_relative('../utils/checks')
5
+
6
6
 
7
7
  module StarkBank
8
8
  # # BoletoHolmes object
@@ -18,12 +18,12 @@ module StarkBank
18
18
  # - tags [list of strings]: list of strings for tagging
19
19
  #
20
20
  # ## Attributes (return-only):
21
- # - id [string, default nil]: unique id returned when holmes is created. ex: '5656565656565656'
22
- # - status [string, default nil]: current holmes status. ex: 'solving' or 'solved'
23
- # - result [string, default nil]: result of boleto status investigation. ex: 'paid' or 'cancelled'
24
- # - created [DateTime, default nil]: creation datetime for the Boleto. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
25
- # - updated [DateTime, default nil]: latest update datetime for the holmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
26
- class BoletoHolmes < StarkBank::Utils::Resource
21
+ # - id [string]: unique id returned when holmes is created. ex: '5656565656565656'
22
+ # - status [string]: current holmes status. ex: 'solving' or 'solved'
23
+ # - result [string]: result of boleto status investigation. ex: 'paid' or 'cancelled'
24
+ # - created [DateTime]: creation datetime for the Boleto. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
25
+ # - updated [DateTime]: latest update datetime for the holmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
26
+ class BoletoHolmes < StarkCore::Utils::Resource
27
27
  attr_reader :boleto_id, :tags, :id, :status, :result, :created, :updated
28
28
  def initialize(
29
29
  boleto_id:, tags: nil, id: nil, status: nil, result: nil, created: nil, updated: nil
@@ -33,8 +33,8 @@ module StarkBank
33
33
  @tags = tags
34
34
  @status = status
35
35
  @result = result
36
- @created = StarkBank::Utils::Checks.check_datetime(created)
37
- @updated = StarkBank::Utils::Checks.check_datetime(updated)
36
+ @created = StarkCore::Utils::Checks.check_datetime(created)
37
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
38
38
  end
39
39
 
40
40
  # # Create BoletoHolmes
@@ -86,8 +86,8 @@ module StarkBank
86
86
  # ## Return:
87
87
  # - generator of BoletoHolmes objects with updated attributes
88
88
  def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, boleto_id: nil, user: nil)
89
- after = StarkBank::Utils::Checks.check_date(after)
90
- before = StarkBank::Utils::Checks.check_date(before)
89
+ after = StarkCore::Utils::Checks.check_date(after)
90
+ before = StarkCore::Utils::Checks.check_date(before)
91
91
  StarkBank::Utils::Rest.get_stream(
92
92
  limit: limit,
93
93
  after: after,
@@ -120,8 +120,8 @@ module StarkBank
120
120
  # ## Return:
121
121
  # - list of BoletoHolmes objects with updated attributes and cursor to retrieve the next page of BoletoHolmes objects
122
122
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, boleto_id: nil, user: nil)
123
- after = StarkBank::Utils::Checks.check_date(after)
124
- before = StarkBank::Utils::Checks.check_date(before)
123
+ after = StarkCore::Utils::Checks.check_date(after)
124
+ before = StarkCore::Utils::Checks.check_date(before)
125
125
  return StarkBank::Utils::Rest.get_page(
126
126
  cursor: cursor,
127
127
  limit: limit,
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
3
+ require('starkcore')
4
4
  require_relative('../utils/rest')
5
- require_relative('../utils/checks')
6
5
  require_relative('boleto_holmes')
7
6
 
7
+
8
8
  module StarkBank
9
9
  class BoletoHolmes
10
10
  # # BoletoHolmes::Log object
@@ -14,18 +14,20 @@ module StarkBank
14
14
  # user, but it can be retrieved to check additional information
15
15
  # on the BoletoHolmes.
16
16
  #
17
- # ## Attributes:
17
+ # ## Attributes (return-only):
18
18
  # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
19
19
  # - holmes [BoletoHolmes]: BoletoHolmes entity to which the log refers to.
20
20
  # - type [string]: type of the Boleto event which triggered the log creation. ex: 'registered' or 'paid'
21
21
  # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
22
- class Log < StarkBank::Utils::Resource
23
- attr_reader :id, :holmes, :type, :created
24
- def initialize(id:, holmes:, type:, created:)
22
+ # - updated [DateTime]: latest update datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
23
+ class Log < StarkCore::Utils::Resource
24
+ attr_reader :id, :holmes, :type, :created, :updated
25
+ def initialize(id:, holmes:, type:, created:, updated:)
25
26
  super(id)
26
27
  @holmes = holmes
27
28
  @type = type
28
- @created = StarkBank::Utils::Checks.check_datetime(created)
29
+ @created = StarkCore::Utils::Checks.check_datetime(created)
30
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
29
31
  end
30
32
 
31
33
  # # Retrieve a specific Log
@@ -59,8 +61,8 @@ module StarkBank
59
61
  # ## Return:
60
62
  # - list of Log objects with updated attributes
61
63
  def self.query(limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil, user: nil)
62
- after = StarkBank::Utils::Checks.check_date(after)
63
- before = StarkBank::Utils::Checks.check_date(before)
64
+ after = StarkCore::Utils::Checks.check_date(after)
65
+ before = StarkCore::Utils::Checks.check_date(before)
64
66
  StarkBank::Utils::Rest.get_stream(
65
67
  limit: limit,
66
68
  after: after,
@@ -89,8 +91,8 @@ module StarkBank
89
91
  # ## Return:
90
92
  # - list of Log objects with updated attributes and cursor to retrieve the next page of Log objects
91
93
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil, user: nil)
92
- after = StarkBank::Utils::Checks.check_date(after)
93
- before = StarkBank::Utils::Checks.check_date(before)
94
+ after = StarkCore::Utils::Checks.check_date(after)
95
+ before = StarkCore::Utils::Checks.check_date(before)
94
96
  return StarkBank::Utils::Rest.get_page(
95
97
  cursor: cursor,
96
98
  limit: limit,
@@ -110,9 +112,10 @@ module StarkBank
110
112
  resource_maker: proc { |json|
111
113
  Log.new(
112
114
  id: json['id'],
113
- holmes: StarkBank::Utils::API.from_api_json(holmes_maker, json['holmes']),
115
+ holmes: StarkCore::Utils::API.from_api_json(holmes_maker, json['holmes']),
114
116
  type: json['type'],
115
- created: json['created']
117
+ created: json['created'],
118
+ updated: json['updated']
116
119
  )
117
120
  }
118
121
  }
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
3
+ require('starkcore')
4
4
  require_relative('../utils/rest')
5
- require_relative('../utils/checks')
5
+
6
6
 
7
7
  module StarkBank
8
8
  # # BoletoPayment object
@@ -20,29 +20,31 @@ module StarkBank
20
20
  # - description [string]: Text to be displayed in your statement (min. 10 characters). ex: 'payment ABC'
21
21
  #
22
22
  # ## Parameters (optional):
23
+ # - amount [int, default nil]: amount automatically calculated from line or bar_code. ex: 23456 (= R$ 234.56)
23
24
  # - scheduled [Date, DateTime, Time or string, default today]: payment scheduled date. ex: Date.new(2020, 3, 10)
24
25
  # - tags [list of strings]: list of strings for tagging
25
26
  #
26
27
  # ## Attributes (return-only):
27
- # - id [string, default nil]: unique id returned when payment is created. ex: '5656565656565656'
28
- # - status [string, default nil]: current payment status. ex: 'success' or 'failed'
29
- # - amount [int, default nil]: amount automatically calculated from line or bar_code. ex: 23456 (= R$ 234.56)
30
- # - fee [integer, default nil]: fee charged when the boleto payment is created. ex: 200 (= R$ 2.00)
31
- # - created [DateTime, default nil]: creation datetime for the payment. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
32
- class BoletoPayment < StarkBank::Utils::Resource
33
- attr_reader :tax_id, :description, :line, :bar_code, :scheduled, :tags, :id, :status, :amount, :fee, :created
34
- def initialize(tax_id:, description:, line: nil, bar_code: nil, scheduled: nil, tags: nil, id: nil, status: nil, amount: nil, fee: nil, created: nil)
28
+ # - id [string]: unique id returned when payment is created. ex: '5656565656565656'
29
+ # - status [string]: current payment status. ex: 'success' or 'failed'
30
+ # - fee [integer]: fee charged when the boleto payment is created. ex: 200 (= R$ 2.00)
31
+ # - transaction_ids [list of strings]: ledger transaction ids linked to this BoletoPayment. ex: ["19827356981273"]
32
+ # - created [DateTime]: creation datetime for the payment. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
33
+ class BoletoPayment < StarkCore::Utils::Resource
34
+ attr_reader :tax_id, :description, :line, :bar_code, :scheduled, :tags, :id, :status, :amount, :fee, :transaction_ids, :created
35
+ def initialize(tax_id:, description:, line: nil, bar_code: nil, scheduled: nil, tags: nil, id: nil, status: nil, amount: nil, fee: nil, transaction_ids: nil, created: nil)
35
36
  super(id)
36
37
  @tax_id = tax_id
37
38
  @description = description
38
39
  @line = line
39
40
  @bar_code = bar_code
40
- @scheduled = StarkBank::Utils::Checks.check_date(scheduled)
41
+ @amount = amount
42
+ @scheduled = StarkCore::Utils::Checks.check_date(scheduled)
41
43
  @tags = tags
42
44
  @status = status
43
- @amount = amount
44
45
  @fee = fee
45
- @created = StarkBank::Utils::Checks.check_datetime(created)
46
+ @transaction_ids = transaction_ids
47
+ @created = StarkCore::Utils::Checks.check_datetime(created)
46
48
  end
47
49
 
48
50
  # # Create BoletoPayments
@@ -110,8 +112,8 @@ module StarkBank
110
112
  # ## Return:
111
113
  # - generator of BoletoPayment objects with updated attributes
112
114
  def self.query(limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
113
- after = StarkBank::Utils::Checks.check_date(after)
114
- before = StarkBank::Utils::Checks.check_date(before)
115
+ after = StarkCore::Utils::Checks.check_date(after)
116
+ before = StarkCore::Utils::Checks.check_date(before)
115
117
  StarkBank::Utils::Rest.get_stream(
116
118
  user: user,
117
119
  limit: limit,
@@ -142,8 +144,8 @@ module StarkBank
142
144
  # ## Return:
143
145
  # - list of BoletoPayment objects with updated attributes and cursor to retrieve the next page of BoletoPayment objects
144
146
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
145
- after = StarkBank::Utils::Checks.check_date(after)
146
- before = StarkBank::Utils::Checks.check_date(before)
147
+ after = StarkCore::Utils::Checks.check_date(after)
148
+ before = StarkCore::Utils::Checks.check_date(before)
147
149
  return StarkBank::Utils::Rest.get_page(
148
150
  cursor: cursor,
149
151
  user: user,
@@ -181,11 +183,12 @@ module StarkBank
181
183
  description: json['description'],
182
184
  line: json['line'],
183
185
  bar_code: json['bar_code'],
186
+ amount: json['amount'],
184
187
  scheduled: json['scheduled'],
185
188
  tags: json['tags'],
186
189
  status: json['status'],
187
- amount: json['amount'],
188
190
  fee: json['fee'],
191
+ transaction_ids: json['transaction_ids'],
189
192
  created: json['created']
190
193
  )
191
194
  }
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
3
+ require('starkcore')
4
4
  require_relative('../utils/rest')
5
- require_relative('../utils/checks')
6
5
  require_relative('boleto_payment')
7
6
 
7
+
8
8
  module StarkBank
9
9
  class BoletoPayment
10
10
  # # BoletoPayment::Log object
@@ -14,20 +14,20 @@ module StarkBank
14
14
  # user, but it can be retrieved to check additional information
15
15
  # on the BoletoPayment.
16
16
  #
17
- # ## Attributes:
17
+ # ## Attributes (return-only):
18
18
  # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
19
19
  # - payment [BoletoPayment]: BoletoPayment entity to which the log refers to.
20
20
  # - errors [list of strings]: list of errors linked to this BoletoPayment event.
21
21
  # - type [string]: type of the BoletoPayment event which triggered the log creation. ex: 'processing' or 'success'
22
22
  # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
23
- class Log < StarkBank::Utils::Resource
23
+ class Log < StarkCore::Utils::Resource
24
24
  attr_reader :id, :created, :type, :errors, :payment
25
25
  def initialize(id:, created:, type:, errors:, payment:)
26
26
  super(id)
27
27
  @type = type
28
28
  @errors = errors
29
29
  @payment = payment
30
- @created = StarkBank::Utils::Checks.check_datetime(created)
30
+ @created = StarkCore::Utils::Checks.check_datetime(created)
31
31
  end
32
32
 
33
33
  # # Retrieve a specific Log
@@ -61,8 +61,8 @@ module StarkBank
61
61
  # ## Return:
62
62
  # - list of Log objects with updated attributes
63
63
  def self.query(limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil)
64
- after = StarkBank::Utils::Checks.check_date(after)
65
- before = StarkBank::Utils::Checks.check_date(before)
64
+ after = StarkCore::Utils::Checks.check_date(after)
65
+ before = StarkCore::Utils::Checks.check_date(before)
66
66
  StarkBank::Utils::Rest.get_stream(
67
67
  limit: limit,
68
68
  after: after,
@@ -91,8 +91,8 @@ module StarkBank
91
91
  # ## Return:
92
92
  # - list of Log objects with updated attributes and cursor to retrieve the next page of Log objects
93
93
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil)
94
- after = StarkBank::Utils::Checks.check_date(after)
95
- before = StarkBank::Utils::Checks.check_date(before)
94
+ after = StarkCore::Utils::Checks.check_date(after)
95
+ before = StarkCore::Utils::Checks.check_date(before)
96
96
  return StarkBank::Utils::Rest.get_page(
97
97
  cursor: cursor,
98
98
  limit: limit,
@@ -115,7 +115,7 @@ module StarkBank
115
115
  created: json['created'],
116
116
  type: json['type'],
117
117
  errors: json['errors'],
118
- payment: StarkBank::Utils::API.from_api_json(payment_maker, json['payment'])
118
+ payment: StarkCore::Utils::API.from_api_json(payment_maker, json['payment'])
119
119
  )
120
120
  }
121
121
  }
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
3
+ require('starkcore')
4
4
  require_relative('../utils/rest')
5
- require_relative('../utils/checks')
5
+
6
6
 
7
7
  module StarkBank
8
8
  # # BrcodePayment object
@@ -22,33 +22,35 @@ module StarkBank
22
22
  # ## Parameters (optional):
23
23
  # - scheduled [datetime.date, datetime.datetime or string, default now]: payment scheduled date or datetime. ex: datetime.datetime(2020, 3, 10, 15, 17, 3)
24
24
  # - tags [list of strings, default nil]: list of strings for tagging
25
+ # - rules [list of BrcodePayment::Rules, default []]: list of BrcodePayment::Rule objects for modifying transfer behavior. ex: [BrcodePayment::Rule(key: "resendingLimit", value: 5)]
25
26
  #
26
27
  # ## Attributes (return-only):
27
- # - id [string, default nil]: unique id returned when payment is created. ex: '5656565656565656'
28
- # - name [string, nil]: receiver name. ex: 'Jon Snow'
29
- # - status [string, default nil]: current payment status. ex: 'success' or 'failed'
30
- # - type [string, default nil]: brcode type. ex: 'static' or 'dynamic'
31
- # - transaction_ids [list of strings, default nil]: ledger transaction ids linked to this payment. ex: ['19827356981273']
32
- # - fee [integer, default nil]: fee charged when the brcode payment is created. ex: 200 (= R$ 2.00)
33
- # - updated [datetime.datetime, default nil]: latest update datetime for the payment. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0)
34
- # - created [datetime.datetime, default nil]: creation datetime for the payment. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0)
35
- class BrcodePayment < StarkBank::Utils::Resource
36
- attr_reader :brcode, :tax_id, :description, :amount, :scheduled, :tags, :id, :name, :status, :type, :transaction_ids, :fee, :updated, :created
37
- def initialize(brcode:, tax_id:, description:, amount: nil, scheduled: nil, tags: nil, id: nil, name: nil, status: nil, type: nil, transaction_ids: nil, fee: nil, updated: nil, created: nil)
28
+ # - id [string]: unique id returned when payment is created. ex: '5656565656565656'
29
+ # - name [string]: receiver name. ex: 'Jon Snow'
30
+ # - status [string]: current payment status. ex: 'success' or 'failed'
31
+ # - type [string]: brcode type. ex: 'static' or 'dynamic'
32
+ # - transaction_ids [list of strings]: ledger transaction ids linked to this payment. ex: ['19827356981273']
33
+ # - fee [integer]: fee charged when the brcode payment is created. ex: 200 (= R$ 2.00)
34
+ # - updated [datetime.datetime]: latest update datetime for the payment. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0)
35
+ # - created [datetime.datetime]: creation datetime for the payment. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0)
36
+ class BrcodePayment < StarkCore::Utils::Resource
37
+ attr_reader :brcode, :tax_id, :description, :amount, :scheduled, :tags, :rules, :id, :name, :status, :type, :transaction_ids, :fee, :updated, :created
38
+ def initialize(brcode:, tax_id:, description:, amount: nil, scheduled: nil, tags: nil, rules: nil, id: nil, name: nil, status: nil, type: nil, transaction_ids: nil, fee: nil, updated: nil, created: nil)
38
39
  super(id)
39
40
  @brcode = brcode
40
41
  @tax_id = tax_id
41
42
  @description = description
42
43
  @amount = amount
43
- @scheduled = StarkBank::Utils::Checks.check_date_or_datetime(scheduled)
44
+ @scheduled = StarkCore::Utils::Checks.check_date_or_datetime(scheduled)
44
45
  @tags = tags
46
+ @rules = StarkBank::BrcodePayment::Rule.parse_rules(rules)
45
47
  @name = name
46
48
  @status = status
47
49
  @type = type
48
50
  @transaction_ids = transaction_ids
49
51
  @fee = fee
50
- @updated = StarkBank::Utils::Checks.check_datetime(updated)
51
- @created = StarkBank::Utils::Checks.check_datetime(created)
52
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
53
+ @created = StarkCore::Utils::Checks.check_datetime(created)
52
54
  end
53
55
 
54
56
  # # Create BrcodePayments
@@ -132,8 +134,8 @@ module StarkBank
132
134
  # ## Return:
133
135
  # - generator of BrcodePayment objects with updated attributes
134
136
  def self.query(limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
135
- after = StarkBank::Utils::Checks.check_date(after)
136
- before = StarkBank::Utils::Checks.check_date(before)
137
+ after = StarkCore::Utils::Checks.check_date(after)
138
+ before = StarkCore::Utils::Checks.check_date(before)
137
139
  StarkBank::Utils::Rest.get_stream(
138
140
  limit: limit,
139
141
  after: after,
@@ -164,8 +166,8 @@ module StarkBank
164
166
  # ## Return:
165
167
  # - list of BrcodePayment objects with updated attributes and cursor to retrieve the next page of BrcodePayment objects
166
168
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
167
- after = StarkBank::Utils::Checks.check_date(after)
168
- before = StarkBank::Utils::Checks.check_date(before)
169
+ after = StarkCore::Utils::Checks.check_date(after)
170
+ before = StarkCore::Utils::Checks.check_date(before)
169
171
  return StarkBank::Utils::Rest.get_page(
170
172
  cursor: cursor,
171
173
  limit: limit,
@@ -190,6 +192,7 @@ module StarkBank
190
192
  amount: json['amount'],
191
193
  scheduled: json['scheduled'],
192
194
  tags: json['tags'],
195
+ rules: json['rules'],
193
196
  id: json['id'],
194
197
  name: json['name'],
195
198
  status: json['status'],