starkbank 2.4.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 +1 -1
- data/lib/boleto/boleto.rb +49 -10
- data/lib/boleto/log.rb +35 -4
- data/lib/boleto_holmes/boleto_holmes.rb +39 -4
- data/lib/boleto_holmes/log.rb +35 -4
- data/lib/boleto_payment/boleto_payment.rb +38 -5
- data/lib/boleto_payment/log.rb +35 -4
- data/lib/brcode_payment/brcode_payment.rb +52 -13
- data/lib/brcode_payment/log.rb +35 -4
- 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 +45 -7
- data/lib/deposit/log.rb +35 -4
- data/lib/dict_key/dict_key.rb +44 -8
- data/lib/error.rb +13 -5
- data/lib/event/attempt.rb +125 -0
- data/lib/event/event.rb +40 -4
- data/lib/institution/institution.rb +67 -0
- data/lib/invoice/invoice.rb +66 -9
- data/lib/invoice/log.rb +51 -4
- data/lib/invoice/payment.rb +57 -0
- data/lib/payment_request/payment_request.rb +47 -7
- data/lib/starkbank.rb +7 -0
- data/lib/tax_payment/log.rb +125 -0
- data/lib/tax_payment/tax_payment.rb +203 -0
- data/lib/transaction/transaction.rb +37 -4
- data/lib/transfer/log.rb +35 -4
- data/lib/transfer/transfer.rb +47 -8
- data/lib/user/organization.rb +1 -1
- data/lib/user/project.rb +1 -1
- data/lib/utility_payment/log.rb +35 -4
- data/lib/utility_payment/utility_payment.rb +38 -5
- 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 +28 -12
- data/lib/utils/sub_resource.rb +28 -0
- data/lib/utils/url.rb +3 -1
- data/lib/webhook/webhook.rb +23 -2
- data/lib/workspace/workspace.rb +57 -8
- metadata +15 -7
data/lib/brcode_payment/log.rb
CHANGED
@@ -52,18 +52,49 @@ module StarkBank
|
|
52
52
|
#
|
53
53
|
# ## Parameters (optional):
|
54
54
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
55
|
-
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
56
|
-
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
55
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
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 retrieved objects by event types. ex: 'success' or 'failed'
|
58
58
|
# - payment_ids [list of strings, default nil]: list of BrcodePayment ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
59
|
-
# - user [Organization/Project object]: Organization or Project object. Not necessary if
|
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
|
63
63
|
def self.query(limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil)
|
64
64
|
after = StarkBank::Utils::Checks.check_date(after)
|
65
65
|
before = StarkBank::Utils::Checks.check_date(before)
|
66
|
-
StarkBank::Utils::Rest.
|
66
|
+
StarkBank::Utils::Rest.get_stream(
|
67
|
+
limit: limit,
|
68
|
+
after: after,
|
69
|
+
before: before,
|
70
|
+
types: types,
|
71
|
+
payment_ids: payment_ids,
|
72
|
+
user: user,
|
73
|
+
**resource
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
# # Retrieve paged Logs
|
78
|
+
#
|
79
|
+
# Receive a list of up to 100 Log objects previously created in the Stark Bank API and the cursor to the next page.
|
80
|
+
# Use this function instead of query if you want to manually page your requests.
|
81
|
+
#
|
82
|
+
# ## Parameters (optional):
|
83
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
84
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
85
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
86
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
87
|
+
# - types [list of strings, default nil]: filter retrieved objects by event types. ex: 'success' or 'failed'
|
88
|
+
# - payment_ids [list of strings, default nil]: list of BrcodePayment ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
89
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
90
|
+
#
|
91
|
+
# ## Return:
|
92
|
+
# - list of Log objects with updated attributes and cursor to retrieve the next page of Log objects
|
93
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil)
|
94
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
95
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
96
|
+
return StarkBank::Utils::Rest.get_page(
|
97
|
+
cursor: cursor,
|
67
98
|
limit: limit,
|
68
99
|
after: after,
|
69
100
|
before: before,
|
@@ -41,12 +41,12 @@ module StarkBank
|
|
41
41
|
#
|
42
42
|
# ## Parameters (optional):
|
43
43
|
# - brcodes [list of strings]: List of brcodes to preview. ex: %w[00020126580014br.gov.bcb.pix0136a629532e-7693-4846-852d-1bbff817b5a8520400005303986540510.005802BR5908T'Challa6009Sao Paulo62090505123456304B14A]
|
44
|
-
# - user [Organization/Project object]: Organization or Project object. Not necessary if
|
44
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
45
45
|
#
|
46
46
|
# ## Return:
|
47
47
|
# - generator of BrcodePreview objects with updated attributes
|
48
48
|
def self.query(limit: nil, brcodes: nil, user: nil)
|
49
|
-
StarkBank::Utils::Rest.
|
49
|
+
StarkBank::Utils::Rest.get_stream(
|
50
50
|
user: user,
|
51
51
|
limit: nil,
|
52
52
|
brcodes: brcodes,
|
@@ -0,0 +1,218 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
|
7
|
+
module StarkBank
|
8
|
+
# # DarfPayment object
|
9
|
+
#
|
10
|
+
# When you initialize a DarfPayment, the entity will not be automatically
|
11
|
+
# created in 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
|
+
# ## Parameters (required):
|
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
|
+
# - revenue_code [string]: 4-digit tax code assigned by Federal Revenue. ex: '5948'
|
18
|
+
# - tax_id [tax_id]: tax id (formatted or unformatted) of the payer. ex: '12.345.678/0001-95'
|
19
|
+
# - competence [Date, DateTime, Time or string, default today]: competence month of the service. ex: Date.new(2020, 3, 10)
|
20
|
+
# - nominal_amount [int]: amount due in cents without fee or interest. ex: 23456 (= R$ 234.56)
|
21
|
+
# - fine_amount [int]: fixed amount due in cents for fines. ex: 234 (= R$ 2.34)
|
22
|
+
# - interest_amount [int]: amount due in cents for interest. ex: 456 (= R$ 4.56)
|
23
|
+
# - due [Date, DateTime, Time or string, default today]: due date for payment. ex: Date.new(2020, 3, 10)
|
24
|
+
#
|
25
|
+
# ## Parameters (optional):
|
26
|
+
# - reference_number [string, default nil]: number assigned to the region of the tax. ex: '08.1.17.00-4'
|
27
|
+
# - scheduled [Date, DateTime, Time or string, default today]: payment scheduled date. ex: Date.new(2020, 3, 10)
|
28
|
+
# - tags [list of strings, default nil]: list of strings for tagging
|
29
|
+
#
|
30
|
+
# ## Attributes (return-only):
|
31
|
+
# - id [string, default nil]: unique id returned when payment is created. ex: '5656565656565656'
|
32
|
+
# - status [string, default nil]: current payment status. ex: 'success' or 'failed'
|
33
|
+
# - amount [int, default nil]: Total amount due calculated from other amounts. ex: 24146 (= R$ 241.46)
|
34
|
+
# - fee [integer, default nil]: fee charged when the DarfPayment is processed. ex: 0 (= R$ 0.00)
|
35
|
+
# - created [DateTime, default nil]: creation datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
36
|
+
# - updated [DateTime, default nil]: latest update datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
37
|
+
class DarfPayment < StarkBank::Utils::Resource
|
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
|
40
|
+
def initialize(
|
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
|
43
|
+
)
|
44
|
+
super(id)
|
45
|
+
@revenue_code = revenue_code
|
46
|
+
@tax_id = tax_id
|
47
|
+
@competence = StarkBank::Utils::Checks.check_date(competence)
|
48
|
+
@reference_number = reference_number
|
49
|
+
@fine_amount = fine_amount
|
50
|
+
@interest_amount = interest_amount
|
51
|
+
@due = StarkBank::Utils::Checks.check_date(due)
|
52
|
+
@description = description
|
53
|
+
@tags = tags
|
54
|
+
@scheduled = StarkBank::Utils::Checks.check_date(scheduled)
|
55
|
+
@status = status
|
56
|
+
@amount = amount
|
57
|
+
@nominal_amount = nominal_amount
|
58
|
+
@fee = fee
|
59
|
+
@updated = StarkBank::Utils::Checks.check_datetime(updated)
|
60
|
+
@created = StarkBank::Utils::Checks.check_datetime(created)
|
61
|
+
end
|
62
|
+
|
63
|
+
# # Create DarfPayments
|
64
|
+
#
|
65
|
+
# Send a list of DarfPayment objects for creation in the Stark Bank API
|
66
|
+
#
|
67
|
+
# ## Parameters (required):
|
68
|
+
# - payments [list of DarfPayment objects]: list of DarfPayment objects to be created in the API
|
69
|
+
#
|
70
|
+
# ## Parameters (optional):
|
71
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
72
|
+
#
|
73
|
+
# ## Return:
|
74
|
+
# - list of DarfPayment objects with updated attributes
|
75
|
+
def self.create(payments, user: nil)
|
76
|
+
StarkBank::Utils::Rest.post(entities: payments, user: user, **resource)
|
77
|
+
end
|
78
|
+
|
79
|
+
# # Retrieve a specific DarfPayment
|
80
|
+
#
|
81
|
+
# Receive a single DarfPayment object previously created by the Stark Bank API by passing its id
|
82
|
+
#
|
83
|
+
# ## Parameters (required):
|
84
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
85
|
+
#
|
86
|
+
# ## Parameters (optional):
|
87
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
88
|
+
#
|
89
|
+
# ## Return:
|
90
|
+
# - DarfPayment object with updated attributes
|
91
|
+
def self.get(id, user: nil)
|
92
|
+
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
93
|
+
end
|
94
|
+
|
95
|
+
# # Retrieve a specific DarfPayment pdf file
|
96
|
+
#
|
97
|
+
# Receive a single DarfPayment pdf file generated in the Stark Bank API by passing its id.
|
98
|
+
# Only valid for darf payments with 'success' status.
|
99
|
+
#
|
100
|
+
# ## Parameters (required):
|
101
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
102
|
+
#
|
103
|
+
# ## Parameters (optional):
|
104
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
105
|
+
#
|
106
|
+
# ## Return:
|
107
|
+
# - DarfPayment pdf file
|
108
|
+
def self.pdf(id, user: nil)
|
109
|
+
StarkBank::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'pdf', **resource)
|
110
|
+
end
|
111
|
+
|
112
|
+
# # Retrieve DarfPayments
|
113
|
+
#
|
114
|
+
# Receive a generator of DarfPayment objects previously created in the Stark Bank API
|
115
|
+
#
|
116
|
+
# ## Parameters (optional):
|
117
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
118
|
+
# - after [Date , DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
119
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
120
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
121
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
122
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
|
123
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
124
|
+
#
|
125
|
+
# ## Return:
|
126
|
+
# - generator of DarfPayment objects with updated attributes
|
127
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
128
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
129
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
130
|
+
StarkBank::Utils::Rest.get_stream(
|
131
|
+
limit: limit,
|
132
|
+
after: after,
|
133
|
+
before: before,
|
134
|
+
tags: tags,
|
135
|
+
ids: ids,
|
136
|
+
status: status,
|
137
|
+
user: user,
|
138
|
+
**resource
|
139
|
+
)
|
140
|
+
end
|
141
|
+
|
142
|
+
# # Retrieve paged Darf Payments
|
143
|
+
#
|
144
|
+
# Receive a list of up to 100 Darf Payment objects previously created in the Stark Bank API and the cursor to the next page.
|
145
|
+
# Use this function instead of query if you want to manually page your requests.
|
146
|
+
#
|
147
|
+
# ## Parameters (optional):
|
148
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
149
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
150
|
+
# - after [Date , DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
151
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
152
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
153
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
154
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
|
155
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
156
|
+
#
|
157
|
+
# ## Return:
|
158
|
+
# - list of Darf Payment objects with updated attributes and cursor to retrieve the next page of Darf Payment objects
|
159
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
160
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
161
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
162
|
+
return StarkBank::Utils::Rest.get_page(
|
163
|
+
cursor: cursor,
|
164
|
+
limit: limit,
|
165
|
+
after: after,
|
166
|
+
before: before,
|
167
|
+
tags: tags,
|
168
|
+
ids: ids,
|
169
|
+
status: status,
|
170
|
+
user: user,
|
171
|
+
**resource
|
172
|
+
)
|
173
|
+
end
|
174
|
+
|
175
|
+
# # Delete a DarfPayment entity
|
176
|
+
#
|
177
|
+
# Delete a DarfPayment entity previously created in the Stark Bank API
|
178
|
+
#
|
179
|
+
# ## Parameters (required):
|
180
|
+
# - id [string]: UtilityPayment unique id. ex:'5656565656565656'
|
181
|
+
#
|
182
|
+
# ## Parameters (optional):
|
183
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
184
|
+
#
|
185
|
+
# ## Return:
|
186
|
+
# - deleted TaxPayment object
|
187
|
+
def self.delete(id, user: nil)
|
188
|
+
StarkBank::Utils::Rest.delete_id(id: id, user: user, **resource)
|
189
|
+
end
|
190
|
+
|
191
|
+
def self.resource
|
192
|
+
{
|
193
|
+
resource_name: 'DarfPayment',
|
194
|
+
resource_maker: proc { |json|
|
195
|
+
DarfPayment.new(
|
196
|
+
id: json['id'],
|
197
|
+
revenue_code: json['revenue_code'],
|
198
|
+
tax_id: json['tax_id'],
|
199
|
+
competence: json['competence'],
|
200
|
+
reference_number: json['reference_number'],
|
201
|
+
fine_amount: json['fine_amount'],
|
202
|
+
interest_amount: json['interest_amount'],
|
203
|
+
due: json['due'],
|
204
|
+
description: json['description'],
|
205
|
+
tags: json['tags'],
|
206
|
+
scheduled: json['scheduled'],
|
207
|
+
status: json['status'],
|
208
|
+
amount: json['amount'],
|
209
|
+
nominal_amount: json['nominal_amount'],
|
210
|
+
fee: json['fee'],
|
211
|
+
updated: json['updated'],
|
212
|
+
created: json['created'],
|
213
|
+
)
|
214
|
+
}
|
215
|
+
}
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
require_relative('darf_payment')
|
7
|
+
|
8
|
+
module StarkBank
|
9
|
+
class DarfPayment
|
10
|
+
# # DarfPayment::Log object
|
11
|
+
#
|
12
|
+
# Every time a DarfPayment entity is updated, a corresponding DarfPayment::Log
|
13
|
+
# is generated for the entity. This log is never generated by the
|
14
|
+
# user, but it can be retrieved to check additional information
|
15
|
+
# on the DarfPayment.
|
16
|
+
#
|
17
|
+
# ## Attributes:
|
18
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
19
|
+
# - payment [DarfPayment]: DarfPayment entity to which the log refers to.
|
20
|
+
# - errors [list of strings]: list of errors linked to this DarfPayment event
|
21
|
+
# - type [string]: type of the DarfPayment event which triggered the log creation. ex: 'processing' or 'success'
|
22
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
23
|
+
class Log < StarkBank::Utils::Resource
|
24
|
+
attr_reader :id, :created, :type, :errors, :payment
|
25
|
+
def initialize(id:, created:, type:, errors:, payment:)
|
26
|
+
super(id)
|
27
|
+
@type = type
|
28
|
+
@errors = errors
|
29
|
+
@payment = payment
|
30
|
+
@created = StarkBank::Utils::Checks.check_datetime(created)
|
31
|
+
end
|
32
|
+
|
33
|
+
# # Retrieve a specific Log
|
34
|
+
#
|
35
|
+
# Receive a single Log object previously created by the Stark Bank API by passing its id
|
36
|
+
#
|
37
|
+
# ## Parameters (required):
|
38
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
39
|
+
#
|
40
|
+
# ## Parameters (optional):
|
41
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
42
|
+
#
|
43
|
+
# ## Return:
|
44
|
+
# - Log object with updated attributes
|
45
|
+
def self.get(id, user: nil)
|
46
|
+
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
47
|
+
end
|
48
|
+
|
49
|
+
# # Retrieve Logs
|
50
|
+
#
|
51
|
+
# Receive a generator of Log objects previously created in the Stark Bank API
|
52
|
+
#
|
53
|
+
# ## Parameters (optional):
|
54
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
55
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
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
|
+
# - types [list of strings, default nil]: filter for log event types. ex: 'paid' or 'canceled'
|
58
|
+
# - payment_ids [list of strings, default nil]: list of TaxPayment ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
59
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if Starkbank.user was set before function call
|
60
|
+
#
|
61
|
+
# ## Return:
|
62
|
+
# - list of Log objects with updated attributes
|
63
|
+
def self.query(limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil)
|
64
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
65
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
66
|
+
StarkBank::Utils::Rest.get_stream(
|
67
|
+
limit: limit,
|
68
|
+
after: after,
|
69
|
+
before: before,
|
70
|
+
types: types,
|
71
|
+
payment_ids: payment_ids,
|
72
|
+
user: user,
|
73
|
+
**resource
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
# # Retrieve paged Logs
|
78
|
+
#
|
79
|
+
# Receive a list of up to 100 Log objects previously created in the Stark Bank API and the cursor to the next page.
|
80
|
+
# Use this function instead of query if you want to manually page your requests.
|
81
|
+
#
|
82
|
+
# ## Parameters (optional):
|
83
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
84
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
85
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
86
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
87
|
+
# - types [list of strings, default nil]: filter for log event types. ex: 'paid' or 'canceled'
|
88
|
+
# - payment_ids [list of strings, default nil]: list of TaxPayment ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
89
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if Starkbank.user was set before function call
|
90
|
+
#
|
91
|
+
# ## Return:
|
92
|
+
# - list of Log objects with updated attributes and cursor to retrieve the next page of Log objects
|
93
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil)
|
94
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
95
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
96
|
+
return StarkBank::Utils::Rest.get_page(
|
97
|
+
cursor: cursor,
|
98
|
+
limit: limit,
|
99
|
+
after: after,
|
100
|
+
before: before,
|
101
|
+
types: types,
|
102
|
+
payment_ids: payment_ids,
|
103
|
+
user: user,
|
104
|
+
**resource
|
105
|
+
)
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.resource
|
109
|
+
darf_payment_maker = StarkBank::DarfPayment.resource[:resource_maker]
|
110
|
+
{
|
111
|
+
resource_name: 'DarfPaymentLog',
|
112
|
+
resource_maker: proc { |json|
|
113
|
+
Log.new(
|
114
|
+
id: json['id'],
|
115
|
+
created: json['created'],
|
116
|
+
type: json['type'],
|
117
|
+
errors: json['errors'],
|
118
|
+
payment: StarkBank::Utils::API.from_api_json(darf_payment_maker, json['payment'])
|
119
|
+
)
|
120
|
+
}
|
121
|
+
}
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
data/lib/deposit/deposit.rb
CHANGED
@@ -16,6 +16,7 @@ module StarkBank
|
|
16
16
|
# - bank_code [string]: payer bank code in Brazil. ex: '20018183' or '341'
|
17
17
|
# - branch_code [string]: payer bank account branch. ex: '1357-9's
|
18
18
|
# - account_number [string]: payer bank account number. ex: '876543-2'
|
19
|
+
# - account_type [string]: payer bank account type. ex: 'checking'
|
19
20
|
# - amount [integer]: Deposit value in cents. ex: 1234 (= R$ 12.34)
|
20
21
|
# - type [string]: Type of settlement that originated the deposit. ex: 'pix' or 'ted'
|
21
22
|
# - status [string]: current Deposit status. ex: 'created'
|
@@ -25,10 +26,10 @@ module StarkBank
|
|
25
26
|
# - created [datetime.datetime]: creation datetime for the Deposit. ex: datetime.datetime(2020, 12, 10, 10, 30, 0, 0)
|
26
27
|
# - updated [datetime.datetime]: latest update datetime for the Deposit. ex: datetime.datetime(2020, 12, 10, 10, 30, 0, 0)
|
27
28
|
class Deposit < StarkBank::Utils::Resource
|
28
|
-
attr_reader :id, :name, :tax_id, :bank_code, :branch_code, :account_number, :amount, :type, :status, :tags, :fee, :transaction_ids, :created, :updated
|
29
|
+
attr_reader :id, :name, :tax_id, :bank_code, :branch_code, :account_number, :account_type, :amount, :type, :status, :tags, :fee, :transaction_ids, :created, :updated
|
29
30
|
def initialize(
|
30
|
-
id:, name:, tax_id:, bank_code:, branch_code:, account_number:, amount:, type:,
|
31
|
-
transaction_ids:, created:, updated:
|
31
|
+
id:, name:, tax_id:, bank_code:, branch_code:, account_number:, account_type:, amount:, type:,
|
32
|
+
status:, tags:, fee:, transaction_ids:, created:, updated:
|
32
33
|
)
|
33
34
|
super(id)
|
34
35
|
@name = name
|
@@ -36,6 +37,7 @@ module StarkBank
|
|
36
37
|
@bank_code = bank_code
|
37
38
|
@branch_code = branch_code
|
38
39
|
@account_number = account_number
|
40
|
+
@account_type = account_type
|
39
41
|
@amount = amount
|
40
42
|
@type = type
|
41
43
|
@status = status
|
@@ -68,20 +70,55 @@ module StarkBank
|
|
68
70
|
#
|
69
71
|
# ## Parameters (optional):
|
70
72
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
71
|
-
# - after [Date
|
72
|
-
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
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
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
73
75
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
|
74
76
|
# - sort [string, default '-created']: sort order considered in response. Valid options are 'created' or '-created'.
|
75
77
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
76
78
|
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
77
|
-
# - user [Organization/Project object]: Organization or Project object. Not necessary if
|
79
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
78
80
|
#
|
79
81
|
# ## Return:
|
80
82
|
# - generator of Deposit objects with updated attributes
|
81
83
|
def self.query(limit: nil, after: nil, before: nil, status: nil, sort: nil, tags: nil, ids: nil, user: nil)
|
82
84
|
after = StarkBank::Utils::Checks.check_date(after)
|
83
85
|
before = StarkBank::Utils::Checks.check_date(before)
|
84
|
-
StarkBank::Utils::Rest.
|
86
|
+
StarkBank::Utils::Rest.get_stream(
|
87
|
+
limit: limit,
|
88
|
+
after: after,
|
89
|
+
before: before,
|
90
|
+
status: status,
|
91
|
+
sort: sort,
|
92
|
+
tags: tags,
|
93
|
+
ids: ids,
|
94
|
+
user: user,
|
95
|
+
**resource
|
96
|
+
)
|
97
|
+
end
|
98
|
+
|
99
|
+
# # Retrieve paged Deposits
|
100
|
+
#
|
101
|
+
# Receive a list of up to 100 Deposit objects previously created in the Stark Bank API and the cursor to the next page.
|
102
|
+
# Use this function instead of query if you want to manually page your requests.
|
103
|
+
#
|
104
|
+
# ## Parameters (optional):
|
105
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
106
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
107
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
108
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
109
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
|
110
|
+
# - sort [string, default '-created']: sort order considered in response. Valid options are 'created' or '-created'.
|
111
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
112
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
113
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
114
|
+
#
|
115
|
+
# ## Return:
|
116
|
+
# - list of Deposit objects with updated attributes and cursor to retrieve the next page of Deposit objects
|
117
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, sort: nil, tags: nil, ids: nil, user: nil)
|
118
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
119
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
120
|
+
return StarkBank::Utils::Rest.get_page(
|
121
|
+
cursor: cursor,
|
85
122
|
limit: limit,
|
86
123
|
after: after,
|
87
124
|
before: before,
|
@@ -105,6 +142,7 @@ module StarkBank
|
|
105
142
|
bank_code: json['bank_code'],
|
106
143
|
branch_code: json['branch_code'],
|
107
144
|
account_number: json['account_number'],
|
145
|
+
account_type: json['account_type'],
|
108
146
|
amount: json['amount'],
|
109
147
|
type: json['type'],
|
110
148
|
status: json['status'],
|