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
data/lib/event/event.rb
CHANGED
@@ -15,6 +15,8 @@ require_relative('../brcode_payment/log')
|
|
15
15
|
require_relative('../transfer/log')
|
16
16
|
require_relative('../boleto_payment/log')
|
17
17
|
require_relative('../utility_payment/log')
|
18
|
+
require_relative('../tax_payment/log')
|
19
|
+
require_relative('../darf_payment/log')
|
18
20
|
|
19
21
|
module StarkBank
|
20
22
|
# # Webhook Event object
|
@@ -28,13 +30,15 @@ module StarkBank
|
|
28
30
|
# - log [Log]: a Log object from one the subscription services (TransferLog, InvoiceLog, BoletoLog, BoletoPaymentlog or UtilityPaymentLog)
|
29
31
|
# - created [DateTime]: creation datetime for the notification event. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
30
32
|
# - is_delivered [bool]: true if the event has been successfully delivered to the user url. ex: False
|
33
|
+
# - workspace_id [string]: ID of the Workspace that generated this event. Mostly used when multiple Workspaces have Webhooks registered to the same endpoint. ex: '4545454545454545'
|
31
34
|
# - subscription [string]: service that triggered this event. ex: 'transfer', 'utility-payment'
|
32
35
|
class Event < StarkBank::Utils::Resource
|
33
|
-
attr_reader :id, :log, :created, :is_delivered, :subscription
|
34
|
-
def initialize(id:, log:, created:, is_delivered:, subscription:)
|
36
|
+
attr_reader :id, :log, :created, :is_delivered, :workspace_id, :subscription
|
37
|
+
def initialize(id:, log:, created:, is_delivered:, workspace_id:, subscription:)
|
35
38
|
super(id)
|
36
39
|
@created = StarkBank::Utils::Checks.check_datetime(created)
|
37
40
|
@is_delivered = is_delivered
|
41
|
+
@workspace_id = workspace_id
|
38
42
|
@subscription = subscription
|
39
43
|
|
40
44
|
resource = {
|
@@ -45,6 +49,8 @@ module StarkBank
|
|
45
49
|
'boleto': StarkBank::Boleto::Log.resource,
|
46
50
|
'boleto-payment': StarkBank::BoletoPayment::Log.resource,
|
47
51
|
'utility-payment': StarkBank::UtilityPayment::Log.resource,
|
52
|
+
'tax-payment': StarkBank::TaxPayment::Log.resource,
|
53
|
+
'darf-payment': StarkBank::DarfPayment::Log.resource,
|
48
54
|
'boleto-holmes': StarkBank::BoletoHolmes::Log.resource
|
49
55
|
}[subscription.to_sym]
|
50
56
|
|
@@ -60,7 +66,7 @@ module StarkBank
|
|
60
66
|
# - id [string]: object unique id. ex: '5656565656565656'
|
61
67
|
#
|
62
68
|
# ## Parameters (optional):
|
63
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
69
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
64
70
|
#
|
65
71
|
# ## Return:
|
66
72
|
# - Event object with updated attributes
|
@@ -77,14 +83,14 @@ module StarkBank
|
|
77
83
|
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
78
84
|
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
79
85
|
# - is_delivered [bool, default nil]: bool to filter successfully delivered events. ex: True or False
|
80
|
-
# - user [Project object
|
86
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
81
87
|
#
|
82
88
|
# ## Return:
|
83
89
|
# - generator of Event objects with updated attributes
|
84
90
|
def self.query(limit: nil, after: nil, before: nil, is_delivered: nil, user: nil)
|
85
91
|
after = StarkBank::Utils::Checks.check_date(after)
|
86
92
|
before = StarkBank::Utils::Checks.check_date(before)
|
87
|
-
StarkBank::Utils::Rest.
|
93
|
+
StarkBank::Utils::Rest.get_stream(
|
88
94
|
user: user,
|
89
95
|
limit: limit,
|
90
96
|
after: after,
|
@@ -94,6 +100,35 @@ module StarkBank
|
|
94
100
|
)
|
95
101
|
end
|
96
102
|
|
103
|
+
# # Retrieve paged Events
|
104
|
+
#
|
105
|
+
# Receive a list of up to 100 Event objects previously created in the Stark Bank API and the cursor to the next page.
|
106
|
+
# Use this function instead of query if you want to manually page your requests.
|
107
|
+
#
|
108
|
+
# ## Parameters (optional):
|
109
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
110
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
111
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
112
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
113
|
+
# - is_delivered [bool, default nil]: bool to filter successfully delivered events. ex: True or False
|
114
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
115
|
+
#
|
116
|
+
# ## Return:
|
117
|
+
# - list of Event objects with updated attributes and cursor to retrieve the next page of Event objects
|
118
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, is_delivered: nil, user: nil)
|
119
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
120
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
121
|
+
return StarkBank::Utils::Rest.get_page(
|
122
|
+
cursor: cursor,
|
123
|
+
limit: limit,
|
124
|
+
after: after,
|
125
|
+
before: before,
|
126
|
+
is_delivered: is_delivered,
|
127
|
+
user: user,
|
128
|
+
**resource
|
129
|
+
)
|
130
|
+
end
|
131
|
+
|
97
132
|
# # Delete a notification Event
|
98
133
|
#
|
99
134
|
# Delete a of notification Event entity previously created in the Stark Bank API by its ID
|
@@ -102,7 +137,7 @@ module StarkBank
|
|
102
137
|
# - id [string]: Event unique id. ex: '5656565656565656'
|
103
138
|
#
|
104
139
|
# ## Parameters (optional):
|
105
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
140
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
106
141
|
#
|
107
142
|
# ## Return:
|
108
143
|
# - deleted Event object
|
@@ -120,7 +155,7 @@ module StarkBank
|
|
120
155
|
# - is_delivered [bool]: If True and event hasn't been delivered already, event will be set as delivered. ex: True
|
121
156
|
#
|
122
157
|
# ## Parameters (optional):
|
123
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
158
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
124
159
|
#
|
125
160
|
# ## Return:
|
126
161
|
# - target Event with updated attributes
|
@@ -139,7 +174,7 @@ module StarkBank
|
|
139
174
|
# - signature [string]: base-64 digital signature received at response header 'Digital-Signature'
|
140
175
|
#
|
141
176
|
# ## Parameters (optional):
|
142
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
177
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
143
178
|
#
|
144
179
|
# ## Return:
|
145
180
|
# - Parsed Event object
|
@@ -185,6 +220,7 @@ module StarkBank
|
|
185
220
|
log: json['log'],
|
186
221
|
created: json['created'],
|
187
222
|
is_delivered: json['is_delivered'],
|
223
|
+
workspace_id: json['workspace_id'],
|
188
224
|
subscription: json['subscription']
|
189
225
|
)
|
190
226
|
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/sub_resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
|
7
|
+
module StarkBank
|
8
|
+
# # Institution object
|
9
|
+
#
|
10
|
+
# This resource is used to get information on the institutions that are recognized by the Brazilian Central Bank.
|
11
|
+
# Besides the display name and full name, they also include the STR code (used for TEDs) and the SPI Code
|
12
|
+
# (used for Pix) for the institutions. Either of these codes may be empty if the institution is not registered on
|
13
|
+
# that Central Bank service.
|
14
|
+
#
|
15
|
+
# ## Attributes (return-only):
|
16
|
+
# - display_name [string]: short version of the institution name that should be displayed to end users. ex: 'Stark Bank'
|
17
|
+
# - name [string]: full version of the institution name. ex: 'Stark Bank S.A.'
|
18
|
+
# - spi_code [string]: SPI code used to identify the institution on Pix transactions. ex: '20018183'
|
19
|
+
# - str_code [string]: STR code used to identify the institution on TED transactions. ex: '123'
|
20
|
+
class Institution < StarkBank::Utils::SubResource
|
21
|
+
attr_reader :display_name, :name, :spi_code, :str_code
|
22
|
+
def initialize(display_name: nil, name: nil, spi_code: nil, str_code: nil)
|
23
|
+
@display_name = display_name
|
24
|
+
@name = name
|
25
|
+
@spi_code = spi_code
|
26
|
+
@str_code = str_code
|
27
|
+
end
|
28
|
+
|
29
|
+
# # Retrieve Bacen Institutions
|
30
|
+
#
|
31
|
+
# Receive a list of Institution objects that are recognized by the Brazilian Central bank for Pix and TED transactions
|
32
|
+
#
|
33
|
+
# ## Parameters (optional):
|
34
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
35
|
+
# - search [string, default nil]: part of the institution name to be searched. ex: 'stark'
|
36
|
+
# - spi_codes [list of strings, default nil]: list of SPI (Pix) codes to be searched. ex: ['20018183']
|
37
|
+
# - str_codes [list of strings, default nil]: list of STR (TED) codes to be searched. ex: ['260']
|
38
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
39
|
+
#
|
40
|
+
# ## Return:
|
41
|
+
# - list of Institution objects with updated attributes
|
42
|
+
def self.query(limit: nil, search: nil, spi_codes: nil, str_codes: nil, user: nil)
|
43
|
+
StarkBank::Utils::Rest.get_page(
|
44
|
+
limit: limit,
|
45
|
+
search: search,
|
46
|
+
spi_codes: spi_codes,
|
47
|
+
str_codes: str_codes,
|
48
|
+
user: user,
|
49
|
+
**resource
|
50
|
+
).first
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.resource
|
54
|
+
{
|
55
|
+
resource_name: 'Institution',
|
56
|
+
resource_maker: proc { |json|
|
57
|
+
Institution.new(
|
58
|
+
display_name: json['display_name'],
|
59
|
+
name: json['name'],
|
60
|
+
spi_code: json['spi_code'],
|
61
|
+
str_code: json['str_code']
|
62
|
+
)
|
63
|
+
}
|
64
|
+
}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
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
|
@@ -26,6 +26,8 @@ module StarkBank
|
|
26
26
|
# - tags [list of strings, default nil]: list of strings for tagging
|
27
27
|
#
|
28
28
|
# ## Attributes (return-only):
|
29
|
+
# - pdf [string, default nil]: public Invoice PDF URL. ex: 'https://invoice.starkbank.com/pdf/d454fa4e524441c1b0c1a729457ed9d8'
|
30
|
+
# - link [string, default nil]: public Invoice webpage URL. ex: 'https://my-workspace.sandbox.starkbank.com/invoicelink/d454fa4e524441c1b0c1a729457ed9d8'
|
29
31
|
# - id [string, default nil]: unique id returned when Invoice is created. ex: '5656565656565656'
|
30
32
|
# - nominal_amount [integer, default nil]: Invoice emission value in cents (will change if invoice is updated, but not if it's paid). ex: 400000
|
31
33
|
# - fine_amount [integer, default nil]: Invoice fine value calculated over nominal_amount. ex: 20000
|
@@ -37,11 +39,11 @@ module StarkBank
|
|
37
39
|
# - created [DateTime, default nil]: creation datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
38
40
|
# - updated [DateTime, default nil]: latest update datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
39
41
|
class Invoice < StarkBank::Utils::Resource
|
40
|
-
attr_reader :amount, :
|
42
|
+
attr_reader :amount, :tax_id, :name, :due, :expiration, :fine, :interest, :discounts, :tags, :pdf, :link, :descriptions, :nominal_amount, :fine_amount, :interest_amount, :discount_amount, :id, :brcode, :fee, :status, :transaction_ids, :created, :updated
|
41
43
|
def initialize(
|
42
|
-
amount:,
|
43
|
-
tags: nil, descriptions: nil, nominal_amount: nil, fine_amount: nil, interest_amount: nil,
|
44
|
-
discount_amount: nil, id: nil, brcode: nil, fee: nil, status: nil, created: nil, updated: nil
|
44
|
+
amount:, tax_id:, name:, due: nil, expiration: nil, fine: nil, interest: nil, discounts: nil,
|
45
|
+
tags: nil, pdf: nil, link: nil, descriptions: nil, nominal_amount: nil, fine_amount: nil, interest_amount: nil,
|
46
|
+
discount_amount: nil, id: nil, brcode: nil, fee: nil, status: nil, transaction_ids: nil, created: nil, updated: nil
|
45
47
|
)
|
46
48
|
super(id)
|
47
49
|
@amount = amount
|
@@ -53,6 +55,8 @@ module StarkBank
|
|
53
55
|
@interest = interest
|
54
56
|
@discounts = discounts
|
55
57
|
@tags = tags
|
58
|
+
@pdf = pdf
|
59
|
+
@link = link
|
56
60
|
@descriptions = descriptions
|
57
61
|
@nominal_amount = nominal_amount
|
58
62
|
@fine_amount = fine_amount
|
@@ -61,6 +65,7 @@ module StarkBank
|
|
61
65
|
@brcode = brcode
|
62
66
|
@fee = fee
|
63
67
|
@status = status
|
68
|
+
@transaction_ids = transaction_ids
|
64
69
|
@updated = StarkBank::Utils::Checks.check_datetime(updated)
|
65
70
|
@created = StarkBank::Utils::Checks.check_datetime(created)
|
66
71
|
end
|
@@ -73,7 +78,7 @@ module StarkBank
|
|
73
78
|
# - invoices [list of Invoice objects]: list of Invoice objects to be created in the API
|
74
79
|
#
|
75
80
|
# ## Parameters (optional):
|
76
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
81
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
77
82
|
#
|
78
83
|
# ## Return:
|
79
84
|
# - list of Invoice objects with updated attributes
|
@@ -89,7 +94,7 @@ module StarkBank
|
|
89
94
|
# - id [string]: object unique id. ex: '5656565656565656'
|
90
95
|
#
|
91
96
|
# ## Parameters (optional):
|
92
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
97
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
93
98
|
#
|
94
99
|
# ## Return:
|
95
100
|
# - Invoice object with updated attributes
|
@@ -105,12 +110,12 @@ module StarkBank
|
|
105
110
|
# - id [string]: object unique id. ex: '5656565656565656'
|
106
111
|
#
|
107
112
|
# ## Parameters (optional):
|
108
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
113
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
109
114
|
#
|
110
115
|
# ## Return:
|
111
116
|
# - Invoice pdf file
|
112
117
|
def self.pdf(id, user: nil)
|
113
|
-
StarkBank::Utils::Rest.
|
118
|
+
StarkBank::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'pdf', **resource)
|
114
119
|
end
|
115
120
|
|
116
121
|
# # Retrieve a specific Invoice QR Code file
|
@@ -121,12 +126,12 @@ module StarkBank
|
|
121
126
|
# - id [string]: object unique id. ex: '5656565656565656'
|
122
127
|
#
|
123
128
|
# ## Parameters (optional):
|
124
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
129
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
125
130
|
#
|
126
131
|
# ## Return:
|
127
132
|
# - Invoice QR Code png blob
|
128
133
|
def self.qrcode(id, user: nil)
|
129
|
-
StarkBank::Utils::Rest.
|
134
|
+
StarkBank::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'qrcode', **resource)
|
130
135
|
end
|
131
136
|
|
132
137
|
# # Retrieve Invoices
|
@@ -135,19 +140,52 @@ module StarkBank
|
|
135
140
|
#
|
136
141
|
# ## Parameters (optional):
|
137
142
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
138
|
-
# - after [Date
|
139
|
-
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
143
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
144
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
140
145
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
|
141
146
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
142
147
|
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
143
|
-
# - user [Project object
|
148
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
144
149
|
#
|
145
150
|
# ## Return:
|
146
151
|
# - generator of Invoice objects with updated attributes
|
147
152
|
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
148
153
|
after = StarkBank::Utils::Checks.check_date(after)
|
149
154
|
before = StarkBank::Utils::Checks.check_date(before)
|
150
|
-
StarkBank::Utils::Rest.
|
155
|
+
StarkBank::Utils::Rest.get_stream(
|
156
|
+
limit: limit,
|
157
|
+
after: after,
|
158
|
+
before: before,
|
159
|
+
status: status,
|
160
|
+
tags: tags,
|
161
|
+
ids: ids,
|
162
|
+
user: user,
|
163
|
+
**resource
|
164
|
+
)
|
165
|
+
end
|
166
|
+
|
167
|
+
# # Retrieve paged Invoices
|
168
|
+
#
|
169
|
+
# Receive a list of up to 100 Invoice objects previously created in the Stark Bank API and the cursor to the next page.
|
170
|
+
# Use this function instead of query if you want to manually page your requests.
|
171
|
+
#
|
172
|
+
# ## Parameters (optional):
|
173
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
174
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
175
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
176
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
177
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
|
178
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
179
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
180
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
181
|
+
#
|
182
|
+
# ## Return:
|
183
|
+
# - list of Invoice objects with updated attributes and cursor to retrieve the next page of Invoice objects
|
184
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
185
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
186
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
187
|
+
return StarkBank::Utils::Rest.get_page(
|
188
|
+
cursor: cursor,
|
151
189
|
limit: limit,
|
152
190
|
after: after,
|
153
191
|
before: before,
|
@@ -178,6 +216,22 @@ module StarkBank
|
|
178
216
|
StarkBank::Utils::Rest.patch_id(id: id, status: status, amount: amount, due: due, expiration: expiration, user: user, **resource)
|
179
217
|
end
|
180
218
|
|
219
|
+
# # Retrieve a specific Invoice payment information
|
220
|
+
#
|
221
|
+
# Receive the Invoice::Payment sub-resource associated with a paid Invoice.
|
222
|
+
#
|
223
|
+
# ## Parameters (required):
|
224
|
+
# - id [string]: Invoice unique id. ex: '5656565656565656'
|
225
|
+
#
|
226
|
+
# ## Parameters (optional):
|
227
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
228
|
+
#
|
229
|
+
# ## Return:
|
230
|
+
# - Invoice::Payment sub-resource
|
231
|
+
def self.payment(id, user: nil)
|
232
|
+
StarkBank::Utils::Rest.get_sub_resource(id: id, user: user, **resource, **StarkBank::Invoice::Payment.resource)
|
233
|
+
end
|
234
|
+
|
181
235
|
def self.resource
|
182
236
|
{
|
183
237
|
resource_name: 'Invoice',
|
@@ -193,6 +247,8 @@ module StarkBank
|
|
193
247
|
interest: json['interest'],
|
194
248
|
discounts: json['discounts'],
|
195
249
|
tags: json['tags'],
|
250
|
+
pdf: json['pdf'],
|
251
|
+
link: json['link'],
|
196
252
|
descriptions: json['descriptions'],
|
197
253
|
nominal_amount: json['nominal_amount'],
|
198
254
|
fine_amount: json['fine_amount'],
|
@@ -201,6 +257,7 @@ module StarkBank
|
|
201
257
|
brcode: json['brcode'],
|
202
258
|
fee: json['fee'],
|
203
259
|
status: json['status'],
|
260
|
+
transaction_ids: json['transaction_ids'],
|
204
261
|
updated: json['updated'],
|
205
262
|
created: json['created'],
|
206
263
|
)
|
data/lib/invoice/log.rb
CHANGED
@@ -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
|
@@ -52,18 +52,18 @@ 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 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
|
63
63
|
def self.query(limit: nil, after: nil, before: nil, types: nil, invoice_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
67
|
limit: limit,
|
68
68
|
after: after,
|
69
69
|
before: before,
|
@@ -74,6 +74,53 @@ module StarkBank
|
|
74
74
|
)
|
75
75
|
end
|
76
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 'registered'
|
88
|
+
# - boleto_ids [list of strings, default nil]: list of Boleto ids to filter logs. 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, invoice_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
|
+
invoice_ids: invoice_ids,
|
103
|
+
user: user,
|
104
|
+
**resource
|
105
|
+
)
|
106
|
+
end
|
107
|
+
|
108
|
+
# # Retrieve a specific Invoice::Log pdf file
|
109
|
+
#
|
110
|
+
# Receive a single Invoice::Log pdf file generated in the Stark Bank API by passing its id.
|
111
|
+
#
|
112
|
+
# ## Parameters (required):
|
113
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
114
|
+
#
|
115
|
+
# ## Parameters (optional):
|
116
|
+
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
|
117
|
+
#
|
118
|
+
# ## Return:
|
119
|
+
# - Invoice::Log pdf file
|
120
|
+
def self.pdf(id, user: nil)
|
121
|
+
StarkBank::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'pdf', **resource)
|
122
|
+
end
|
123
|
+
|
77
124
|
def self.resource
|
78
125
|
invoice_maker = StarkBank::Invoice.resource[:resource_maker]
|
79
126
|
{
|