starkbank 2.6.0 → 2.7.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/balance/balance.rb +8 -8
- data/lib/boleto/boleto.rb +22 -19
- data/lib/boleto/log.rb +10 -10
- data/lib/boleto_holmes/boleto_holmes.rb +14 -14
- data/lib/boleto_holmes/log.rb +16 -13
- data/lib/boleto_payment/boleto_payment.rb +21 -18
- data/lib/boleto_payment/log.rb +10 -10
- data/lib/brcode_payment/brcode_payment.rb +23 -20
- data/lib/brcode_payment/log.rb +10 -10
- data/lib/brcode_payment/rule.rb +49 -0
- data/lib/darf_payment/darf_payment.rb +23 -21
- data/lib/darf_payment/log.rb +10 -10
- data/lib/deposit/deposit.rb +9 -9
- data/lib/deposit/log.rb +10 -10
- data/lib/dict_key/dict_key.rb +26 -27
- data/lib/dynamic_brcode/dynamic_brcode.rb +155 -0
- data/lib/error.rb +7 -40
- data/lib/event/attempt.rb +9 -9
- data/lib/event/event.rb +30 -56
- data/lib/institution/institution.rb +2 -3
- data/lib/invoice/invoice.rb +24 -23
- data/lib/invoice/log.rb +10 -10
- data/lib/invoice/payment.rb +1 -2
- data/lib/payment_preview/boleto_preview.rb +4 -5
- data/lib/payment_preview/brcode_preview.rb +2 -3
- data/lib/payment_preview/payment_preview.rb +10 -6
- data/lib/payment_preview/tax_preview.rb +2 -3
- data/lib/payment_preview/utility_preview.rb +2 -3
- data/lib/payment_request/payment_request.rb +22 -16
- data/lib/starkbank.rb +16 -5
- data/lib/tax_payment/log.rb +10 -10
- data/lib/tax_payment/tax_payment.rb +22 -19
- data/lib/transaction/transaction.rb +13 -13
- data/lib/transfer/log.rb +10 -10
- data/lib/transfer/rule.rb +49 -0
- data/lib/transfer/transfer.rb +27 -24
- data/lib/utility_payment/log.rb +10 -10
- data/lib/utility_payment/utility_payment.rb +26 -17
- data/lib/utils/parse.rb +35 -0
- data/lib/utils/rest.rb +132 -109
- data/lib/webhook/webhook.rb +5 -5
- data/lib/workspace/workspace.rb +38 -10
- metadata +15 -25
- data/lib/brcode_preview/brcode_preview.rb +0 -79
- data/lib/key.rb +0 -33
- data/lib/user/organization.rb +0 -54
- data/lib/user/project.rb +0 -37
- data/lib/user/user.rb +0 -20
- data/lib/utils/api.rb +0 -79
- data/lib/utils/cache.rb +0 -10
- data/lib/utils/case.rb +0 -21
- data/lib/utils/checks.rb +0 -101
- data/lib/utils/environment.rb +0 -13
- data/lib/utils/request.rb +0 -79
- data/lib/utils/resource.rb +0 -13
- data/lib/utils/sub_resource.rb +0 -28
- data/lib/utils/url.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ba62b02ad32829b30a63195687160079a8f200f27c37480ff77fc3c9f181e1d
|
4
|
+
data.tar.gz: 8613d297878dba9deb3b5b4d1ae02122075585b636b08fe16d6862381cd78f65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 443cdda0a60dc2a8f53a55cda53158c41a2808fefda33dc8d4ed79a50d95dfb74d05fef2269120c06e806a6fdf4bd5affb0e2861f2281032b1b73ad573a38a35
|
7
|
+
data.tar.gz: bc0d01ba573da4d07b64f39f3bf208cf010ec5583f23bc59bf044ef9ebc2c33048f00a8a8090b312a8431162cb26d8e5541a8d48c7998d101b2050529e641c1e
|
data/lib/balance/balance.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require('starkcore')
|
4
4
|
require_relative('../utils/rest')
|
5
|
-
|
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
|
17
|
-
# - amount [integer
|
18
|
-
# - currency [string
|
19
|
-
# - updated [DateTime
|
20
|
-
class Balance <
|
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 =
|
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
|
-
|
3
|
+
require('starkcore')
|
4
4
|
require_relative('../utils/rest')
|
5
|
-
|
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
|
38
|
-
# - fee [integer
|
39
|
-
# - line [string
|
40
|
-
# - bar_code [string
|
41
|
-
# - transaction_ids [list of strings
|
42
|
-
# -
|
43
|
-
# -
|
44
|
-
# -
|
45
|
-
|
46
|
-
|
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 =
|
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
|
-
@
|
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 =
|
148
|
-
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 =
|
180
|
-
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
|
-
|
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 <
|
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 =
|
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 =
|
65
|
-
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 =
|
95
|
-
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:
|
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
|
-
|
3
|
+
require('starkcore')
|
4
4
|
require_relative('../utils/rest')
|
5
|
-
|
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
|
22
|
-
# - status [string
|
23
|
-
# - result [string
|
24
|
-
# - created [DateTime
|
25
|
-
# - updated [DateTime
|
26
|
-
class BoletoHolmes <
|
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 =
|
37
|
-
@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 =
|
90
|
-
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 =
|
124
|
-
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,
|
data/lib/boleto_holmes/log.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
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 =
|
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 =
|
63
|
-
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 =
|
93
|
-
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:
|
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
|
-
|
3
|
+
require('starkcore')
|
4
4
|
require_relative('../utils/rest')
|
5
|
-
|
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
|
28
|
-
# - status [string
|
29
|
-
# -
|
30
|
-
# -
|
31
|
-
# - created [DateTime
|
32
|
-
class BoletoPayment <
|
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
|
-
@
|
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
|
-
@
|
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 =
|
114
|
-
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 =
|
146
|
-
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
|
}
|
data/lib/boleto_payment/log.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
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 <
|
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 =
|
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 =
|
65
|
-
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 =
|
95
|
-
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:
|
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
|
-
|
3
|
+
require('starkcore')
|
4
4
|
require_relative('../utils/rest')
|
5
|
-
|
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
|
28
|
-
# - name [string
|
29
|
-
# - status [string
|
30
|
-
# - type [string
|
31
|
-
# - transaction_ids [list of strings
|
32
|
-
# - fee [integer
|
33
|
-
# - updated [datetime.datetime
|
34
|
-
# - created [datetime.datetime
|
35
|
-
class BrcodePayment <
|
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 =
|
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 =
|
51
|
-
@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 =
|
136
|
-
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 =
|
168
|
-
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'],
|