starkbank 2.1.0.beta2 → 2.3.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 +1 -1
- data/lib/boleto/boleto.rb +8 -7
- data/lib/boleto/log.rb +2 -2
- data/lib/boleto_holmes/boleto_holmes.rb +121 -0
- data/lib/boleto_holmes/log.rb +91 -0
- data/lib/boleto_payment/boleto_payment.rb +5 -5
- data/lib/boleto_payment/log.rb +3 -3
- data/lib/brcode_payment/brcode_payment.rb +167 -0
- data/lib/brcode_payment/log.rb +94 -0
- data/lib/brcode_preview/brcode_preview.rb +77 -0
- data/lib/deposit/deposit.rb +121 -0
- data/lib/deposit/log.rb +94 -0
- data/lib/dict_key/dict_key.rb +118 -0
- data/lib/event/event.rb +12 -6
- data/lib/invoice/invoice.rb +47 -9
- data/lib/invoice/log.rb +3 -3
- data/lib/payment_request/payment_request.rb +9 -7
- data/lib/starkbank.rb +12 -0
- data/lib/transaction/transaction.rb +3 -3
- data/lib/transfer/log.rb +2 -2
- data/lib/transfer/transfer.rb +8 -8
- data/lib/user/organization.rb +54 -0
- data/lib/user/project.rb +10 -5
- data/lib/user/user.rb +0 -4
- data/lib/utility_payment/log.rb +2 -2
- data/lib/utility_payment/utility_payment.rb +5 -5
- data/lib/utils/api.rb +7 -1
- data/lib/utils/checks.rb +11 -0
- data/lib/utils/request.rb +1 -1
- data/lib/utils/rest.rb +10 -2
- data/lib/webhook/webhook.rb +8 -8
- data/lib/workspace/workspace.rb +92 -0
- metadata +13 -3
data/lib/event/event.rb
CHANGED
@@ -8,7 +8,10 @@ require_relative('../utils/checks')
|
|
8
8
|
require_relative('../utils/cache')
|
9
9
|
require_relative('../error')
|
10
10
|
require_relative('../boleto/log')
|
11
|
+
require_relative('../boleto_holmes/log')
|
11
12
|
require_relative('../invoice/log')
|
13
|
+
require_relative('../deposit/log')
|
14
|
+
require_relative('../brcode_payment/log')
|
12
15
|
require_relative('../transfer/log')
|
13
16
|
require_relative('../boleto_payment/log')
|
14
17
|
require_relative('../utility_payment/log')
|
@@ -37,9 +40,12 @@ module StarkBank
|
|
37
40
|
resource = {
|
38
41
|
'transfer': StarkBank::Transfer::Log.resource,
|
39
42
|
'invoice': StarkBank::Invoice::Log.resource,
|
43
|
+
'deposit': StarkBank::Deposit::Log.resource,
|
44
|
+
'brcode-payment': StarkBank::BrcodePayment::Log.resource,
|
40
45
|
'boleto': StarkBank::Boleto::Log.resource,
|
41
46
|
'boleto-payment': StarkBank::BoletoPayment::Log.resource,
|
42
|
-
'utility-payment': StarkBank::UtilityPayment::Log.resource
|
47
|
+
'utility-payment': StarkBank::UtilityPayment::Log.resource,
|
48
|
+
'boleto-holmes': StarkBank::BoletoHolmes::Log.resource
|
43
49
|
}[subscription.to_sym]
|
44
50
|
|
45
51
|
@log = log
|
@@ -54,7 +60,7 @@ module StarkBank
|
|
54
60
|
# - id [string]: object unique id. ex: '5656565656565656'
|
55
61
|
#
|
56
62
|
# ## Parameters (optional):
|
57
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
63
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
58
64
|
#
|
59
65
|
# ## Return:
|
60
66
|
# - Event object with updated attributes
|
@@ -71,7 +77,7 @@ module StarkBank
|
|
71
77
|
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
72
78
|
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
73
79
|
# - is_delivered [bool, default nil]: bool to filter successfully delivered events. ex: True or False
|
74
|
-
# - user [Project object
|
80
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
|
75
81
|
#
|
76
82
|
# ## Return:
|
77
83
|
# - generator of Event objects with updated attributes
|
@@ -96,7 +102,7 @@ module StarkBank
|
|
96
102
|
# - id [string]: Event unique id. ex: '5656565656565656'
|
97
103
|
#
|
98
104
|
# ## Parameters (optional):
|
99
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
105
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
100
106
|
#
|
101
107
|
# ## Return:
|
102
108
|
# - deleted Event object
|
@@ -114,7 +120,7 @@ module StarkBank
|
|
114
120
|
# - is_delivered [bool]: If True and event hasn't been delivered already, event will be set as delivered. ex: True
|
115
121
|
#
|
116
122
|
# ## Parameters (optional):
|
117
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
123
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
118
124
|
#
|
119
125
|
# ## Return:
|
120
126
|
# - target Event with updated attributes
|
@@ -133,7 +139,7 @@ module StarkBank
|
|
133
139
|
# - signature [string]: base-64 digital signature received at response header 'Digital-Signature'
|
134
140
|
#
|
135
141
|
# ## Parameters (optional):
|
136
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
142
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
137
143
|
#
|
138
144
|
# ## Return:
|
139
145
|
# - Parsed Event object
|
data/lib/invoice/invoice.rb
CHANGED
@@ -17,7 +17,7 @@ module StarkBank
|
|
17
17
|
# - name [string]: payer name. ex: 'Iron Bank S.A.'
|
18
18
|
#
|
19
19
|
# ## Parameters (optional):
|
20
|
-
# - due [DateTime or string, default
|
20
|
+
# - due [DateTime or string, default now + 2 days]: Invoice due date in UTC ISO format. ex: '2020-10-28T17:59:26.249976+00:00'
|
21
21
|
# - expiration [integer, default 5097600 (59 days)]: time interval in seconds between due date and expiration date. ex 123456789
|
22
22
|
# - fine [float, default 0.0]: Invoice fine for overdue payment in %. ex: 2.5
|
23
23
|
# - interest [float, default 0.0]: Invoice monthly interest for overdue payment in %. ex: 5.2
|
@@ -32,15 +32,16 @@ module StarkBank
|
|
32
32
|
# - interest_amount [integer, default nil]: Invoice interest value calculated over nominal_amount. ex: 10000
|
33
33
|
# - discount_amount [integer, default nil]: Invoice discount value calculated over nominal_amount. ex: 3000
|
34
34
|
# - brcode [string, default nil]: BR Code for the Invoice payment. ex: '00020101021226800014br.gov.bcb.pix2558invoice.starkbank.com/f5333103-3279-4db2-8389-5efe335ba93d5204000053039865802BR5913Arya Stark6009Sao Paulo6220051656565656565656566304A9A0'
|
35
|
+
# - fee [integer, default nil]: fee charged by the Invoice. ex: 65 (= R$ 0.65)
|
35
36
|
# - status [string, default nil]: current Invoice status. ex: 'registered' or 'paid'
|
36
37
|
# - created [DateTime, default nil]: creation datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
37
38
|
# - updated [DateTime, default nil]: latest update datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
38
39
|
class Invoice < StarkBank::Utils::Resource
|
39
|
-
attr_reader :amount, :
|
40
|
+
attr_reader :amount, :tax_id, :name, :due, :expiration, :fine, :interest, :discounts, :tags, :descriptions, :nominal_amount, :fine_amount, :interest_amount, :discount_amount, :id, :brcode, :fee, :status, :created, :updated
|
40
41
|
def initialize(
|
41
|
-
amount:,
|
42
|
+
amount:, tax_id:, name:, due: nil, expiration: nil, fine: nil, interest: nil, discounts: nil,
|
42
43
|
tags: nil, descriptions: nil, nominal_amount: nil, fine_amount: nil, interest_amount: nil,
|
43
|
-
discount_amount: nil, id: nil, brcode: nil, status: nil, created: nil, updated: nil
|
44
|
+
discount_amount: nil, id: nil, brcode: nil, fee: nil, status: nil, created: nil, updated: nil
|
44
45
|
)
|
45
46
|
super(id)
|
46
47
|
@amount = amount
|
@@ -58,6 +59,7 @@ module StarkBank
|
|
58
59
|
@interest_amount = interest_amount
|
59
60
|
@discount_amount = discount_amount
|
60
61
|
@brcode = brcode
|
62
|
+
@fee = fee
|
61
63
|
@status = status
|
62
64
|
@updated = StarkBank::Utils::Checks.check_datetime(updated)
|
63
65
|
@created = StarkBank::Utils::Checks.check_datetime(created)
|
@@ -71,7 +73,7 @@ module StarkBank
|
|
71
73
|
# - invoices [list of Invoice objects]: list of Invoice objects to be created in the API
|
72
74
|
#
|
73
75
|
# ## Parameters (optional):
|
74
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
76
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
75
77
|
#
|
76
78
|
# ## Return:
|
77
79
|
# - list of Invoice objects with updated attributes
|
@@ -87,7 +89,7 @@ module StarkBank
|
|
87
89
|
# - id [string]: object unique id. ex: '5656565656565656'
|
88
90
|
#
|
89
91
|
# ## Parameters (optional):
|
90
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
92
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
91
93
|
#
|
92
94
|
# ## Return:
|
93
95
|
# - Invoice object with updated attributes
|
@@ -95,6 +97,38 @@ module StarkBank
|
|
95
97
|
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
96
98
|
end
|
97
99
|
|
100
|
+
# # Retrieve a specific Invoice pdf file
|
101
|
+
#
|
102
|
+
# Receive a single Invoice pdf file generated in the Stark Bank API by passing its id.
|
103
|
+
#
|
104
|
+
# ## Parameters (required):
|
105
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
106
|
+
#
|
107
|
+
# ## Parameters (optional):
|
108
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
109
|
+
#
|
110
|
+
# ## Return:
|
111
|
+
# - Invoice pdf file
|
112
|
+
def self.pdf(id, user: nil)
|
113
|
+
StarkBank::Utils::Rest.get_pdf(id: id, user: user, **resource)
|
114
|
+
end
|
115
|
+
|
116
|
+
# # Retrieve a specific Invoice QR Code file
|
117
|
+
#
|
118
|
+
# Receive a single Invoice QR Code png file generated in the Stark Bank API by passing its id.
|
119
|
+
#
|
120
|
+
# ## Parameters (required):
|
121
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
122
|
+
#
|
123
|
+
# ## Parameters (optional):
|
124
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
125
|
+
#
|
126
|
+
# ## Return:
|
127
|
+
# - Invoice QR Code png blob
|
128
|
+
def self.qrcode(id, user: nil)
|
129
|
+
StarkBank::Utils::Rest.get_qrcode(id: id, user: user, **resource)
|
130
|
+
end
|
131
|
+
|
98
132
|
# # Retrieve Invoices
|
99
133
|
#
|
100
134
|
# Receive a generator of Invoice objects previously created in the Stark Bank API
|
@@ -106,7 +140,7 @@ module StarkBank
|
|
106
140
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
|
107
141
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
108
142
|
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
109
|
-
# - user [Project object
|
143
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
|
110
144
|
#
|
111
145
|
# ## Return:
|
112
146
|
# - generator of Invoice objects with updated attributes
|
@@ -133,10 +167,13 @@ module StarkBank
|
|
133
167
|
# - id [string]: Invoice unique id. ex: '5656565656565656'
|
134
168
|
#
|
135
169
|
# ## Parameters (optional):
|
136
|
-
# -
|
170
|
+
# - status [string, nil]: You may cancel the invoice by passing 'canceled' in the status
|
171
|
+
# - amount [string, nil]: Nominal amount charged by the invoice. ex: 100 (R$1.00)
|
172
|
+
# - due [datetime.date or string, default nil]: Invoice due date in UTC ISO format. ex: DateTime.new(2020, 3, 10, 10, 30, 12, 21)
|
173
|
+
# - expiration [number, default nil]: time interval in seconds between the due date and the expiration date. ex 123456789
|
137
174
|
#
|
138
175
|
# ## Return:
|
139
|
-
# -
|
176
|
+
# - updated Invoice object
|
140
177
|
def self.update(id, status: nil, amount: nil, due: nil, expiration: nil, user: nil)
|
141
178
|
StarkBank::Utils::Rest.patch_id(id: id, status: status, amount: amount, due: due, expiration: expiration, user: user, **resource)
|
142
179
|
end
|
@@ -162,6 +199,7 @@ module StarkBank
|
|
162
199
|
interest_amount: json['interest_amount'],
|
163
200
|
discount_amount: json['discount_amount'],
|
164
201
|
brcode: json['brcode'],
|
202
|
+
fee: json['fee'],
|
165
203
|
status: json['status'],
|
166
204
|
updated: json['updated'],
|
167
205
|
created: json['created'],
|
data/lib/invoice/log.rb
CHANGED
@@ -9,7 +9,7 @@ module StarkBank
|
|
9
9
|
class Invoice
|
10
10
|
# # Invoice::Log object
|
11
11
|
#
|
12
|
-
# Every time
|
12
|
+
# Every time an Invoice entity is updated, a corresponding Invoice::Log
|
13
13
|
# is generated for the entity. This log is never generated by the
|
14
14
|
# user, but it can be retrieved to check additional information
|
15
15
|
# on the Invoice.
|
@@ -38,7 +38,7 @@ module StarkBank
|
|
38
38
|
# - id [string]: object unique id. ex: '5656565656565656'
|
39
39
|
#
|
40
40
|
# ## Parameters (optional):
|
41
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
41
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
42
42
|
#
|
43
43
|
# ## Return:
|
44
44
|
# - Log object with updated attributes
|
@@ -56,7 +56,7 @@ module StarkBank
|
|
56
56
|
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
57
57
|
# - types [list of strings, default nil]: filter for log event types. ex: 'paid' or 'canceled'
|
58
58
|
# - invoice_ids [list of strings, default nil]: list of Invoice ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
59
|
-
# - user [Project object
|
59
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
|
60
60
|
#
|
61
61
|
# ## Return:
|
62
62
|
# - list of Log objects with updated attributes
|
@@ -7,17 +7,17 @@ require_relative('../utils/checks')
|
|
7
7
|
module StarkBank
|
8
8
|
# # PaymentRequest object
|
9
9
|
# A PaymentRequest is an indirect request to access a specific cash-out service
|
10
|
-
# (such as Transfer,
|
10
|
+
# (such as Transfer, BrcodePayments, etc.) which goes through the cost center
|
11
11
|
# approval flow on our website. To emit a PaymentRequest, you must direct it to
|
12
12
|
# a specific cost center by its ID, which can be retrieved on our website at the
|
13
13
|
# cost center page.
|
14
14
|
#
|
15
15
|
# ## Parameters (required):
|
16
16
|
# - center_id [String]: target cost center ID. ex: '5656565656565656'
|
17
|
-
# - payment [Transfer, BoletoPayment, UtilityPayment, Transaction or dictionary]: payment entity that should be approved and executed.
|
17
|
+
# - payment [Transfer, BrcodePayment, BoletoPayment, UtilityPayment, Transaction or dictionary]: payment entity that should be approved and executed.
|
18
18
|
#
|
19
19
|
# ## Parameters (optional):
|
20
|
-
# - type [String]: payment type, inferred from the payment parameter if it is not a dictionary. ex: 'transfer', '
|
20
|
+
# - type [String]: payment type, inferred from the payment parameter if it is not a dictionary. ex: 'transfer', 'brcode-payment'
|
21
21
|
# - due [Date, DateTime, Time or string]: Payment target date in ISO format. ex: 2020-12-31
|
22
22
|
# - tags [list of strings]: list of strings for tagging
|
23
23
|
#
|
@@ -53,7 +53,7 @@ module StarkBank
|
|
53
53
|
#
|
54
54
|
# ## Parameters
|
55
55
|
# - payment_requests [list of PaymentRequest objects]: list of PaymentRequest objects to be created in the API
|
56
|
-
# - user [Project object]: Project object. Not necessary if
|
56
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
|
57
57
|
#
|
58
58
|
# ## Return
|
59
59
|
# - list of PaymentRequest objects with updated attributes
|
@@ -73,11 +73,11 @@ module StarkBank
|
|
73
73
|
# - after [Date , DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
74
74
|
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
75
75
|
# - status [string, default '-created']: sort order considered in response. Valid options are '-created' or '-due'.
|
76
|
-
# - type [string, default nil]: payment type, inferred from the payment parameter if it is not a dictionary. ex: 'transfer', '
|
76
|
+
# - type [string, default nil]: payment type, inferred from the payment parameter if it is not a dictionary. ex: 'transfer', 'brcode-payment'
|
77
77
|
# - sort [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
78
78
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
79
79
|
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
80
|
-
# - user [Project object
|
80
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
|
81
81
|
#
|
82
82
|
# ## Return:
|
83
83
|
# - generator of PaymentRequest objects with updated attributes
|
@@ -102,14 +102,16 @@ module StarkBank
|
|
102
102
|
def parse_payment(payment:, type:)
|
103
103
|
return [payment, 'transfer'] if payment.is_a?(StarkBank::Transfer)
|
104
104
|
return [payment, 'transaction'] if payment.is_a?(StarkBank::Transaction)
|
105
|
+
return [payment, 'brcode-payment'] if payment.is_a?(StarkBank::BrcodePayment)
|
105
106
|
return [payment, 'boleto-payment'] if payment.is_a?(StarkBank::BoletoPayment)
|
106
107
|
return [payment, 'utility-payment'] if payment.is_a?(StarkBank::UtilityPayment)
|
107
108
|
|
108
|
-
raise(Exception('Payment must either be a Transfer, a Transaction, a BoletoPayment, a UtilityPayment or a hash.')) unless payment.is_a?(Hash)
|
109
|
+
raise(Exception('Payment must either be a Transfer, a Transaction, a BrcodePayment, BoletoPayment, a UtilityPayment or a hash.')) unless payment.is_a?(Hash)
|
109
110
|
|
110
111
|
resource = {
|
111
112
|
'transfer': StarkBank::Transfer.resource,
|
112
113
|
'transaction': StarkBank::Transaction.resource,
|
114
|
+
'brcode-payment': StarkBank::BrcodePayment.resource,
|
113
115
|
'boleto-payment': StarkBank::BoletoPayment.resource,
|
114
116
|
'utility-payment': StarkBank::UtilityPayment.resource
|
115
117
|
}[type.to_sym]
|
data/lib/starkbank.rb
CHANGED
@@ -2,10 +2,22 @@
|
|
2
2
|
|
3
3
|
require_relative('key')
|
4
4
|
require_relative('user/project')
|
5
|
+
require_relative('user/organization')
|
6
|
+
require_relative('workspace/workspace')
|
5
7
|
require_relative('balance/balance')
|
6
8
|
require_relative('transaction/transaction')
|
9
|
+
require_relative('invoice/invoice')
|
10
|
+
require_relative('invoice/log')
|
11
|
+
require_relative('dict_key/dict_key')
|
12
|
+
require_relative('deposit/deposit')
|
13
|
+
require_relative('deposit/log')
|
14
|
+
require_relative('brcode_preview/brcode_preview')
|
15
|
+
require_relative('brcode_payment/brcode_payment')
|
16
|
+
require_relative('brcode_payment/log')
|
7
17
|
require_relative('boleto/boleto')
|
8
18
|
require_relative('boleto/log')
|
19
|
+
require_relative('boleto_holmes/boleto_holmes')
|
20
|
+
require_relative('boleto_holmes/log')
|
9
21
|
require_relative('transfer/transfer')
|
10
22
|
require_relative('transfer/log')
|
11
23
|
require_relative('boleto_payment/boleto_payment')
|
@@ -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
|
@@ -90,7 +90,7 @@ module StarkBank
|
|
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
|
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
|
@@ -55,7 +55,7 @@ module StarkBank
|
|
55
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
|
data/lib/transfer/transfer.rb
CHANGED
@@ -15,13 +15,13 @@ 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]:
|
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
|
#
|
22
22
|
# ## Parameters (optional):
|
23
23
|
# - tags [list of strings]: list of strings for reference when searching for transfers. ex: ['employees', 'monthly']
|
24
|
-
# - 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,
|
24
|
+
# - 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)
|
25
25
|
#
|
26
26
|
# ## Attributes (return-only):
|
27
27
|
# - id [string, default nil]: unique id returned when Transfer is created. ex: '5656565656565656'
|
@@ -40,7 +40,7 @@ module StarkBank
|
|
40
40
|
@bank_code = bank_code
|
41
41
|
@branch_code = branch_code
|
42
42
|
@account_number = account_number
|
43
|
-
@scheduled = StarkBank::Utils::Checks.
|
43
|
+
@scheduled = StarkBank::Utils::Checks.check_date_or_datetime(scheduled)
|
44
44
|
@transaction_ids = transaction_ids
|
45
45
|
@fee = fee
|
46
46
|
@tags = tags
|
@@ -57,7 +57,7 @@ module StarkBank
|
|
57
57
|
# - transfers [list of Transfer objects]: list of Transfer objects to be created in the API
|
58
58
|
#
|
59
59
|
# ## Parameters (optional):
|
60
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
60
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
61
61
|
#
|
62
62
|
# ## Return:
|
63
63
|
# - list of Transfer objects with updated attributes
|
@@ -73,7 +73,7 @@ module StarkBank
|
|
73
73
|
# - id [string]: object unique id. ex: '5656565656565656'
|
74
74
|
#
|
75
75
|
# ## Parameters (optional):
|
76
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
76
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
77
77
|
#
|
78
78
|
# ## Return:
|
79
79
|
# - Transfer object with updated attributes
|
@@ -89,7 +89,7 @@ module StarkBank
|
|
89
89
|
# - id [string]: Transfer unique id. ex: '5656565656565656'
|
90
90
|
#
|
91
91
|
# ## Parameters (optional):
|
92
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
92
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
93
93
|
#
|
94
94
|
# ## Return:
|
95
95
|
# - deleted Transfer object
|
@@ -106,7 +106,7 @@ module StarkBank
|
|
106
106
|
# - id [string]: object unique id. ex: '5656565656565656'
|
107
107
|
#
|
108
108
|
# ## Parameters (optional):
|
109
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
109
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
110
110
|
#
|
111
111
|
# ## Return:
|
112
112
|
# - Transfer pdf file
|
@@ -127,7 +127,7 @@ module StarkBank
|
|
127
127
|
# - tax_id [string, default nil]: filter for transfers sent to the specified tax ID. ex: "012.345.678-90"
|
128
128
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
129
129
|
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
130
|
-
# - user [Project object
|
130
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if Starkbank.user was set before function call
|
131
131
|
#
|
132
132
|
# ## Return:
|
133
133
|
# - generator of Transfer objects with updated attributes
|
@@ -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://sandbox.web.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
|