starkbank 0.0.3 → 0.4.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/{ledger → balance}/balance.rb +2 -2
- data/lib/boleto/boleto.rb +47 -27
- data/lib/boleto/log.rb +19 -11
- data/lib/{payment/boleto/boleto.rb → boleto_payment/boleto_payment.rb} +35 -25
- data/lib/{payment/boleto → boleto_payment}/log.rb +23 -15
- data/lib/{webhook → event}/event.rb +29 -17
- data/lib/starkbank.rb +9 -8
- data/lib/{ledger → transaction}/transaction.rb +22 -19
- data/lib/transfer/log.rb +19 -11
- data/lib/transfer/transfer.rb +34 -22
- data/lib/user/project.rb +6 -6
- data/lib/{payment/utility → utility_payment}/log.rb +24 -16
- data/lib/{payment/utility/utility.rb → utility_payment/utility_payment.rb} +33 -24
- data/lib/utils/api.rb +16 -3
- data/lib/utils/checks.rb +8 -0
- data/lib/utils/request.rb +3 -1
- data/lib/utils/rest.rb +2 -1
- data/lib/webhook/webhook.rb +8 -8
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf5488ddd0ee3f98ef2a890f8f3432ce3b80b5bba5344da16d4f99339e4f2aa3
|
4
|
+
data.tar.gz: cafd89743d269f83769f250b7651bf4eecebb88c7997fdd4bf4e66ae532dd735
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 987f82173290c1dd081326dd3955a8978aabe38115b0d1885570e81eb73df3f2e381def15bdcfd726ccfca255e4b8531e096c761da563d886f1fc2334a1b938b
|
7
|
+
data.tar.gz: 730698a7e8c425c430b1b3652003c9acf54070f1e791e288b452f5e308ecc3fd7b9d42accb329a3ba5ccdde41cb95fbed4bd5c3440ea89738c50cd780f5ca71f
|
@@ -13,9 +13,9 @@ module StarkBank
|
|
13
13
|
# can be retrieved to see the available information.
|
14
14
|
#
|
15
15
|
# ## Attributes (return-only):
|
16
|
-
# - id [string, default nil]: unique id returned when
|
16
|
+
# - id [string, default nil]: unique id returned when Balance is created. ex: '5656565656565656'
|
17
17
|
# - amount [integer, default nil]: current balance amount of the workspace in cents. ex: 200 (= R$ 2.00)
|
18
|
-
# - currency [string, default nil]: currency of the current workspace. Expect others to be added eventually. ex:
|
18
|
+
# - currency [string, default nil]: currency of the current workspace. Expect others to be added eventually. ex:'BRL'
|
19
19
|
# - updated [DateTime, default nil]: update datetime for the balance. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
20
20
|
class Balance < StarkBank::Utils::Resource
|
21
21
|
attr_reader :amount, :currency, :updated
|
data/lib/boleto/boleto.rb
CHANGED
@@ -13,36 +13,40 @@ module StarkBank
|
|
13
13
|
#
|
14
14
|
# ## Parameters (required):
|
15
15
|
# - amount [integer]: Boleto value in cents. Minimum = 200 (R$2,00). ex: 1234 (= R$ 12.34)
|
16
|
-
# - name [string]: payer full name. ex:
|
17
|
-
# - tax_id [string]: payer tax ID (CPF or CNPJ) with or without formatting. ex:
|
16
|
+
# - name [string]: payer full name. ex: 'Anthony Edward Stark'
|
17
|
+
# - tax_id [string]: payer tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
|
18
18
|
# - street_line_1 [string]: payer main address. ex: Av. Paulista, 200
|
19
19
|
# - street_line_2 [string]: payer address complement. ex: Apto. 123
|
20
20
|
# - district [string]: payer address district / neighbourhood. ex: Bela Vista
|
21
21
|
# - city [string]: payer address city. ex: Rio de Janeiro
|
22
22
|
# - state_code [string]: payer address state. ex: GO
|
23
23
|
# - zip_code [string]: payer address zip code. ex: 01311-200
|
24
|
-
# - due [Date, default today + 2 days]: Boleto due date in ISO format. ex: 2020-04-30
|
25
24
|
#
|
26
25
|
# ## Parameters (optional):
|
26
|
+
# - due [Date, DateTime, Time or string, default today + 2 days]: Boleto due date in ISO format. ex: '2020-04-30'
|
27
27
|
# - fine [float, default 0.0]: Boleto fine for overdue payment in %. ex: 2.5
|
28
28
|
# - interest [float, default 0.0]: Boleto monthly interest for overdue payment in %. ex: 5.2
|
29
|
-
# - overdue_limit [integer, default 59]: limit in days for
|
30
|
-
# -
|
29
|
+
# - overdue_limit [integer, default 59]: limit in days for payment after due date. ex: 7 (max: 59)
|
30
|
+
# - receiver_name [string]: receiver (Sacador Avalista) full name. ex: 'Anthony Edward Stark'
|
31
|
+
# - receiver_tax_id [string]: receiver (Sacador Avalista) tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
|
32
|
+
# - descriptions [list of dictionaries, default nil]: list of dictionaries with 'text':string and (optional) 'amount':int pairs
|
33
|
+
# - discounts [list of dictionaries, default nil]: list of dictionaries with 'percentage':float and 'date':Date or string pairs
|
31
34
|
# - tags [list of strings]: list of strings for tagging
|
32
35
|
#
|
33
36
|
# ## Attributes (return-only):
|
34
|
-
# - id [string, default nil]: unique id returned when Boleto is created. ex:
|
37
|
+
# - id [string, default nil]: unique id returned when Boleto is created. ex: '5656565656565656'
|
35
38
|
# - fee [integer, default nil]: fee charged when Boleto is paid. ex: 200 (= R$ 2.00)
|
36
|
-
# - line [string, default nil]: generated Boleto line for payment. ex:
|
37
|
-
# - bar_code [string, default nil]: generated Boleto bar-code for payment. ex:
|
38
|
-
# - status [string, default nil]: current Boleto status. ex:
|
39
|
+
# - line [string, default nil]: generated Boleto line for payment. ex: '34191.09008 63571.277308 71444.640008 5 81960000000062'
|
40
|
+
# - bar_code [string, default nil]: generated Boleto bar-code for payment. ex: '34195819600000000621090063571277307144464000'
|
41
|
+
# - status [string, default nil]: current Boleto status. ex: 'registered' or 'paid'
|
39
42
|
# - created [DateTime, default nil]: creation datetime for the Boleto. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
40
43
|
class Boleto < StarkBank::Utils::Resource
|
41
|
-
attr_reader :amount, :name, :tax_id, :street_line_1, :street_line_2, :district, :city, :state_code, :zip_code, :due, :fine, :interest, :overdue_limit, :tags, :descriptions, :id, :fee, :line, :bar_code, :status, :created
|
44
|
+
attr_reader :amount, :name, :tax_id, :street_line_1, :street_line_2, :district, :city, :state_code, :zip_code, :due, :fine, :interest, :overdue_limit, :receiver_name, :receiver_tax_id, :tags, :descriptions, :discounts, :id, :fee, :line, :bar_code, :status, :created
|
42
45
|
def initialize(
|
43
46
|
amount:, name:, tax_id:, street_line_1:, street_line_2:, district:, city:, state_code:, zip_code:,
|
44
|
-
due: nil, fine: nil, interest: nil, overdue_limit: nil,
|
45
|
-
|
47
|
+
due: nil, fine: nil, interest: nil, overdue_limit: nil, receiver_name: nil, receiver_tax_id: nil,
|
48
|
+
tags: nil, descriptions: nil, discounts: nil, id: nil, fee: nil, line: nil, bar_code: nil,
|
49
|
+
status: nil, created: nil
|
46
50
|
)
|
47
51
|
super(id)
|
48
52
|
@amount = amount
|
@@ -58,8 +62,11 @@ module StarkBank
|
|
58
62
|
@fine = fine
|
59
63
|
@interest = interest
|
60
64
|
@overdue_limit = overdue_limit
|
65
|
+
@receiver_name = receiver_name
|
66
|
+
@receiver_tax_id = receiver_tax_id
|
61
67
|
@tags = tags
|
62
68
|
@descriptions = descriptions
|
69
|
+
@discounts = discounts
|
63
70
|
@fee = fee
|
64
71
|
@line = line
|
65
72
|
@bar_code = bar_code
|
@@ -79,7 +86,7 @@ module StarkBank
|
|
79
86
|
#
|
80
87
|
# ## Return:
|
81
88
|
# - list of Boleto objects with updated attributes
|
82
|
-
def self.create(boletos
|
89
|
+
def self.create(boletos, user: nil)
|
83
90
|
StarkBank::Utils::Rest.post(entities: boletos, user: user, **resource)
|
84
91
|
end
|
85
92
|
|
@@ -88,14 +95,14 @@ module StarkBank
|
|
88
95
|
# Receive a single Boleto object previously created in the Stark Bank API by passing its id
|
89
96
|
#
|
90
97
|
# ## Parameters (required):
|
91
|
-
# - id [string]: object unique id. ex:
|
98
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
92
99
|
#
|
93
100
|
# ## Parameters (optional):
|
94
101
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
95
102
|
#
|
96
103
|
# ## Return:
|
97
104
|
# - Boleto object with updated attributes
|
98
|
-
def self.get(id
|
105
|
+
def self.get(id, user: nil)
|
99
106
|
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
100
107
|
end
|
101
108
|
|
@@ -104,15 +111,16 @@ module StarkBank
|
|
104
111
|
# Receive a single Boleto pdf file generated in the Stark Bank API by passing its id.
|
105
112
|
#
|
106
113
|
# ## Parameters (required):
|
107
|
-
# - id [string]: object unique id. ex:
|
114
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
108
115
|
#
|
109
116
|
# ## Parameters (optional):
|
117
|
+
# - layout [string]: Layout specification. Available options are "default" and "booklet"
|
110
118
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
111
119
|
#
|
112
120
|
# ## Return:
|
113
121
|
# - Boleto pdf file
|
114
|
-
def self.pdf(id
|
115
|
-
StarkBank::Utils::Rest.get_pdf(id: id, user: user, **resource)
|
122
|
+
def self.pdf(id, layout: nil, user: nil)
|
123
|
+
StarkBank::Utils::Rest.get_pdf(id: id, layout: layout, user: user, **resource)
|
116
124
|
end
|
117
125
|
|
118
126
|
# # Retrieve Boletos
|
@@ -121,19 +129,28 @@ module StarkBank
|
|
121
129
|
#
|
122
130
|
# ## Parameters (optional):
|
123
131
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
124
|
-
# -
|
125
|
-
# -
|
126
|
-
# -
|
127
|
-
# -
|
128
|
-
# -
|
132
|
+
# - after [Date , DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
133
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
134
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
|
135
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
136
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
129
137
|
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
130
138
|
#
|
131
139
|
# ## Return:
|
132
140
|
# - generator of Boleto objects with updated attributes
|
133
|
-
def self.query(limit: nil,
|
141
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
134
142
|
after = StarkBank::Utils::Checks.check_date(after)
|
135
143
|
before = StarkBank::Utils::Checks.check_date(before)
|
136
|
-
StarkBank::Utils::Rest.get_list(
|
144
|
+
StarkBank::Utils::Rest.get_list(
|
145
|
+
limit: limit,
|
146
|
+
after: after,
|
147
|
+
before: before,
|
148
|
+
status: status,
|
149
|
+
tags: tags,
|
150
|
+
ids: ids,
|
151
|
+
user: user,
|
152
|
+
**resource
|
153
|
+
)
|
137
154
|
end
|
138
155
|
|
139
156
|
# # Delete a Boleto entity
|
@@ -141,14 +158,14 @@ module StarkBank
|
|
141
158
|
# Delete a Boleto entity previously created in the Stark Bank API
|
142
159
|
#
|
143
160
|
# ## Parameters (required):
|
144
|
-
# - id [string]: Boleto unique id. ex:
|
161
|
+
# - id [string]: Boleto unique id. ex: '5656565656565656'
|
145
162
|
#
|
146
163
|
# ## Parameters (optional):
|
147
164
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
148
165
|
#
|
149
166
|
# ## Return:
|
150
167
|
# - deleted Boleto with updated attributes
|
151
|
-
def self.delete(id
|
168
|
+
def self.delete(id, user: nil)
|
152
169
|
StarkBank::Utils::Rest.delete_id(id: id, user: user, **resource)
|
153
170
|
end
|
154
171
|
|
@@ -170,8 +187,11 @@ module StarkBank
|
|
170
187
|
fine: json['fine'],
|
171
188
|
interest: json['interest'],
|
172
189
|
overdue_limit: json['overdue_limit'],
|
190
|
+
receiver_name: json['receiver_name'],
|
191
|
+
receiver_tax_id: json['receiver_tax_id'],
|
173
192
|
tags: json['tags'],
|
174
193
|
descriptions: json['descriptions'],
|
194
|
+
discounts: json['discounts'],
|
175
195
|
id: json['id'],
|
176
196
|
fee: json['fee'],
|
177
197
|
line: json['line'],
|
data/lib/boleto/log.rb
CHANGED
@@ -15,11 +15,11 @@ module StarkBank
|
|
15
15
|
# on the Boleto.
|
16
16
|
#
|
17
17
|
# ## Attributes:
|
18
|
-
# - id [string]: unique id returned when the log is created. ex:
|
18
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
19
19
|
# - boleto [Boleto]: Boleto entity to which the log refers to.
|
20
20
|
# - errors [list of strings]: list of errors linked to this Boleto event
|
21
|
-
# - type [string]: type of the Boleto event which triggered the log creation. ex:
|
22
|
-
# - created [DateTime]: creation datetime for the
|
21
|
+
# - type [string]: type of the Boleto event which triggered the log creation. ex: 'registered' or 'paid'
|
22
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
23
23
|
class Log < StarkBank::Utils::Resource
|
24
24
|
attr_reader :id, :created, :type, :errors, :boleto
|
25
25
|
def initialize(id:, created:, type:, errors:, boleto:)
|
@@ -35,14 +35,14 @@ module StarkBank
|
|
35
35
|
# Receive a single Log object previously created by the Stark Bank API by passing its id
|
36
36
|
#
|
37
37
|
# ## Parameters (required):
|
38
|
-
# - id [string]: object unique id. ex:
|
38
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
39
39
|
#
|
40
40
|
# ## Parameters (optional):
|
41
41
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
42
42
|
#
|
43
43
|
# ## Return:
|
44
44
|
# - Log object with updated attributes
|
45
|
-
def self.get(id
|
45
|
+
def self.get(id, user: nil)
|
46
46
|
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
47
47
|
end
|
48
48
|
|
@@ -52,18 +52,26 @@ 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
|
-
# -
|
56
|
-
# -
|
57
|
-
# -
|
58
|
-
# -
|
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 'registered'
|
58
|
+
# - boleto_ids [list of strings, default nil]: list of Boleto ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
59
59
|
# - user [Project object, default nil]: 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
|
-
def self.query(limit: nil,
|
63
|
+
def self.query(limit: nil, after: nil, before: nil, types: nil, boleto_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.get_list(
|
66
|
+
StarkBank::Utils::Rest.get_list(
|
67
|
+
limit: limit,
|
68
|
+
after: after,
|
69
|
+
before: before,
|
70
|
+
types: types,
|
71
|
+
boleto_ids: boleto_ids,
|
72
|
+
user: user,
|
73
|
+
**resource
|
74
|
+
)
|
67
75
|
end
|
68
76
|
|
69
77
|
def self.resource
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('
|
4
|
-
require_relative('
|
5
|
-
require_relative('
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
6
|
|
7
7
|
module StarkBank
|
8
8
|
# # BoletoPayment object
|
@@ -12,22 +12,22 @@ module StarkBank
|
|
12
12
|
# to the Stark Bank API and returns the list of created objects.
|
13
13
|
#
|
14
14
|
# ## Parameters (conditionally required):
|
15
|
-
# - line [string, default nil]: Number sequence that describes the payment. Either 'line' or 'bar_code' parameters are required. If both are sent, they must match. ex:
|
16
|
-
# - bar_code [string, default nil]: Bar code number that describes the payment. Either 'line' or 'barCode' parameters are required. If both are sent, they must match. ex:
|
15
|
+
# - line [string, default nil]: Number sequence that describes the payment. Either 'line' or 'bar_code' parameters are required. If both are sent, they must match. ex: '34191.09008 63571.277308 71444.640008 5 81960000000062'
|
16
|
+
# - bar_code [string, default nil]: Bar code number that describes the payment. Either 'line' or 'barCode' parameters are required. If both are sent, they must match. ex: '34195819600000000621090063571277307144464000'
|
17
17
|
#
|
18
18
|
# ## Parameters (required):
|
19
|
-
# - tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex:
|
20
|
-
# - description [string]: Text to be displayed in your statement (min. 10 characters). ex:
|
19
|
+
# - tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
|
20
|
+
# - description [string]: Text to be displayed in your statement (min. 10 characters). ex: 'payment ABC'
|
21
21
|
#
|
22
22
|
# ## Parameters (optional):
|
23
|
-
# - scheduled [Date, default today]: payment scheduled date. ex: Date.new(2020, 3, 10)
|
23
|
+
# - scheduled [Date, DateTime, Time or string, default today]: payment scheduled date. ex: Date.new(2020, 3, 10)
|
24
24
|
# - tags [list of strings]: list of strings for tagging
|
25
25
|
#
|
26
26
|
# ## Attributes (return-only):
|
27
|
-
# - id [string, default nil]: unique id returned when payment is created. ex:
|
28
|
-
# - status [string, default nil]: current payment status. ex:
|
27
|
+
# - id [string, default nil]: unique id returned when payment is created. ex: '5656565656565656'
|
28
|
+
# - status [string, default nil]: current payment status. ex: 'success' or 'failed'
|
29
29
|
# - amount [int, default nil]: amount automatically calculated from line or bar_code. ex: 23456 (= R$ 234.56)
|
30
|
-
# - fee [integer, default nil]: fee charged when boleto payment is created. ex: 200 (= R$ 2.00)
|
30
|
+
# - fee [integer, default nil]: fee charged when the boleto payment is created. ex: 200 (= R$ 2.00)
|
31
31
|
# - created [DateTime, default nil]: creation datetime for the payment. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
32
32
|
class BoletoPayment < StarkBank::Utils::Resource
|
33
33
|
attr_reader :tax_id, :description, :line, :bar_code, :scheduled, :tags, :id, :status, :amount, :fee, :created
|
@@ -57,7 +57,7 @@ module StarkBank
|
|
57
57
|
#
|
58
58
|
# ## Return:
|
59
59
|
# - list of BoletoPayment objects with updated attributes
|
60
|
-
def self.create(payments
|
60
|
+
def self.create(payments, user: nil)
|
61
61
|
StarkBank::Utils::Rest.post(entities: payments, user: user, **resource)
|
62
62
|
end
|
63
63
|
|
@@ -66,31 +66,31 @@ module StarkBank
|
|
66
66
|
# Receive a single BoletoPayment object previously created by the Stark Bank API by passing its id
|
67
67
|
#
|
68
68
|
# ## Parameters (required):
|
69
|
-
# - id [string]: object unique id. ex:
|
69
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
70
70
|
#
|
71
71
|
# ## Parameters (optional):
|
72
72
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
73
73
|
#
|
74
74
|
# ## Return:
|
75
75
|
# - BoletoPayment object with updated attributes
|
76
|
-
def self.get(id
|
76
|
+
def self.get(id, user: nil)
|
77
77
|
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
78
78
|
end
|
79
79
|
|
80
80
|
# # Retrieve a specific BoletoPayment pdf file
|
81
81
|
#
|
82
82
|
# Receive a single BoletoPayment pdf file generated in the Stark Bank API by passing its id.
|
83
|
-
# Only valid for boleto payments with
|
83
|
+
# Only valid for boleto payments with 'success' status.
|
84
84
|
#
|
85
85
|
# ## Parameters (required):
|
86
|
-
# - id [string]: object unique id. ex:
|
86
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
87
87
|
#
|
88
88
|
# ## Parameters (optional):
|
89
89
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
90
90
|
#
|
91
91
|
# ## Return:
|
92
92
|
# - BoletoPayment pdf file
|
93
|
-
def self.pdf(id
|
93
|
+
def self.pdf(id, user: nil)
|
94
94
|
StarkBank::Utils::Rest.get_pdf(id: id, user: user, **resource)
|
95
95
|
end
|
96
96
|
|
@@ -100,18 +100,28 @@ module StarkBank
|
|
100
100
|
#
|
101
101
|
# ## Parameters (optional):
|
102
102
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
103
|
-
# -
|
104
|
-
# -
|
105
|
-
# -
|
106
|
-
# -
|
103
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
104
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
105
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
106
|
+
# - ids [list of strings, default nil]: list of strings to get specific entities by ids. ex: ['12376517623', '1928367198236']
|
107
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid'
|
107
108
|
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
108
109
|
#
|
109
110
|
# ## Return:
|
110
111
|
# - generator of BoletoPayment objects with updated attributes
|
111
|
-
def self.query(limit: nil,
|
112
|
+
def self.query(limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
|
112
113
|
after = StarkBank::Utils::Checks.check_date(after)
|
113
114
|
before = StarkBank::Utils::Checks.check_date(before)
|
114
|
-
StarkBank::Utils::Rest.get_list(
|
115
|
+
StarkBank::Utils::Rest.get_list(
|
116
|
+
user: user,
|
117
|
+
limit: limit,
|
118
|
+
after: after,
|
119
|
+
before: before,
|
120
|
+
tags: tags,
|
121
|
+
ids: ids,
|
122
|
+
status: status,
|
123
|
+
**resource
|
124
|
+
)
|
115
125
|
end
|
116
126
|
|
117
127
|
# # Delete a BoletoPayment entity
|
@@ -119,12 +129,12 @@ module StarkBank
|
|
119
129
|
# Delete a BoletoPayment entity previously created in the Stark Bank API
|
120
130
|
#
|
121
131
|
# Parameters (required):
|
122
|
-
# - id [string]: BoletoPayment unique id. ex:
|
132
|
+
# - id [string]: BoletoPayment unique id. ex: '5656565656565656'
|
123
133
|
# Parameters (optional):
|
124
134
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
125
135
|
# Return:
|
126
136
|
# - deleted BoletoPayment with updated attributes
|
127
|
-
def self.delete(id
|
137
|
+
def self.delete(id, user: nil)
|
128
138
|
StarkBank::Utils::Rest.delete_id(id: id, user: user, **resource)
|
129
139
|
end
|
130
140
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('
|
4
|
-
require_relative('
|
5
|
-
require_relative('
|
6
|
-
require_relative('
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
require_relative('boleto_payment')
|
7
7
|
|
8
8
|
module StarkBank
|
9
9
|
class BoletoPayment
|
@@ -15,11 +15,11 @@ module StarkBank
|
|
15
15
|
# on the BoletoPayment.
|
16
16
|
#
|
17
17
|
# ## Attributes:
|
18
|
-
# - id [string]: unique id returned when the log is created. ex:
|
18
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
19
19
|
# - payment [BoletoPayment]: BoletoPayment entity to which the log refers to.
|
20
20
|
# - errors [list of strings]: list of errors linked to this BoletoPayment event.
|
21
|
-
# - type [string]: type of the BoletoPayment event which triggered the log creation. ex:
|
22
|
-
# - created [DateTime]: creation datetime for the
|
21
|
+
# - type [string]: type of the BoletoPayment 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
23
|
class Log < StarkBank::Utils::Resource
|
24
24
|
attr_reader :id, :created, :type, :errors, :payment
|
25
25
|
def initialize(id:, created:, type:, errors:, payment:)
|
@@ -35,14 +35,14 @@ module StarkBank
|
|
35
35
|
# Receive a single Log object previously created by the Stark Bank API by passing its id
|
36
36
|
#
|
37
37
|
# ## Parameters (required):
|
38
|
-
# - id [string]: object unique id. ex:
|
38
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
39
39
|
#
|
40
40
|
# ## Parameters (optional):
|
41
41
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
42
42
|
#
|
43
43
|
# ## Return:
|
44
44
|
# - Log object with updated attributes
|
45
|
-
def self.get(id
|
45
|
+
def self.get(id, user: nil)
|
46
46
|
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
47
47
|
end
|
48
48
|
|
@@ -52,18 +52,26 @@ 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, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
56
|
-
# - before [Date, default nil] date filter for objects only before specified date. ex: Date.new(2020, 3, 10)
|
57
|
-
# -
|
58
|
-
# -
|
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 retrieved objects by event types. ex: 'paid' or 'registered'
|
58
|
+
# - payment_ids [list of strings, default nil]: list of BoletoPayment ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
59
59
|
# - user [Project object, default nil]: 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
|
-
def self.query(limit: nil, after: nil, before: nil,
|
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.get_list(
|
66
|
+
StarkBank::Utils::Rest.get_list(
|
67
|
+
limit: limit,
|
68
|
+
after: after,
|
69
|
+
before: before,
|
70
|
+
types: types,
|
71
|
+
payment_ids: payment_ids,
|
72
|
+
user: user,
|
73
|
+
**resource
|
74
|
+
)
|
67
75
|
end
|
68
76
|
|
69
77
|
def self.resource
|