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/transfer/transfer.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
|
# # Transfer object
|
@@ -15,7 +15,7 @@ module StarkBank
|
|
15
15
|
# - amount [integer]: amount in cents to be transferred. ex: 1234 (= R$ 12.34)
|
16
16
|
# - name [string]: receiver full name. ex: 'Anthony Edward Stark'
|
17
17
|
# - tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
|
18
|
-
# - bank_code [string]: code of the receiver bank institution in Brazil. If an ISPB (8 digits) is informed, a
|
18
|
+
# - bank_code [string]: code of the receiver bank institution in Brazil. If an ISPB (8 digits) is informed, a Pix transfer will be created, else a TED will be issued. ex: '20018183' or '260'
|
19
19
|
# - branch_code [string]: receiver bank account branch. Use '-' in case there is a verifier digit. ex: '1357-9'
|
20
20
|
# - account_number [string]: receiver bank account number. Use '-' before the verifier digit. ex: '876543-2'
|
21
21
|
#
|
@@ -25,17 +25,18 @@ module StarkBank
|
|
25
25
|
# - scheduled [string, default now]: datetime when the transfer will be processed. May be pushed to next business day if necessary. ex: DateTime.new(2020, 3, 11, 8, 13, 12, 11)
|
26
26
|
# - description [string, default nil]: optional description to override default description to be shown in the bank statement. ex: 'Payment for service #1234'
|
27
27
|
# - tags [list of strings]: list of strings for reference when searching for transfers. ex: ['employees', 'monthly']
|
28
|
+
# - rules [list of Transfer::Rules, default []]: list of Transfer::Rule objects for modifying transfer behavior. ex: [Transfer::Rule(key: "resendingLimit", value: 5)]
|
28
29
|
#
|
29
30
|
# ## Attributes (return-only):
|
30
|
-
# - id [string
|
31
|
-
# - fee [integer
|
32
|
-
# - status [string
|
33
|
-
# - transaction_ids [list of strings
|
34
|
-
# - created [DateTime
|
35
|
-
# - updated [DateTime
|
36
|
-
class Transfer <
|
37
|
-
attr_reader :amount, :name, :tax_id, :bank_code, :branch_code, :account_number, :account_type, :external_id, :scheduled, :description, :transaction_ids, :fee, :tags, :status, :id, :created, :updated
|
38
|
-
def initialize(amount:, name:, tax_id:, bank_code:, branch_code:, account_number:, account_type: nil, external_id: nil, scheduled: nil, description: nil, transaction_ids: nil, fee: nil, tags: nil, status: nil, id: nil, created: nil, updated: nil)
|
31
|
+
# - id [string]: unique id returned when Transfer is created. ex: '5656565656565656'
|
32
|
+
# - fee [integer]: fee charged when transfer is created. ex: 200 (= R$ 2.00)
|
33
|
+
# - status [string]: current transfer status. ex: 'success' or 'failed'
|
34
|
+
# - transaction_ids [list of strings]: ledger transaction ids linked to this transfer (if there are two, second is the chargeback). ex: ['19827356981273']
|
35
|
+
# - created [DateTime]: creation datetime for the transfer. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
36
|
+
# - updated [DateTime]: latest update datetime for the transfer. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
37
|
+
class Transfer < StarkCore::Utils::Resource
|
38
|
+
attr_reader :amount, :name, :tax_id, :bank_code, :branch_code, :account_number, :account_type, :external_id, :scheduled, :description, :transaction_ids, :fee, :tags, :rules, :status, :id, :created, :updated
|
39
|
+
def initialize(amount:, name:, tax_id:, bank_code:, branch_code:, account_number:, account_type: nil, external_id: nil, scheduled: nil, description: nil, transaction_ids: nil, fee: nil, tags: nil, rules: nil, status: nil, id: nil, created: nil, updated: nil)
|
39
40
|
super(id)
|
40
41
|
@amount = amount
|
41
42
|
@name = name
|
@@ -45,14 +46,15 @@ module StarkBank
|
|
45
46
|
@account_number = account_number
|
46
47
|
@account_type = account_type
|
47
48
|
@external_id = external_id
|
48
|
-
@scheduled =
|
49
|
+
@scheduled = StarkCore::Utils::Checks.check_date_or_datetime(scheduled)
|
49
50
|
@description = description
|
50
|
-
@transaction_ids = transaction_ids
|
51
|
-
@fee = fee
|
52
51
|
@tags = tags
|
52
|
+
@rules = StarkBank::Transfer::Rule.parse_rules(rules)
|
53
|
+
@fee = fee
|
53
54
|
@status = status
|
54
|
-
@
|
55
|
-
@
|
55
|
+
@transaction_ids = transaction_ids
|
56
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
57
|
+
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
56
58
|
end
|
57
59
|
|
58
60
|
# # Create Transfers
|
@@ -138,8 +140,8 @@ module StarkBank
|
|
138
140
|
# ## Return:
|
139
141
|
# - generator of Transfer objects with updated attributes
|
140
142
|
def self.query(limit: nil, after: nil, before: nil, transaction_ids: nil, status: nil, tax_id: nil, sort: nil, tags: nil, ids: nil, user: nil)
|
141
|
-
after =
|
142
|
-
before =
|
143
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
144
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
143
145
|
StarkBank::Utils::Rest.get_stream(
|
144
146
|
limit: limit,
|
145
147
|
after: after,
|
@@ -173,8 +175,8 @@ module StarkBank
|
|
173
175
|
# ## Return:
|
174
176
|
# - list of Transfer objects with updated attributes and cursor to retrieve the next page of Transfer objects
|
175
177
|
def self.page(cursor: nil, limit: nil, after: nil, before: nil, transaction_ids: nil, status: nil, tax_id: nil, sort: nil, tags: nil, ids: nil, user: nil)
|
176
|
-
after =
|
177
|
-
before =
|
178
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
179
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
178
180
|
return StarkBank::Utils::Rest.get_page(
|
179
181
|
cursor: cursor,
|
180
182
|
limit: limit,
|
@@ -196,7 +198,6 @@ module StarkBank
|
|
196
198
|
resource_name: 'Transfer',
|
197
199
|
resource_maker: proc { |json|
|
198
200
|
Transfer.new(
|
199
|
-
id: json['id'],
|
200
201
|
amount: json['amount'],
|
201
202
|
name: json['name'],
|
202
203
|
tax_id: json['tax_id'],
|
@@ -207,10 +208,12 @@ module StarkBank
|
|
207
208
|
external_id: json['external_id'],
|
208
209
|
scheduled: json['scheduled'],
|
209
210
|
description: json['description'],
|
210
|
-
transaction_ids: json['transaction_ids'],
|
211
|
-
fee: json['fee'],
|
212
211
|
tags: json['tags'],
|
212
|
+
rules: json['rules'],
|
213
|
+
id: json['id'],
|
214
|
+
fee: json['fee'],
|
213
215
|
status: json['status'],
|
216
|
+
transaction_ids: json['transaction_ids'],
|
214
217
|
created: json['created'],
|
215
218
|
updated: json['updated']
|
216
219
|
)
|
data/lib/utility_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('utility_payment')
|
7
6
|
|
7
|
+
|
8
8
|
module StarkBank
|
9
9
|
class UtilityPayment
|
10
10
|
# # UtilityPayment::Log object
|
@@ -13,20 +13,20 @@ module StarkBank
|
|
13
13
|
# is generated for the entity. This log is never generated by the user, but it can
|
14
14
|
# be retrieved to check additional information on the UtilityPayment.
|
15
15
|
#
|
16
|
-
# ## Attributes:
|
16
|
+
# ## Attributes (return-only):
|
17
17
|
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
18
18
|
# - payment [UtilityPayment]: UtilityPayment entity to which the log refers to.
|
19
19
|
# - errors [list of strings]: list of errors linked to this UtilityPayment event.
|
20
20
|
# - type [string]: type of the UtilityPayment event which triggered the log creation. ex: 'processing' or 'success'
|
21
21
|
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
22
|
-
class Log <
|
22
|
+
class Log < StarkCore::Utils::Resource
|
23
23
|
attr_reader :id, :created, :type, :errors, :payment
|
24
24
|
def initialize(id:, created:, type:, errors:, payment:)
|
25
25
|
super(id)
|
26
26
|
@type = type
|
27
27
|
@errors = errors
|
28
28
|
@payment = payment
|
29
|
-
@created =
|
29
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
30
30
|
end
|
31
31
|
|
32
32
|
# # Retrieve a specific Log
|
@@ -60,8 +60,8 @@ module StarkBank
|
|
60
60
|
# ## Return:
|
61
61
|
# - list of Log objects with updated attributes
|
62
62
|
def self.query(limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil)
|
63
|
-
after =
|
64
|
-
before =
|
63
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
64
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
65
65
|
StarkBank::Utils::Rest.get_stream(
|
66
66
|
limit: limit,
|
67
67
|
after: after,
|
@@ -90,8 +90,8 @@ module StarkBank
|
|
90
90
|
# ## Return:
|
91
91
|
# - list of Log objects with updated attributes and cursor to retrieve the next page of Log objects
|
92
92
|
def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil)
|
93
|
-
after =
|
94
|
-
before =
|
93
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
94
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
95
95
|
return StarkBank::Utils::Rest.get_page(
|
96
96
|
cursor: cursor,
|
97
97
|
limit: limit,
|
@@ -114,7 +114,7 @@ module StarkBank
|
|
114
114
|
created: json['created'],
|
115
115
|
type: json['type'],
|
116
116
|
errors: json['errors'],
|
117
|
-
payment:
|
117
|
+
payment: StarkCore::Utils::API.from_api_json(payment_maker, json['payment'])
|
118
118
|
)
|
119
119
|
}
|
120
120
|
}
|
@@ -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
|
# # UtilityPayment object
|
@@ -23,24 +23,30 @@ module StarkBank
|
|
23
23
|
# - tags [list of strings]: list of strings for tagging
|
24
24
|
#
|
25
25
|
# ## Attributes (return-only):
|
26
|
-
# - id [string
|
27
|
-
# - status [string
|
28
|
-
# - amount [int
|
29
|
-
# - fee [integer
|
30
|
-
# -
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
# - id [string]: unique id returned when payment is created. ex: '5656565656565656'
|
27
|
+
# - status [string]: current payment status. ex: 'success' or 'failed'
|
28
|
+
# - amount [int]: amount automatically calculated from line or bar_code. ex: 23456 (= R$ 234.56)
|
29
|
+
# - fee [integer]: fee charged when utility payment is created. ex: 200 (= R$ 2.00)
|
30
|
+
# - type [string]: payment type. ex: "utility"
|
31
|
+
# - transaction_ids [list of strings]: ledger transaction ids linked to this UtilityPayment. ex: ["19827356981273"]
|
32
|
+
# - created [DateTime]: creation datetime for the payment. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
33
|
+
# - updated [DateTime]: latest update datetime for the payment. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
34
|
+
class UtilityPayment < StarkCore::Utils::Resource
|
35
|
+
attr_reader :description, :line, :bar_code, :tags, :scheduled, :id, :amount, :fee, :type, :transaction_ids, :status, :created, :updated
|
36
|
+
def initialize(description:, line: nil, bar_code: nil, tags: nil, scheduled: nil, id: nil, amount: nil, fee: nil, type: nil, transaction_ids: nil, status: nil, created: nil, updated: nil)
|
34
37
|
super(id)
|
35
38
|
@description = description
|
36
39
|
@line = line
|
37
40
|
@bar_code = bar_code
|
38
41
|
@tags = tags
|
39
|
-
@scheduled =
|
42
|
+
@scheduled = StarkCore::Utils::Checks.check_date(scheduled)
|
40
43
|
@amount = amount
|
41
44
|
@fee = fee
|
42
45
|
@status = status
|
43
|
-
@
|
46
|
+
@type = type
|
47
|
+
@transaction_ids = transaction_ids
|
48
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
49
|
+
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
44
50
|
end
|
45
51
|
|
46
52
|
# # Create UtilityPayments
|
@@ -108,8 +114,8 @@ module StarkBank
|
|
108
114
|
# ## Return:
|
109
115
|
# - generator of UtilityPayment objects with updated attributes
|
110
116
|
def self.query(limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
|
111
|
-
after =
|
112
|
-
before =
|
117
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
118
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
113
119
|
StarkBank::Utils::Rest.get_stream(
|
114
120
|
limit: limit,
|
115
121
|
after: after,
|
@@ -140,8 +146,8 @@ module StarkBank
|
|
140
146
|
# ## Return:
|
141
147
|
# - list of UtilityPayment objects with updated attributes and cursor to retrieve the next page of UtilityPayment objects
|
142
148
|
def self.page(cursor: nil, limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
|
143
|
-
after =
|
144
|
-
before =
|
149
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
150
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
145
151
|
return StarkBank::Utils::Rest.get_page(
|
146
152
|
cursor: cursor,
|
147
153
|
limit: limit,
|
@@ -184,8 +190,11 @@ module StarkBank
|
|
184
190
|
scheduled: json['scheduled'],
|
185
191
|
amount: json['amount'],
|
186
192
|
fee: json['fee'],
|
193
|
+
type: json['type'],
|
194
|
+
transaction_ids: json['transaction_ids'],
|
187
195
|
status: json['status'],
|
188
|
-
created: json['created']
|
196
|
+
created: json['created'],
|
197
|
+
updated: json['updated']
|
189
198
|
)
|
190
199
|
}
|
191
200
|
}
|
data/lib/utils/parse.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require('starkcore')
|
2
|
+
|
3
|
+
module StarkBank
|
4
|
+
module Utils
|
5
|
+
module Parse
|
6
|
+
def self.parse_and_verify(content:, signature:, user: nil, resource:, key: nil)
|
7
|
+
return StarkCore::Utils::Parse.parse_and_verify(
|
8
|
+
content: content,
|
9
|
+
signature: signature,
|
10
|
+
sdk_version: StarkBank::SDK_VERSION,
|
11
|
+
api_version: StarkBank::API_VERSION,
|
12
|
+
host: StarkBank::HOST,
|
13
|
+
resource: resource,
|
14
|
+
user: user ? user : StarkBank.user,
|
15
|
+
language: StarkBank.language,
|
16
|
+
timeout: StarkBank.language,
|
17
|
+
key: key
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.verify(content:, signature:, user: nil)
|
22
|
+
return StarkCore::Utils::Parse.verify(
|
23
|
+
content: content,
|
24
|
+
signature: signature,
|
25
|
+
sdk_version: StarkBank::SDK_VERSION,
|
26
|
+
api_version: StarkBank::API_VERSION,
|
27
|
+
host: StarkBank::HOST,
|
28
|
+
user: user ? user : StarkBank.user,
|
29
|
+
language: StarkBank.language,
|
30
|
+
timeout: StarkBank.language
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/utils/rest.rb
CHANGED
@@ -1,135 +1,158 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require_relative('api')
|
3
|
+
require('starkcore')
|
5
4
|
|
6
5
|
module StarkBank
|
7
6
|
module Utils
|
8
7
|
module Rest
|
9
|
-
def self.get_page(resource_name:, resource_maker:, user: nil, **query)
|
10
|
-
json = StarkBank::Utils::Request.fetch(
|
11
|
-
method: 'GET',
|
12
|
-
path: StarkBank::Utils::API.endpoint(resource_name),
|
13
|
-
query: query,
|
14
|
-
user: user
|
15
|
-
).json
|
16
|
-
entities = []
|
17
|
-
json[StarkBank::Utils::API.last_name_plural(resource_name)].each do |entity_json|
|
18
|
-
entities << StarkBank::Utils::API.from_api_json(resource_maker, entity_json)
|
19
|
-
end
|
20
|
-
return entities, json['cursor']
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.get_stream(resource_name:, resource_maker:, user: nil, **query)
|
24
|
-
limit = query[:limit]
|
25
|
-
query[:limit] = limit.nil? ? limit : [limit, 100].min
|
26
|
-
|
27
|
-
Enumerator.new do |enum|
|
28
|
-
loop do
|
29
|
-
json = StarkBank::Utils::Request.fetch(
|
30
|
-
method: 'GET',
|
31
|
-
path: StarkBank::Utils::API.endpoint(resource_name),
|
32
|
-
query: query,
|
33
|
-
user: user
|
34
|
-
).json
|
35
|
-
entities = json[StarkBank::Utils::API.last_name_plural(resource_name)]
|
36
8
|
|
37
|
-
|
38
|
-
|
39
|
-
|
9
|
+
def self.get_page(resource_name:, resource_maker:, user:, **query)
|
10
|
+
return StarkCore::Utils::Rest.get_page(
|
11
|
+
resource_name: resource_name,
|
12
|
+
resource_maker: resource_maker,
|
13
|
+
sdk_version: StarkBank::SDK_VERSION,
|
14
|
+
host: StarkBank::HOST,
|
15
|
+
api_version: StarkBank::API_VERSION,
|
16
|
+
user: user ? user : StarkBank.user,
|
17
|
+
language: StarkBank.language,
|
18
|
+
timeout: StarkBank.timeout,
|
19
|
+
**query
|
20
|
+
)
|
21
|
+
end
|
40
22
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
23
|
+
def self.get_stream(resource_name:, resource_maker:, user:, **query)
|
24
|
+
return StarkCore::Utils::Rest.get_stream(
|
25
|
+
resource_name: resource_name,
|
26
|
+
resource_maker: resource_maker,
|
27
|
+
sdk_version: StarkBank::SDK_VERSION,
|
28
|
+
host: StarkBank::HOST,
|
29
|
+
api_version: StarkBank::API_VERSION,
|
30
|
+
user: user ? user : StarkBank.user,
|
31
|
+
language: StarkBank.language,
|
32
|
+
timeout: StarkBank.timeout,
|
33
|
+
**query
|
34
|
+
)
|
35
|
+
end
|
45
36
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
37
|
+
def self.get_id(resource_name:, resource_maker:, user:, id:, **query)
|
38
|
+
return StarkCore::Utils::Rest.get_id(
|
39
|
+
resource_name: resource_name,
|
40
|
+
resource_maker: resource_maker,
|
41
|
+
sdk_version: StarkBank::SDK_VERSION,
|
42
|
+
host: StarkBank::HOST,
|
43
|
+
api_version: StarkBank::API_VERSION,
|
44
|
+
user: user ? user : StarkBank.user,
|
45
|
+
language: StarkBank.language,
|
46
|
+
timeout: StarkBank.timeout,
|
47
|
+
id: id,
|
48
|
+
**query
|
49
|
+
)
|
51
50
|
end
|
52
51
|
|
53
|
-
def self.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
52
|
+
def self.get_content(resource_name:, resource_maker:, user:, sub_resource_name:, id:, **query)
|
53
|
+
return StarkCore::Utils::Rest.get_content(
|
54
|
+
resource_name: resource_name,
|
55
|
+
resource_maker: resource_maker,
|
56
|
+
sdk_version: StarkBank::SDK_VERSION,
|
57
|
+
host: StarkBank::HOST,
|
58
|
+
api_version: StarkBank::API_VERSION,
|
59
|
+
user: user ? user : StarkBank.user,
|
60
|
+
language: StarkBank.language,
|
61
|
+
timeout: StarkBank.timeout,
|
62
|
+
sub_resource_name: sub_resource_name,
|
63
|
+
id: id,
|
64
|
+
**query
|
65
|
+
)
|
61
66
|
end
|
62
67
|
|
63
|
-
def self.
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
def self.get_sub_resource(resource_name:, sub_resource_maker:, sub_resource_name:, user:, id:, **query)
|
69
|
+
return StarkCore::Utils::Rest.get_sub_resource(
|
70
|
+
resource_name: resource_name,
|
71
|
+
sub_resource_maker: sub_resource_maker,
|
72
|
+
sub_resource_name: sub_resource_name,
|
73
|
+
sdk_version: StarkBank::SDK_VERSION,
|
74
|
+
host: StarkBank::HOST,
|
75
|
+
api_version: StarkBank::API_VERSION,
|
76
|
+
user: user ? user : StarkBank.user,
|
77
|
+
language: StarkBank.language,
|
78
|
+
timeout: StarkBank.timeout,
|
79
|
+
id: id,
|
80
|
+
**query
|
81
|
+
)
|
70
82
|
end
|
71
83
|
|
72
|
-
def self.
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
returned_jsons.each do |returned_json|
|
87
|
-
entities << StarkBank::Utils::API.from_api_json(resource_maker, returned_json)
|
88
|
-
end
|
89
|
-
entities
|
84
|
+
def self.get_sub_resources(resource_name:, sub_resource_maker:, sub_resource_name:, user:, id:, **query)
|
85
|
+
return StarkCore::Utils::Rest.get_sub_resource(
|
86
|
+
resource_name: resource_name,
|
87
|
+
sub_resource_maker: sub_resource_maker,
|
88
|
+
sub_resource_name: sub_resource_name,
|
89
|
+
sdk_version: StarkBank::SDK_VERSION,
|
90
|
+
host: StarkBank::HOST,
|
91
|
+
api_version: StarkBank::API_VERSION,
|
92
|
+
user: user ? user : StarkBank.user,
|
93
|
+
language: StarkBank.language,
|
94
|
+
timeout: StarkBank.timeout,
|
95
|
+
id: id,
|
96
|
+
**query
|
97
|
+
)
|
90
98
|
end
|
91
99
|
|
92
|
-
def self.
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
100
|
+
def self.post(resource_name:, resource_maker:, user:, entities:, **query)
|
101
|
+
return StarkCore::Utils::Rest.post(
|
102
|
+
resource_name: resource_name,
|
103
|
+
resource_maker: resource_maker,
|
104
|
+
sdk_version: StarkBank::SDK_VERSION,
|
105
|
+
host: StarkBank::HOST,
|
106
|
+
api_version: StarkBank::API_VERSION,
|
107
|
+
user: user ? user : StarkBank.user,
|
108
|
+
language: StarkBank.language,
|
109
|
+
timeout: StarkBank.timeout,
|
110
|
+
entities: entities,
|
111
|
+
**query
|
112
|
+
)
|
101
113
|
end
|
102
114
|
|
103
|
-
def self.
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
115
|
+
def self.post_single(resource_name:, resource_maker:, user:, entity:)
|
116
|
+
return StarkCore::Utils::Rest.post_single(
|
117
|
+
resource_name: resource_name,
|
118
|
+
resource_maker: resource_maker,
|
119
|
+
sdk_version: StarkBank::SDK_VERSION,
|
120
|
+
host: StarkBank::HOST,
|
121
|
+
api_version: StarkBank::API_VERSION,
|
122
|
+
user: user ? user : StarkBank.user,
|
123
|
+
language: StarkBank.language,
|
124
|
+
timeout: StarkBank.timeout,
|
125
|
+
entity: entity
|
126
|
+
)
|
111
127
|
end
|
112
128
|
|
113
|
-
def self.
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
129
|
+
def self.delete_id(resource_name:, resource_maker:, user:, id:)
|
130
|
+
return StarkCore::Utils::Rest.delete_id(
|
131
|
+
resource_name: resource_name,
|
132
|
+
resource_maker: resource_maker,
|
133
|
+
sdk_version: StarkBank::SDK_VERSION,
|
134
|
+
host: StarkBank::HOST,
|
135
|
+
api_version: StarkBank::API_VERSION,
|
136
|
+
user: user ? user : StarkBank.user,
|
137
|
+
language: StarkBank.language,
|
138
|
+
timeout: StarkBank.timeout,
|
139
|
+
id: id
|
140
|
+
)
|
122
141
|
end
|
123
142
|
|
124
|
-
def self.
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
143
|
+
def self.patch_id(resource_name:, resource_maker:, user:, id:, **payload)
|
144
|
+
return StarkCore::Utils::Rest.patch_id(
|
145
|
+
resource_name: resource_name,
|
146
|
+
resource_maker: resource_maker,
|
147
|
+
sdk_version: StarkBank::SDK_VERSION,
|
148
|
+
host: StarkBank::HOST,
|
149
|
+
api_version: StarkBank::API_VERSION,
|
150
|
+
user: user ? user : StarkBank.user,
|
151
|
+
language: StarkBank.language,
|
152
|
+
timeout: StarkBank.timeout,
|
153
|
+
id: id,
|
154
|
+
**payload
|
155
|
+
)
|
133
156
|
end
|
134
157
|
end
|
135
158
|
end
|
data/lib/webhook/webhook.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
|
# # Webhook subscription object
|
@@ -15,9 +15,9 @@ module StarkBank
|
|
15
15
|
# - url [string]: Url that will be notified when an event occurs.
|
16
16
|
# - subscriptions [list of strings]: list of any non-empty combination of the available services. ex: ['transfer', 'deposit']
|
17
17
|
#
|
18
|
-
# ## Attributes:
|
19
|
-
# - id [string
|
20
|
-
class Webhook <
|
18
|
+
# ## Attributes (return-only):
|
19
|
+
# - id [string]: unique id returned when the webhook is created. ex: '5656565656565656'
|
20
|
+
class Webhook < StarkCore::Utils::Resource
|
21
21
|
attr_reader :url, :subscriptions, :id
|
22
22
|
def initialize(url:, subscriptions:, id: nil)
|
23
23
|
super(id)
|