starkbank 2.2.0 → 2.5.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 +2 -2
- data/lib/boleto/boleto.rb +53 -14
- data/lib/boleto/log.rb +36 -5
- data/lib/boleto_holmes/boleto_holmes.rb +41 -6
- data/lib/boleto_holmes/log.rb +36 -5
- data/lib/boleto_payment/boleto_payment.rb +42 -9
- data/lib/boleto_payment/log.rb +36 -5
- data/lib/brcode_payment/brcode_payment.rb +56 -17
- data/lib/brcode_payment/log.rb +36 -5
- data/lib/brcode_preview/brcode_preview.rb +2 -2
- data/lib/darf_payment/darf_payment.rb +218 -0
- data/lib/darf_payment/log.rb +125 -0
- data/lib/deposit/deposit.rb +46 -8
- data/lib/deposit/log.rb +36 -5
- data/lib/dict_key/dict_key.rb +45 -9
- data/lib/error.rb +13 -5
- data/lib/event/attempt.rb +125 -0
- data/lib/event/event.rb +44 -8
- data/lib/institution/institution.rb +67 -0
- data/lib/invoice/invoice.rb +72 -15
- data/lib/invoice/log.rb +52 -5
- data/lib/invoice/payment.rb +57 -0
- data/lib/payment_request/payment_request.rb +53 -11
- data/lib/starkbank.rb +9 -0
- data/lib/tax_payment/log.rb +125 -0
- data/lib/tax_payment/tax_payment.rb +203 -0
- data/lib/transaction/transaction.rb +39 -6
- data/lib/transfer/log.rb +36 -5
- data/lib/transfer/transfer.rb +59 -14
- data/lib/user/organization.rb +54 -0
- data/lib/user/project.rb +11 -6
- data/lib/user/user.rb +0 -4
- data/lib/utility_payment/log.rb +36 -5
- data/lib/utility_payment/utility_payment.rb +42 -9
- data/lib/utils/api.rb +1 -0
- data/lib/utils/request.rb +1 -1
- data/lib/utils/resource.rb +2 -21
- data/lib/utils/rest.rb +29 -14
- data/lib/utils/sub_resource.rb +28 -0
- data/lib/utils/url.rb +3 -1
- data/lib/webhook/webhook.rb +30 -9
- data/lib/workspace/workspace.rb +141 -0
- metadata +17 -7
@@ -55,7 +55,7 @@ module StarkBank
|
|
55
55
|
# - transactions [list of Transaction objects]: list of Transaction objects to be created in the API
|
56
56
|
#
|
57
57
|
# ## Parameters (optional):
|
58
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
58
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
59
59
|
#
|
60
60
|
# ## Return:
|
61
61
|
# - list of Transaction objects with updated attributes
|
@@ -71,7 +71,7 @@ module StarkBank
|
|
71
71
|
# - id [string]: object unique id. ex: '5656565656565656'
|
72
72
|
#
|
73
73
|
# ## Parameters (optional):
|
74
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
74
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
75
75
|
#
|
76
76
|
# ## Return:
|
77
77
|
# - Transaction object with updated attributes
|
@@ -85,19 +85,52 @@ module StarkBank
|
|
85
85
|
#
|
86
86
|
# ## Parameters (optional):
|
87
87
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
88
|
-
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
89
|
-
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
88
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
89
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
90
90
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
91
91
|
# - external_ids [list of strings, default nil]: list of external ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
92
92
|
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
93
|
-
# - user [Project object
|
93
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
94
94
|
#
|
95
95
|
# ## Return:
|
96
96
|
# - generator of Transaction objects with updated attributes
|
97
97
|
def self.query(limit: nil, after: nil, before: nil, tags: nil, external_ids: nil, ids: nil, user: nil)
|
98
98
|
after = StarkBank::Utils::Checks.check_date(after)
|
99
99
|
before = StarkBank::Utils::Checks.check_date(before)
|
100
|
-
StarkBank::Utils::Rest.
|
100
|
+
StarkBank::Utils::Rest.get_stream(
|
101
|
+
limit: limit,
|
102
|
+
after: after,
|
103
|
+
before: before,
|
104
|
+
tags: tags,
|
105
|
+
external_ids: external_ids,
|
106
|
+
ids: ids,
|
107
|
+
user: user,
|
108
|
+
**resource
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
# # Retrieve paged Transactions
|
113
|
+
#
|
114
|
+
# Receive a list of up to 100 Transaction objects previously created in the Stark Bank API and the cursor to the next page.
|
115
|
+
# Use this function instead of query if you want to manually page your requests.
|
116
|
+
#
|
117
|
+
# ## Parameters (optional):
|
118
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
119
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
120
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
121
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
122
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
|
123
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
124
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
125
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
126
|
+
#
|
127
|
+
# ## Return:
|
128
|
+
# - list of Transaction objects with updated attributes and cursor to retrieve the next page of Transaction objects
|
129
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, tags: nil, external_ids: nil, ids: nil, user: nil)
|
130
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
131
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
132
|
+
return StarkBank::Utils::Rest.get_page(
|
133
|
+
cursor: cursor,
|
101
134
|
limit: limit,
|
102
135
|
after: after,
|
103
136
|
before: before,
|
data/lib/transfer/log.rb
CHANGED
@@ -37,7 +37,7 @@ module StarkBank
|
|
37
37
|
# - id [string]: object unique id. ex: '5656565656565656'
|
38
38
|
#
|
39
39
|
# ## Parameters (optional):
|
40
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
40
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
41
41
|
#
|
42
42
|
# ## Return:
|
43
43
|
# - Log object with updated attributes
|
@@ -51,18 +51,49 @@ module StarkBank
|
|
51
51
|
#
|
52
52
|
# ## Parameters (optional):
|
53
53
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
54
|
-
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
55
|
-
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
54
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
55
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
56
56
|
# - types [list of strings, default nil]: filter retrieved objects by types. ex: 'success' or 'failed'
|
57
57
|
# - transfer_ids [list of strings, default nil]: list of Transfer ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
58
|
-
# - user [Project object
|
58
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
59
59
|
#
|
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, transfer_ids: nil, user: nil)
|
63
63
|
after = StarkBank::Utils::Checks.check_date(after)
|
64
64
|
before = StarkBank::Utils::Checks.check_date(before)
|
65
|
-
StarkBank::Utils::Rest.
|
65
|
+
StarkBank::Utils::Rest.get_stream(
|
66
|
+
limit: limit,
|
67
|
+
after: after,
|
68
|
+
before: before,
|
69
|
+
types: types,
|
70
|
+
transfer_ids: transfer_ids,
|
71
|
+
user: user,
|
72
|
+
**resource
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
# # Retrieve paged Logs
|
77
|
+
#
|
78
|
+
# Receive a list of up to 100 Log objects previously created in the Stark Bank API and the cursor to the next page.
|
79
|
+
# Use this function instead of query if you want to manually page your requests.
|
80
|
+
#
|
81
|
+
# ## Parameters (optional):
|
82
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
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
|
+
# - types [list of strings, default nil]: filter retrieved objects by types. ex: 'success' or 'failed'
|
87
|
+
# - transfer_ids [list of strings, default nil]: list of Transfer ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
88
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
89
|
+
#
|
90
|
+
# ## Return:
|
91
|
+
# - list of Log objects with updated attributes and cursor to retrieve the next page of Log objects
|
92
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, transfer_ids: nil, user: nil)
|
93
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
94
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
95
|
+
return StarkBank::Utils::Rest.get_page(
|
96
|
+
cursor: cursor,
|
66
97
|
limit: limit,
|
67
98
|
after: after,
|
68
99
|
before: before,
|
data/lib/transfer/transfer.rb
CHANGED
@@ -17,11 +17,14 @@ module StarkBank
|
|
17
17
|
# - tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
|
18
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
|
-
# - account_number [string]:
|
20
|
+
# - account_number [string]: receiver bank account number. Use '-' before the verifier digit. ex: '876543-2'
|
21
21
|
#
|
22
22
|
# ## Parameters (optional):
|
23
|
-
# -
|
23
|
+
# - account_type [string, default 'checking']: receiver bank account type. This parameter only has effect on Pix Transfers. ex: 'checking', 'savings', 'salary' or 'payment'
|
24
|
+
# - external_id [string, default nil]: url safe string that must be unique among all your transfers. Duplicated external_ids will cause failures. By default, this parameter will block any transfer that repeats amount and receiver information on the same date. ex: 'my-internal-id-123456'
|
24
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
|
+
# - description [string, default nil]: optional description to override default description to be shown in the bank statement. ex: 'Payment for service #1234'
|
27
|
+
# - tags [list of strings]: list of strings for reference when searching for transfers. ex: ['employees', 'monthly']
|
25
28
|
#
|
26
29
|
# ## Attributes (return-only):
|
27
30
|
# - id [string, default nil]: unique id returned when Transfer is created. ex: '5656565656565656'
|
@@ -31,8 +34,8 @@ module StarkBank
|
|
31
34
|
# - created [DateTime, default nil]: creation datetime for the transfer. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
32
35
|
# - updated [DateTime, default nil]: latest update datetime for the transfer. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
33
36
|
class Transfer < StarkBank::Utils::Resource
|
34
|
-
attr_reader :amount, :name, :tax_id, :bank_code, :branch_code, :account_number, :scheduled, :transaction_ids, :fee, :tags, :status, :id, :created, :updated
|
35
|
-
def initialize(amount:, name:, tax_id:, bank_code:, branch_code:, account_number:, scheduled: nil, transaction_ids: nil, fee: nil, tags: nil, status: nil, id: nil, created: nil, updated: nil)
|
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)
|
36
39
|
super(id)
|
37
40
|
@amount = amount
|
38
41
|
@name = name
|
@@ -40,7 +43,10 @@ module StarkBank
|
|
40
43
|
@bank_code = bank_code
|
41
44
|
@branch_code = branch_code
|
42
45
|
@account_number = account_number
|
46
|
+
@account_type = account_type
|
47
|
+
@external_id = external_id
|
43
48
|
@scheduled = StarkBank::Utils::Checks.check_date_or_datetime(scheduled)
|
49
|
+
@description = description
|
44
50
|
@transaction_ids = transaction_ids
|
45
51
|
@fee = fee
|
46
52
|
@tags = tags
|
@@ -57,7 +63,7 @@ module StarkBank
|
|
57
63
|
# - transfers [list of Transfer objects]: list of Transfer objects to be created in the API
|
58
64
|
#
|
59
65
|
# ## Parameters (optional):
|
60
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
66
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
61
67
|
#
|
62
68
|
# ## Return:
|
63
69
|
# - list of Transfer objects with updated attributes
|
@@ -73,7 +79,7 @@ module StarkBank
|
|
73
79
|
# - id [string]: object unique id. ex: '5656565656565656'
|
74
80
|
#
|
75
81
|
# ## Parameters (optional):
|
76
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
82
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
77
83
|
#
|
78
84
|
# ## Return:
|
79
85
|
# - Transfer object with updated attributes
|
@@ -89,7 +95,7 @@ module StarkBank
|
|
89
95
|
# - id [string]: Transfer unique id. ex: '5656565656565656'
|
90
96
|
#
|
91
97
|
# ## Parameters (optional):
|
92
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
98
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
93
99
|
#
|
94
100
|
# ## Return:
|
95
101
|
# - deleted Transfer object
|
@@ -106,12 +112,12 @@ module StarkBank
|
|
106
112
|
# - id [string]: object unique id. ex: '5656565656565656'
|
107
113
|
#
|
108
114
|
# ## Parameters (optional):
|
109
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
115
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
110
116
|
#
|
111
117
|
# ## Return:
|
112
118
|
# - Transfer pdf file
|
113
119
|
def self.pdf(id, user: nil)
|
114
|
-
StarkBank::Utils::Rest.
|
120
|
+
StarkBank::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'pdf', **resource)
|
115
121
|
end
|
116
122
|
|
117
123
|
# # Retrieve Transfers
|
@@ -120,21 +126,57 @@ module StarkBank
|
|
120
126
|
#
|
121
127
|
# ## Parameters (optional):
|
122
128
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
123
|
-
# - after [Date, DateTime, Time or string, default nil] date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
|
124
|
-
# - before [Date, DateTime, Time or string, default nil] date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
|
129
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
|
130
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
|
125
131
|
# - transactionIds [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
126
132
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
|
127
|
-
# - tax_id [string, default nil]: filter for transfers sent to the specified tax ID. ex:
|
133
|
+
# - tax_id [string, default nil]: filter for transfers sent to the specified tax ID. ex: '012.345.678-90'
|
128
134
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
129
135
|
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
130
|
-
# - user [Project object
|
136
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
131
137
|
#
|
132
138
|
# ## Return:
|
133
139
|
# - generator of Transfer objects with updated attributes
|
134
140
|
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)
|
135
141
|
after = StarkBank::Utils::Checks.check_date(after)
|
136
142
|
before = StarkBank::Utils::Checks.check_date(before)
|
137
|
-
StarkBank::Utils::Rest.
|
143
|
+
StarkBank::Utils::Rest.get_stream(
|
144
|
+
limit: limit,
|
145
|
+
after: after,
|
146
|
+
before: before,
|
147
|
+
transaction_ids: transaction_ids,
|
148
|
+
status: status,
|
149
|
+
tax_id: tax_id,
|
150
|
+
sort: sort,
|
151
|
+
tags: tags,
|
152
|
+
ids: ids,
|
153
|
+
user: user,
|
154
|
+
**resource
|
155
|
+
)
|
156
|
+
end
|
157
|
+
|
158
|
+
# # Retrieve paged Transfers
|
159
|
+
#
|
160
|
+
# Receive a list of up to 100 Transfer objects previously created in the Stark Bank API and the cursor to the next page.
|
161
|
+
# Use this function instead of query if you want to manually page your requests.
|
162
|
+
#
|
163
|
+
# ## Parameters (optional):
|
164
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
165
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
166
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
167
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
168
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
|
169
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
170
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
171
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
172
|
+
#
|
173
|
+
# ## Return:
|
174
|
+
# - list of Transfer objects with updated attributes and cursor to retrieve the next page of Transfer objects
|
175
|
+
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 = StarkBank::Utils::Checks.check_date(after)
|
177
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
178
|
+
return StarkBank::Utils::Rest.get_page(
|
179
|
+
cursor: cursor,
|
138
180
|
limit: limit,
|
139
181
|
after: after,
|
140
182
|
before: before,
|
@@ -161,7 +203,10 @@ module StarkBank
|
|
161
203
|
bank_code: json['bank_code'],
|
162
204
|
branch_code: json['branch_code'],
|
163
205
|
account_number: json['account_number'],
|
206
|
+
account_type: json['account_type'],
|
207
|
+
external_id: json['external_id'],
|
164
208
|
scheduled: json['scheduled'],
|
209
|
+
description: json['description'],
|
165
210
|
transaction_ids: json['transaction_ids'],
|
166
211
|
fee: json['fee'],
|
167
212
|
tags: json['tags'],
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('user')
|
4
|
+
|
5
|
+
module StarkBank
|
6
|
+
# # Organization object
|
7
|
+
# The Organization object is an authentication entity for the SDK that
|
8
|
+
# represents your entire Organization, being able to access any Workspace
|
9
|
+
# underneath it and even create new Workspaces. Only a legal representative
|
10
|
+
# of your organization can register or change the Organization credentials.
|
11
|
+
# All requests to the Stark Bank API must be authenticated via an SDK user,
|
12
|
+
# which must have been previously created at the Stark Bank website
|
13
|
+
# [https://web.sandbox.starkbank.com] or [https://web.starkbank.com]
|
14
|
+
# before you can use it in this SDK. Organizations may be passed as the user parameter on
|
15
|
+
# each request or may be defined as the default user at the start (See README).
|
16
|
+
# If you are accessing a specific Workspace using Organization credentials, you should
|
17
|
+
# specify the workspace ID when building the Organization object or by request, using
|
18
|
+
# the Organization.replace(organization, workspace_id) method, which creates a copy of the organization
|
19
|
+
# object with the altered workspace ID. If you are listing or creating new Workspaces, the
|
20
|
+
# workspace_id should be nil.
|
21
|
+
#
|
22
|
+
# ## Parameters (required):
|
23
|
+
# - environment [string]: environment where the organization is being used. ex: 'sandbox' or 'production'
|
24
|
+
# - id [string]: unique id required to identify organization. ex: '5656565656565656'
|
25
|
+
# - private_key [string]: PEM string of the private key linked to the organization. ex: '-----BEGIN PUBLIC KEY-----\nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEyTIHK6jYuik6ktM9FIF3yCEYzpLjO5X/\ntqDioGM+R2RyW0QEo+1DG8BrUf4UXHSvCjtQ0yLppygz23z0yPZYfw==\n-----END PUBLIC KEY-----'
|
26
|
+
# - workspace_id [string]: unique id of the accessed Workspace, if any. ex: nil or '4848484848484848'
|
27
|
+
#
|
28
|
+
# ## Attributes (return-only):
|
29
|
+
# - pem [string]: private key in pem format. ex: '-----BEGIN PUBLIC KEY-----\nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEyTIHK6jYuik6ktM9FIF3yCEYzpLjO5X/\ntqDioGM+R2RyW0QEo+1DG8BrUf4UXHSvCjtQ0yLppygz23z0yPZYfw==\n-----END PUBLIC KEY-----'
|
30
|
+
class Organization < StarkBank::User
|
31
|
+
attr_reader :workspace_id
|
32
|
+
def initialize(id:, environment:, private_key:, workspace_id: nil)
|
33
|
+
super(environment, id, private_key)
|
34
|
+
@workspace_id = workspace_id
|
35
|
+
end
|
36
|
+
|
37
|
+
def access_id
|
38
|
+
if @workspace_id
|
39
|
+
"organization/#{@id}/workspace/#{@workspace_id}"
|
40
|
+
else
|
41
|
+
"organization/#{@id}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.replace(organization, workspace_id)
|
46
|
+
Organization.new(
|
47
|
+
environment: organization.environment,
|
48
|
+
id: organization.id,
|
49
|
+
private_key: organization.pem,
|
50
|
+
workspace_id: workspace_id
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/user/project.rb
CHANGED
@@ -5,20 +5,21 @@ require_relative('user')
|
|
5
5
|
module StarkBank
|
6
6
|
# # Project object
|
7
7
|
#
|
8
|
-
# The Project object is
|
9
|
-
#
|
8
|
+
# The Project object is an authentication entity for the SDK that is permanently
|
9
|
+
# linked to a specific Workspace.
|
10
|
+
# All requests to the Stark Bank API must be authenticated via an SDK user,
|
10
11
|
# which must have been previously created at the Stark Bank website
|
11
|
-
# [https://sandbox.
|
12
|
-
# before you can use it in this SDK. Projects may be passed as
|
12
|
+
# [https://web.sandbox.starkbank.com] or [https://web.starkbank.com]
|
13
|
+
# before you can use it in this SDK. Projects may be passed as the user parameter on
|
13
14
|
# each request or may be defined as the default user at the start (See README).
|
14
15
|
#
|
15
16
|
# ## Parameters (required):
|
16
17
|
# - id [string]: unique id required to identify project. ex: '5656565656565656'
|
17
|
-
# - private_key [
|
18
|
+
# - private_key [string]: PEM string of the private key linked to the project. ex: '-----BEGIN PUBLIC KEY-----\nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEyTIHK6jYuik6ktM9FIF3yCEYzpLjO5X/\ntqDioGM+R2RyW0QEo+1DG8BrUf4UXHSvCjtQ0yLppygz23z0yPZYfw==\n-----END PUBLIC KEY-----'
|
18
19
|
# - environment [string]: environment where the project is being used. ex: 'sandbox' or 'production'
|
19
20
|
#
|
20
21
|
# ## Attributes (return-only):
|
21
|
-
# - name [string, default ']: project name. ex: 'MyProject'
|
22
|
+
# - name [string, default '']: project name. ex: 'MyProject'
|
22
23
|
# - allowed_ips [list of strings]: list containing the strings of the ips allowed to make requests on behalf of this project. ex: ['190.190.0.50']
|
23
24
|
# - pem [string]: private key in pem format. ex: '-----BEGIN PUBLIC KEY-----\nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEyTIHK6jYuik6ktM9FIF3yCEYzpLjO5X/\ntqDioGM+R2RyW0QEo+1DG8BrUf4UXHSvCjtQ0yLppygz23z0yPZYfw==\n-----END PUBLIC KEY-----'
|
24
25
|
class Project < StarkBank::User
|
@@ -28,5 +29,9 @@ module StarkBank
|
|
28
29
|
@name = name
|
29
30
|
@allowed_ips = allowed_ips
|
30
31
|
end
|
32
|
+
|
33
|
+
def access_id
|
34
|
+
"project/#{@id}"
|
35
|
+
end
|
31
36
|
end
|
32
37
|
end
|
data/lib/user/user.rb
CHANGED
data/lib/utility_payment/log.rb
CHANGED
@@ -37,7 +37,7 @@ module StarkBank
|
|
37
37
|
# - id [string]: object unique id. ex: '5656565656565656'
|
38
38
|
#
|
39
39
|
# ## Parameters (optional):
|
40
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
40
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
41
41
|
#
|
42
42
|
# ## Return:
|
43
43
|
# - Log object with updated attributes
|
@@ -51,24 +51,55 @@ module StarkBank
|
|
51
51
|
#
|
52
52
|
# ## Parameters (optional):
|
53
53
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
54
|
-
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
55
|
-
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
54
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
55
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
56
56
|
# - types [list of strings, default nil]: filter retrieved objects by event types. ex: 'paid' or 'registered'
|
57
57
|
# - payment_ids [list of strings, default nil]: list of UtilityPayment ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
58
|
-
# - user [Project object
|
58
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
59
59
|
#
|
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
63
|
after = StarkBank::Utils::Checks.check_date(after)
|
64
64
|
before = StarkBank::Utils::Checks.check_date(before)
|
65
|
-
StarkBank::Utils::Rest.
|
65
|
+
StarkBank::Utils::Rest.get_stream(
|
66
|
+
limit: limit,
|
67
|
+
after: after,
|
68
|
+
before: before,
|
69
|
+
types: types,
|
70
|
+
payment_ids: payment_ids,
|
66
71
|
user: user,
|
72
|
+
**resource
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
# # Retrieve paged Logs
|
77
|
+
#
|
78
|
+
# Receive a list of up to 100 Log objects previously created in the Stark Bank API and the cursor to the next page.
|
79
|
+
# Use this function instead of query if you want to manually page your requests.
|
80
|
+
#
|
81
|
+
# ## Parameters (optional):
|
82
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
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
|
+
# - types [list of strings, default nil]: filter retrieved objects by event types. ex: 'paid' or 'registered'
|
87
|
+
# - payment_ids [list of strings, default nil]: list of UtilityPayment ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
88
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
89
|
+
#
|
90
|
+
# ## Return:
|
91
|
+
# - list of Log objects with updated attributes and cursor to retrieve the next page of Log objects
|
92
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil)
|
93
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
94
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
95
|
+
return StarkBank::Utils::Rest.get_page(
|
96
|
+
cursor: cursor,
|
67
97
|
limit: limit,
|
68
98
|
after: after,
|
69
99
|
before: before,
|
70
100
|
types: types,
|
71
101
|
payment_ids: payment_ids,
|
102
|
+
user: user,
|
72
103
|
**resource
|
73
104
|
)
|
74
105
|
end
|