starkbank 2.5.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 +33 -23
- data/lib/invoice/log.rb +10 -10
- data/lib/invoice/payment.rb +1 -2
- data/lib/payment_preview/boleto_preview.rb +74 -0
- data/lib/payment_preview/brcode_preview.rb +74 -0
- data/lib/payment_preview/payment_preview.rb +71 -0
- data/lib/payment_preview/tax_preview.rb +44 -0
- data/lib/payment_preview/utility_preview.rb +44 -0
- data/lib/payment_request/payment_request.rb +22 -16
- data/lib/starkbank.rb +21 -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 +20 -25
- data/lib/brcode_preview/brcode_preview.rb +0 -77
- 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
data/lib/brcode_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('brcode_payment')
|
7
6
|
|
7
|
+
|
8
8
|
module StarkBank
|
9
9
|
class BrcodePayment
|
10
10
|
# # BrcodePayment::Log object
|
@@ -14,20 +14,20 @@ module StarkBank
|
|
14
14
|
# user, but it can be retrieved to check additional information
|
15
15
|
# on the BrcodePayment.
|
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 [BrcodePayment]: BrcodePayment entity to which the log refers to.
|
20
20
|
# - errors [list of strings]: list of errors linked to this BrcodePayment event.
|
21
21
|
# - type [string]: type of the BrcodePayment 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
|
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/rest')
|
4
|
+
|
5
|
+
|
6
|
+
module StarkBank
|
7
|
+
class BrcodePayment
|
8
|
+
# # BrcodePayment::Rule object
|
9
|
+
#
|
10
|
+
# The BrcodePayment::Rule object modifies the behavior of BrcodePayment objects when passed as an argument upon their creation.
|
11
|
+
#
|
12
|
+
# ## Parameters (required):
|
13
|
+
# - key [string]: Rule to be customized, describes what BrcodePayment behavior will be altered. ex: "resendingLimit"
|
14
|
+
# - value [integer]: Value of the rule. ex: 5
|
15
|
+
class Rule < StarkCore::Utils::SubResource
|
16
|
+
attr_reader :key, :value
|
17
|
+
def initialize(key:, value:)
|
18
|
+
@key = key
|
19
|
+
@value = value
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.parse_rules(rules)
|
23
|
+
resource_maker = StarkBank::BrcodePayment::Rule.resource[:resource_maker]
|
24
|
+
return rules if rules.nil?
|
25
|
+
|
26
|
+
parsed_rules = []
|
27
|
+
rules.each do |rule|
|
28
|
+
unless rule.is_a? Rule
|
29
|
+
rule = StarkCore::Utils::API.from_api_json(resource_maker, rule)
|
30
|
+
end
|
31
|
+
parsed_rules << rule
|
32
|
+
end
|
33
|
+
return parsed_rules
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.resource
|
37
|
+
{
|
38
|
+
resource_name: 'Rule',
|
39
|
+
resource_maker: proc { |json|
|
40
|
+
Rule.new(
|
41
|
+
key: json['key'],
|
42
|
+
value: json['value']
|
43
|
+
)
|
44
|
+
}
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -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
|
# # DarfPayment object
|
@@ -13,7 +13,6 @@ module StarkBank
|
|
13
13
|
#
|
14
14
|
# ## Parameters (required):
|
15
15
|
# - description [string]: Text to be displayed in your statement (min. 10 characters). ex: 'payment ABC'
|
16
|
-
# - description [string]: Text to be displayed in your statement (min. 10 characters). ex: 'payment ABC'
|
17
16
|
# - revenue_code [string]: 4-digit tax code assigned by Federal Revenue. ex: '5948'
|
18
17
|
# - tax_id [tax_id]: tax id (formatted or unformatted) of the payer. ex: '12.345.678/0001-95'
|
19
18
|
# - competence [Date, DateTime, Time or string, default today]: competence month of the service. ex: Date.new(2020, 3, 10)
|
@@ -28,36 +27,38 @@ module StarkBank
|
|
28
27
|
# - tags [list of strings, default nil]: list of strings for tagging
|
29
28
|
#
|
30
29
|
# ## Attributes (return-only):
|
31
|
-
# - id [string
|
32
|
-
# - status [string
|
33
|
-
# - amount [int
|
34
|
-
# - fee [integer
|
35
|
-
# -
|
36
|
-
# -
|
37
|
-
|
30
|
+
# - id [string]: unique id returned when payment is created. ex: '5656565656565656'
|
31
|
+
# - status [string]: current payment status. ex: 'success' or 'failed'
|
32
|
+
# - amount [int]: Total amount due calculated from other amounts. ex: 24146 (= R$ 241.46)
|
33
|
+
# - fee [integer]: fee charged when the DarfPayment is processed. ex: 0 (= R$ 0.00)
|
34
|
+
# - transaction_ids [list of strings]: ledger transaction ids linked to this DarfPayment. ex: ["19827356981273"]
|
35
|
+
# - created [DateTime]: creation datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
36
|
+
# - updated [DateTime]: latest update datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
37
|
+
class DarfPayment < StarkCore::Utils::Resource
|
38
38
|
attr_reader :id, :revenue_code, :tax_id, :competence, :reference_number, :fine_amount, :interest_amount,
|
39
|
-
:due, :description, :tags, :scheduled, :status, :amount, :nominal_amount, :fee, :updated, :created
|
39
|
+
:due, :description, :tags, :scheduled, :status, :amount, :nominal_amount, :fee, :transaction_ids, :updated, :created
|
40
40
|
def initialize(
|
41
41
|
id: nil, revenue_code:, tax_id:, competence:, reference_number:, fine_amount:, interest_amount:, due:, description: nil,
|
42
|
-
tags: nil, scheduled: nil, status: nil, amount: nil, nominal_amount: nil, fee: nil, updated: nil, created: nil
|
42
|
+
tags: nil, scheduled: nil, status: nil, amount: nil, nominal_amount: nil, fee: nil, transaction_ids: nil, updated: nil, created: nil
|
43
43
|
)
|
44
44
|
super(id)
|
45
45
|
@revenue_code = revenue_code
|
46
46
|
@tax_id = tax_id
|
47
|
-
@competence =
|
47
|
+
@competence = StarkCore::Utils::Checks.check_date(competence)
|
48
48
|
@reference_number = reference_number
|
49
49
|
@fine_amount = fine_amount
|
50
50
|
@interest_amount = interest_amount
|
51
|
-
@due =
|
51
|
+
@due = StarkCore::Utils::Checks.check_date(due)
|
52
52
|
@description = description
|
53
53
|
@tags = tags
|
54
|
-
@scheduled =
|
54
|
+
@scheduled = StarkCore::Utils::Checks.check_date(scheduled)
|
55
55
|
@status = status
|
56
56
|
@amount = amount
|
57
57
|
@nominal_amount = nominal_amount
|
58
58
|
@fee = fee
|
59
|
-
@
|
60
|
-
@
|
59
|
+
@transaction_ids = @transaction_ids
|
60
|
+
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
61
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
61
62
|
end
|
62
63
|
|
63
64
|
# # Create DarfPayments
|
@@ -125,8 +126,8 @@ module StarkBank
|
|
125
126
|
# ## Return:
|
126
127
|
# - generator of DarfPayment objects with updated attributes
|
127
128
|
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
128
|
-
after =
|
129
|
-
before =
|
129
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
130
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
130
131
|
StarkBank::Utils::Rest.get_stream(
|
131
132
|
limit: limit,
|
132
133
|
after: after,
|
@@ -157,8 +158,8 @@ module StarkBank
|
|
157
158
|
# ## Return:
|
158
159
|
# - list of Darf Payment objects with updated attributes and cursor to retrieve the next page of Darf Payment objects
|
159
160
|
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
160
|
-
after =
|
161
|
-
before =
|
161
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
162
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
162
163
|
return StarkBank::Utils::Rest.get_page(
|
163
164
|
cursor: cursor,
|
164
165
|
limit: limit,
|
@@ -209,6 +210,7 @@ module StarkBank
|
|
209
210
|
nominal_amount: json['nominal_amount'],
|
210
211
|
fee: json['fee'],
|
211
212
|
updated: json['updated'],
|
213
|
+
transaction_ids: json['transaction_ids'],
|
212
214
|
created: json['created'],
|
213
215
|
)
|
214
216
|
}
|
data/lib/darf_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('darf_payment')
|
7
6
|
|
7
|
+
|
8
8
|
module StarkBank
|
9
9
|
class DarfPayment
|
10
10
|
# # DarfPayment::Log object
|
@@ -14,20 +14,20 @@ module StarkBank
|
|
14
14
|
# user, but it can be retrieved to check additional information
|
15
15
|
# on the DarfPayment.
|
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 [DarfPayment]: DarfPayment entity to which the log refers to.
|
20
20
|
# - errors [list of strings]: list of errors linked to this DarfPayment event
|
21
21
|
# - type [string]: type of the DarfPayment 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(darf_payment_maker, json['payment'])
|
119
119
|
)
|
120
120
|
}
|
121
121
|
}
|
data/lib/deposit/deposit.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
|
# # Deposit object
|
@@ -25,7 +25,7 @@ module StarkBank
|
|
25
25
|
# - transaction_ids [list of strings]: ledger transaction ids linked to this Deposit (if there are more than one, all but first are reversals). ex: ['19827356981273']
|
26
26
|
# - created [datetime.datetime]: creation datetime for the Deposit. ex: datetime.datetime(2020, 12, 10, 10, 30, 0, 0)
|
27
27
|
# - updated [datetime.datetime]: latest update datetime for the Deposit. ex: datetime.datetime(2020, 12, 10, 10, 30, 0, 0)
|
28
|
-
class Deposit <
|
28
|
+
class Deposit < StarkCore::Utils::Resource
|
29
29
|
attr_reader :id, :name, :tax_id, :bank_code, :branch_code, :account_number, :account_type, :amount, :type, :status, :tags, :fee, :transaction_ids, :created, :updated
|
30
30
|
def initialize(
|
31
31
|
id:, name:, tax_id:, bank_code:, branch_code:, account_number:, account_type:, amount:, type:,
|
@@ -44,8 +44,8 @@ module StarkBank
|
|
44
44
|
@tags = tags
|
45
45
|
@fee = fee
|
46
46
|
@transaction_ids = transaction_ids
|
47
|
-
@created =
|
48
|
-
@updated =
|
47
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
48
|
+
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
49
49
|
end
|
50
50
|
|
51
51
|
# # Retrieve a specific Deposit
|
@@ -81,8 +81,8 @@ module StarkBank
|
|
81
81
|
# ## Return:
|
82
82
|
# - generator of Deposit objects with updated attributes
|
83
83
|
def self.query(limit: nil, after: nil, before: nil, status: nil, sort: nil, tags: nil, ids: nil, user: nil)
|
84
|
-
after =
|
85
|
-
before =
|
84
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
85
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
86
86
|
StarkBank::Utils::Rest.get_stream(
|
87
87
|
limit: limit,
|
88
88
|
after: after,
|
@@ -115,8 +115,8 @@ module StarkBank
|
|
115
115
|
# ## Return:
|
116
116
|
# - list of Deposit objects with updated attributes and cursor to retrieve the next page of Deposit objects
|
117
117
|
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, sort: nil, tags: nil, ids: nil, user: nil)
|
118
|
-
after =
|
119
|
-
before =
|
118
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
119
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
120
120
|
return StarkBank::Utils::Rest.get_page(
|
121
121
|
cursor: cursor,
|
122
122
|
limit: limit,
|
data/lib/deposit/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('deposit')
|
7
6
|
|
7
|
+
|
8
8
|
module StarkBank
|
9
9
|
class Deposit
|
10
10
|
# # Deposit::Log object
|
@@ -14,20 +14,20 @@ module StarkBank
|
|
14
14
|
# user, but it can be retrieved to check additional information
|
15
15
|
# on the Deposit.
|
16
16
|
#
|
17
|
-
# ## Attributes:
|
17
|
+
# ## Attributes (return-only):
|
18
18
|
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
19
19
|
# - deposit [Deposit]: Deposit entity to which the log refers to.
|
20
20
|
# - errors [list of strings]: list of errors linked to this Deposit event
|
21
21
|
# - type [string]: type of the Deposit event which triggered the log creation. ex: 'canceled' 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, :deposit
|
25
25
|
def initialize(id:, created:, type:, errors:, deposit:)
|
26
26
|
super(id)
|
27
27
|
@type = type
|
28
28
|
@errors = errors
|
29
29
|
@deposit = deposit
|
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, deposit_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, deposit_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
|
-
deposit:
|
118
|
+
deposit: StarkCore::Utils::API.from_api_json(deposit_maker, json['deposit'])
|
119
119
|
)
|
120
120
|
}
|
121
121
|
}
|
data/lib/dict_key/dict_key.rb
CHANGED
@@ -1,32 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('../utils/resource.rb')
|
4
3
|
require_relative('../utils/rest.rb')
|
5
|
-
|
4
|
+
|
6
5
|
|
7
6
|
module StarkBank
|
8
7
|
# # DictKey object
|
9
8
|
#
|
10
|
-
# DictKey represents a
|
9
|
+
# DictKey represents a Pix key registered in Bacen's DICT system.
|
11
10
|
#
|
12
|
-
# ## Parameters (
|
13
|
-
# - id [string]: DictKey object unique id and
|
11
|
+
# ## Parameters (optional):
|
12
|
+
# - id [string]: DictKey object unique id and Pix key itself. ex: 'tony@starkbank.com', '722.461.430-04', '20.018.183/0001-80', '+5511988887777', 'b6295ee1-f054-47d1-9e90-ee57b74f60d9'
|
14
13
|
#
|
15
14
|
# ## Attributes (return-only):
|
16
|
-
# - type [string
|
17
|
-
# - name [string
|
18
|
-
# - tax_id [string
|
19
|
-
# - owner_type [string
|
20
|
-
# - bank_name [string
|
21
|
-
# - ispb [string
|
22
|
-
# - branch_code [string
|
23
|
-
# - account_number [string
|
24
|
-
# - account_type [string
|
25
|
-
# - status [string
|
26
|
-
# - account_created [DateTime or string
|
27
|
-
# - owned [DateTime or string
|
28
|
-
# - created [DateTime or string
|
29
|
-
class DictKey <
|
15
|
+
# - type [string]: DICT key type. ex: 'email', 'cpf', 'cnpj', 'phone' or 'evp'
|
16
|
+
# - name [string]: account owner full name. ex: 'Tony Stark'
|
17
|
+
# - tax_id [string]: key owner tax ID (CNPJ or masked CPF). ex: '***.345.678-**' or '20.018.183/0001-80'
|
18
|
+
# - owner_type [string]: DICT key owner type. ex 'naturalPerson' or 'legalPerson'
|
19
|
+
# - bank_name [string]: bank name associated with the DICT key. ex: 'Stark Bank'
|
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'
|
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
|
+
class DictKey < StarkCore::Utils::Resource
|
30
29
|
attr_reader :id, :type, :name, :tax_id, :owner_type, :bank_name, :ispb, :branch_code, :account_number, :account_type, :status, :account_created, :owned, :created
|
31
30
|
def initialize(
|
32
31
|
id:, type:, name:, tax_id:, owner_type:, bank_name:, ispb:, branch_code:, account_number:,
|
@@ -43,9 +42,9 @@ module StarkBank
|
|
43
42
|
@account_number = account_number
|
44
43
|
@account_type = account_type
|
45
44
|
@status = status
|
46
|
-
@account_created =
|
47
|
-
@owned =
|
48
|
-
@created =
|
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)
|
49
48
|
end
|
50
49
|
|
51
50
|
# # Retrieve a specific DictKey
|
@@ -53,7 +52,7 @@ module StarkBank
|
|
53
52
|
# Receive a single DictKey object by passing its id
|
54
53
|
#
|
55
54
|
# ## Parameters (required):
|
56
|
-
# - id [string]: DictKey object unique id and
|
55
|
+
# - id [string]: DictKey object unique id and Pix key itself. ex: 'tony@starkbank.com', '722.461.430-04', '20.018.183/0001-80', '+5511988887777', 'b6295ee1-f054-47d1-9e90-ee57b74f60d9'
|
57
56
|
#
|
58
57
|
# ## Parameters (optional):
|
59
58
|
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
@@ -80,8 +79,8 @@ module StarkBank
|
|
80
79
|
# ## Return:
|
81
80
|
# - generator of DitcKey objects with updated attributes
|
82
81
|
def self.query(limit: nil, type: nil, after: nil, before: nil, ids: nil, status: nil, user: nil)
|
83
|
-
after =
|
84
|
-
before =
|
82
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
83
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
85
84
|
StarkBank::Utils::Rest.get_stream(
|
86
85
|
limit: limit,
|
87
86
|
type: type,
|
@@ -112,8 +111,8 @@ module StarkBank
|
|
112
111
|
# ## Return:
|
113
112
|
# - list of DictKey objects with updated attributes and cursor to retrieve the next page of DictKey objects
|
114
113
|
def self.page(cursor: nil, limit: nil, type: nil, after: nil, before: nil, ids: nil, status: nil, user: nil)
|
115
|
-
after =
|
116
|
-
before =
|
114
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
115
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
117
116
|
return StarkBank::Utils::Rest.get_page(
|
118
117
|
cursor: cursor,
|
119
118
|
limit: limit,
|
@@ -0,0 +1,155 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require('starkcore')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
|
6
|
+
|
7
|
+
module StarkBank
|
8
|
+
# # DynamicBrcode object
|
9
|
+
#
|
10
|
+
# When you initialize a DynamicBrcode, the entity will not be automatically
|
11
|
+
# sent to the Stark Bank API. The 'create' function sends the objects
|
12
|
+
# to the Stark Bank API and returns the list of created objects.
|
13
|
+
#
|
14
|
+
# DynamicBrcodes are conciliated BR Codes that can be used to receive Pix transactions in a convenient way.
|
15
|
+
# When a DynamicBrcode is paid, a Deposit is created with the tags parameter containing the character “dynamic-brcode/” followed by the DynamicBrcode’s uuid "dynamic-brcode/{uuid}" for conciliation.
|
16
|
+
# Additionally, all tags passed on the DynamicBrcode will be transferred to the respective Deposit resource.
|
17
|
+
#
|
18
|
+
# ## Parameters (required):
|
19
|
+
# - amount [integer]: DynamicBrcode value in cents. Minimum = 0 (any value will be accepted). ex: 1234 (= R$ 12.34)
|
20
|
+
#
|
21
|
+
# ## Parameters (optional):
|
22
|
+
# - expiration [integer, default 3600 (1 hour)]: time interval in seconds between due date and expiration date. ex 123456789
|
23
|
+
# - tags [list of strings, default []]: list of strings for tagging, these will be passed to the respective DynamicBrcode resource when paid
|
24
|
+
#
|
25
|
+
# ## Attributes (return-only):
|
26
|
+
# - id [string]: id returned on creation, this is the BR code. ex: "00020126360014br.gov.bcb.pix0114+552840092118152040000530398654040.095802BR5915Jamie Lannister6009Sao Paulo620705038566304FC6C"
|
27
|
+
# - uuid [string]: unique uuid returned when the DynamicBrcode is created. ex: "4e2eab725ddd495f9c98ffd97440702d"
|
28
|
+
# - picture_url [string]: public QR Code (png image) URL. "https://sandbox.api.starkbank.com/v2/dynamic-brcode/d3ebb1bd92024df1ab6e5a353ee799a4.png"
|
29
|
+
# - updated [DateTime]: latest update datetime for the DynamicBrcode. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
30
|
+
# - created [DateTime]: creation datetime for the DynamicBrcode. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
31
|
+
class DynamicBrcode < StarkCore::Utils::Resource
|
32
|
+
attr_reader :amount, :expiration, :tags, :id, :uuid, :picture_url, :updated, :created
|
33
|
+
def initialize(
|
34
|
+
amount:, expiration: nil, tags: nil, id: nil, uuid: nil, picture_url: nil, updated: nil, created: nil
|
35
|
+
)
|
36
|
+
super(id)
|
37
|
+
@amount = amount
|
38
|
+
@expiration = expiration
|
39
|
+
@tags = tags
|
40
|
+
@uuid = uuid
|
41
|
+
@picture_url = picture_url
|
42
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
43
|
+
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
44
|
+
end
|
45
|
+
|
46
|
+
# # Create DynamicBrcode
|
47
|
+
#
|
48
|
+
# Send a list of DynamicBrcode objects for creation in the Stark Bank API
|
49
|
+
#
|
50
|
+
# ## Parameters (required):
|
51
|
+
# - brcodes [list of DynamicBrcode objects]: list of DynamicBrcode objects to be created in the API
|
52
|
+
#
|
53
|
+
# ## Parameters (optional):
|
54
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
55
|
+
#
|
56
|
+
# ## Return:
|
57
|
+
# - list of DynamicBrcode objects with updated attributes
|
58
|
+
def self.create(brcodes, user: nil)
|
59
|
+
StarkBank::Utils::Rest.post(entities: brcodes, user: user, **resource)
|
60
|
+
end
|
61
|
+
|
62
|
+
# # Retrieve a specific DynamicBrcode
|
63
|
+
#
|
64
|
+
# Receive a single DynamicBrcode object previously created in the Stark Bank API by its uuid
|
65
|
+
#
|
66
|
+
# ## Parameters (required):
|
67
|
+
# - uuid [string]: object unique uuid. ex: "901e71f2447c43c886f58366a5432c4b"
|
68
|
+
#
|
69
|
+
# ## Parameters (optional):
|
70
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
71
|
+
#
|
72
|
+
# ## Return:
|
73
|
+
# - DynamicBrcode object with updated attributes
|
74
|
+
def self.get(uuid, user: nil)
|
75
|
+
StarkBank::Utils::Rest.get_id(id: uuid, user: user, **resource)
|
76
|
+
end
|
77
|
+
|
78
|
+
# # Retrieve DynamicBrcodes
|
79
|
+
#
|
80
|
+
# Receive a generator of DynamicBrcode objects previously created in the Stark Bank API
|
81
|
+
#
|
82
|
+
# ## Parameters (optional):
|
83
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
84
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
85
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
86
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
87
|
+
# - uuids [list of strings, default nil]: list of uuids to filter retrieved objects. ex: ["901e71f2447c43c886f58366a5432c4b", "4e2eab725ddd495f9c98ffd97440702d"]
|
88
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
89
|
+
#
|
90
|
+
# ## Return:
|
91
|
+
# - generator of DynamicBrcode objects with updated attributes
|
92
|
+
def self.query(limit: nil, after: nil, before: nil, tags: nil, uuids: nil, user: nil)
|
93
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
94
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
95
|
+
StarkBank::Utils::Rest.get_stream(
|
96
|
+
limit: limit,
|
97
|
+
after: after,
|
98
|
+
before: before,
|
99
|
+
tags: tags,
|
100
|
+
uuids: uuids,
|
101
|
+
user: user,
|
102
|
+
**resource
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
# # Retrieve paged DynamicBrcodes
|
107
|
+
#
|
108
|
+
# Receive a list of up to 100 DynamicBrcode objects previously created in the Stark Bank API and the cursor to the next page.
|
109
|
+
# Use this function instead of query if you want to manually page your requests.
|
110
|
+
#
|
111
|
+
# ## Parameters (optional):
|
112
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
113
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
114
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
115
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
116
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
117
|
+
# - uuids [list of strings, default nil]: list of uuids to filter retrieved objects. ex: ["901e71f2447c43c886f58366a5432c4b", "4e2eab725ddd495f9c98ffd97440702d"]
|
118
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
119
|
+
#
|
120
|
+
# ## Return:
|
121
|
+
# - list of DynamicBrcode objects with updated attributes and cursor to retrieve the next page of DynamicBrcode objects
|
122
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, tags: nil, uuids: nil, user: nil)
|
123
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
124
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
125
|
+
return StarkBank::Utils::Rest.get_page(
|
126
|
+
cursor: cursor,
|
127
|
+
limit: limit,
|
128
|
+
after: after,
|
129
|
+
before: before,
|
130
|
+
tags: tags,
|
131
|
+
uuids: uuids,
|
132
|
+
user: user,
|
133
|
+
**resource
|
134
|
+
)
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.resource
|
138
|
+
{
|
139
|
+
resource_name: 'DynamicBrcode',
|
140
|
+
resource_maker: proc { |json|
|
141
|
+
DynamicBrcode.new(
|
142
|
+
id: json['id'],
|
143
|
+
amount: json['amount'],
|
144
|
+
expiration: json['expiration'],
|
145
|
+
tags: json['tags'],
|
146
|
+
uuid: json['uuid'],
|
147
|
+
picture_url: json['picture_url'],
|
148
|
+
created: json['created'],
|
149
|
+
updated: json['updated']
|
150
|
+
)
|
151
|
+
}
|
152
|
+
}
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|