starkbank 0.1.0 → 0.4.1
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 +30 -19
- data/lib/boleto/log.rb +6 -6
- data/lib/{payment/boleto/boleto.rb → boleto_payment/boleto_payment.rb} +17 -17
- data/lib/{payment/boleto → boleto_payment}/log.rb +10 -10
- data/lib/{webhook → event}/event.rb +11 -11
- data/lib/key.rb +1 -1
- data/lib/starkbank.rb +9 -8
- data/lib/{ledger → transaction}/transaction.rb +10 -7
- data/lib/transfer/log.rb +6 -6
- data/lib/transfer/transfer.rb +11 -9
- data/lib/{payment/utility → utility_payment}/log.rb +11 -11
- data/lib/{payment/utility/utility.rb → utility_payment/utility_payment.rb} +15 -15
- 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 +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a04698bff84f2740a1ea3febaf6289e293feb7430ea580711ac166108b1633a3
|
4
|
+
data.tar.gz: 7298985a8eab4f23744f3125ef8b2c891c20fb650606e04ed76f9f05bf0863de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1135e671f73fd00669b2f8b615303196ddd9525b59837fd77ecd35c3639e305591e72dd5023a1538e32abc32bcb5ce3917ea00b662ceeaaaf2ac4e1cd4a21edb
|
7
|
+
data.tar.gz: a00a59fd6d06dbca0b7a23b23faf050357aeb75e408e8e33ad8d9f392bff3c1b31e443c92b8c767bb2294b6dab7d0f45c774cf6588ae38e0f5406e8c568a7e21
|
@@ -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
|
@@ -88,7 +95,7 @@ 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
|
@@ -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, user: nil)
|
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,8 +129,8 @@ 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
|
-
# - after [Date, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
125
|
-
# - before [Date, default nil] date filter for objects only before specified date. ex: Date.new(2020, 3, 10)
|
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)
|
126
134
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
|
127
135
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
128
136
|
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
@@ -150,7 +158,7 @@ module StarkBank
|
|
150
158
|
# Delete a Boleto entity previously created in the Stark Bank API
|
151
159
|
#
|
152
160
|
# ## Parameters (required):
|
153
|
-
# - id [string]: Boleto unique id. ex:
|
161
|
+
# - id [string]: Boleto unique id. ex: '5656565656565656'
|
154
162
|
#
|
155
163
|
# ## Parameters (optional):
|
156
164
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
@@ -179,8 +187,11 @@ module StarkBank
|
|
179
187
|
fine: json['fine'],
|
180
188
|
interest: json['interest'],
|
181
189
|
overdue_limit: json['overdue_limit'],
|
190
|
+
receiver_name: json['receiver_name'],
|
191
|
+
receiver_tax_id: json['receiver_tax_id'],
|
182
192
|
tags: json['tags'],
|
183
193
|
descriptions: json['descriptions'],
|
194
|
+
discounts: json['discounts'],
|
184
195
|
id: json['id'],
|
185
196
|
fee: json['fee'],
|
186
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,7 +35,7 @@ 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
|
@@ -52,8 +52,8 @@ 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)
|
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 'registered'
|
58
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
|
@@ -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
|
@@ -66,7 +66,7 @@ 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
|
@@ -80,10 +80,10 @@ module StarkBank
|
|
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
|
@@ -100,8 +100,8 @@ 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
|
-
# - after [Date, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
104
|
-
# - before [Date, default nil] date filter for objects only before specified date. ex: Date.new(2020, 3, 10)
|
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
105
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
106
106
|
# - ids [list of strings, default nil]: list of strings to get specific entities by ids. ex: ['12376517623', '1928367198236']
|
107
107
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid'
|
@@ -129,7 +129,7 @@ module StarkBank
|
|
129
129
|
# Delete a BoletoPayment entity previously created in the Stark Bank API
|
130
130
|
#
|
131
131
|
# Parameters (required):
|
132
|
-
# - id [string]: BoletoPayment unique id. ex:
|
132
|
+
# - id [string]: BoletoPayment unique id. ex: '5656565656565656'
|
133
133
|
# Parameters (optional):
|
134
134
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
135
135
|
# Return:
|
@@ -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,7 +35,7 @@ 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
|
@@ -52,8 +52,8 @@ 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)
|
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: 'paid' or 'registered'
|
58
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
|
@@ -9,8 +9,8 @@ require_relative('../utils/cache')
|
|
9
9
|
require_relative('../error')
|
10
10
|
require_relative('../boleto/log')
|
11
11
|
require_relative('../transfer/log')
|
12
|
-
require_relative('../
|
13
|
-
require_relative('../
|
12
|
+
require_relative('../boleto_payment/log')
|
13
|
+
require_relative('../utility_payment/log')
|
14
14
|
|
15
15
|
module StarkBank
|
16
16
|
# # Webhook Event object
|
@@ -20,11 +20,11 @@ module StarkBank
|
|
20
20
|
# list all generated updates on entities.
|
21
21
|
#
|
22
22
|
# ## Attributes:
|
23
|
-
# - id [string]: unique id returned when the
|
23
|
+
# - id [string]: unique id returned when the event is created. ex: '5656565656565656'
|
24
24
|
# - log [Log]: a Log object from one the subscription services (TransferLog, BoletoLog, BoletoPaymentlog or UtilityPaymentLog)
|
25
25
|
# - created [DateTime]: creation datetime for the notification event. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
26
26
|
# - is_delivered [bool]: true if the event has been successfully delivered to the user url. ex: False
|
27
|
-
# - subscription [string]: service that triggered this event. ex:
|
27
|
+
# - subscription [string]: service that triggered this event. ex: 'transfer', 'utility-payment'
|
28
28
|
class Event < StarkBank::Utils::Resource
|
29
29
|
attr_reader :id, :log, :created, :is_delivered, :subscription
|
30
30
|
def initialize(id:, log:, created:, is_delivered:, subscription:)
|
@@ -48,7 +48,7 @@ module StarkBank
|
|
48
48
|
# Receive a single notification Event object previously created in the Stark Bank API by passing its id
|
49
49
|
#
|
50
50
|
# ## Parameters (required):
|
51
|
-
# - id [string]: object unique id. ex:
|
51
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
52
52
|
#
|
53
53
|
# ## Parameters (optional):
|
54
54
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
@@ -65,8 +65,8 @@ module StarkBank
|
|
65
65
|
#
|
66
66
|
# ## Parameters (optional):
|
67
67
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
68
|
-
# - after [Date, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
69
|
-
# - before [Date, default nil]: date filter for objects only before specified date. ex: Date.new(2020, 3, 10)
|
68
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
69
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
70
70
|
# - is_delivered [bool, default nil]: bool to filter successfully delivered events. ex: True or False
|
71
71
|
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
72
72
|
#
|
@@ -90,7 +90,7 @@ module StarkBank
|
|
90
90
|
# Delete a of notification Event entity previously created in the Stark Bank API by its ID
|
91
91
|
#
|
92
92
|
# ## Parameters (required):
|
93
|
-
# - id [string]: Event unique id. ex:
|
93
|
+
# - id [string]: Event unique id. ex: '5656565656565656'
|
94
94
|
#
|
95
95
|
# ## Parameters (optional):
|
96
96
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
@@ -107,7 +107,7 @@ module StarkBank
|
|
107
107
|
# If is_delivered is True, the event will no longer be returned on queries with is_delivered=False.
|
108
108
|
#
|
109
109
|
# ## Parameters (required):
|
110
|
-
# - id [list of strings]: Event unique ids. ex:
|
110
|
+
# - id [list of strings]: Event unique ids. ex: '5656565656565656'
|
111
111
|
# - is_delivered [bool]: If True and event hasn't been delivered already, event will be set as delivered. ex: True
|
112
112
|
#
|
113
113
|
# ## Parameters (optional):
|
@@ -127,7 +127,7 @@ module StarkBank
|
|
127
127
|
#
|
128
128
|
# ## Parameters (required):
|
129
129
|
# - content [string]: response content from request received at user endpoint (not parsed)
|
130
|
-
# - signature [string]: base-64 digital signature received at response header
|
130
|
+
# - signature [string]: base-64 digital signature received at response header 'Digital-Signature'
|
131
131
|
#
|
132
132
|
# ## Parameters (optional):
|
133
133
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
@@ -164,7 +164,7 @@ module StarkBank
|
|
164
164
|
end
|
165
165
|
|
166
166
|
def get_public_key_pem(user)
|
167
|
-
StarkBank::Utils::Request.fetch(method: 'GET', path: 'public-key', query: {limit: 1}, user: user).json['publicKeys'][0]['content']
|
167
|
+
StarkBank::Utils::Request.fetch(method: 'GET', path: 'public-key', query: { limit: 1 }, user: user).json['publicKeys'][0]['content']
|
168
168
|
end
|
169
169
|
|
170
170
|
def resource
|
data/lib/key.rb
CHANGED
data/lib/starkbank.rb
CHANGED
@@ -2,21 +2,22 @@
|
|
2
2
|
|
3
3
|
require_relative('key')
|
4
4
|
require_relative('user/project')
|
5
|
-
require_relative('
|
6
|
-
require_relative('
|
5
|
+
require_relative('balance/balance')
|
6
|
+
require_relative('transaction/transaction')
|
7
7
|
require_relative('boleto/boleto')
|
8
8
|
require_relative('boleto/log')
|
9
9
|
require_relative('transfer/transfer')
|
10
10
|
require_relative('transfer/log')
|
11
|
-
require_relative('
|
12
|
-
require_relative('
|
13
|
-
require_relative('
|
14
|
-
require_relative('
|
11
|
+
require_relative('boleto_payment/boleto_payment')
|
12
|
+
require_relative('boleto_payment/log')
|
13
|
+
require_relative('utility_payment/utility_payment')
|
14
|
+
require_relative('utility_payment/log')
|
15
15
|
require_relative('webhook/webhook')
|
16
|
-
require_relative('
|
16
|
+
require_relative('event/event')
|
17
17
|
|
18
18
|
# SDK to facilitate Ruby integrations with Stark Bank
|
19
19
|
module StarkBank
|
20
20
|
@user = nil
|
21
|
-
|
21
|
+
@language = 'en-US'
|
22
|
+
class << self; attr_accessor :user, :language; end
|
22
23
|
end
|
@@ -28,11 +28,12 @@ module StarkBank
|
|
28
28
|
# - sender_id [string]: unique id of the sending workspace. ex: '5656565656565656'
|
29
29
|
# - source [string, default nil]: locator of the entity that generated the transaction. ex: 'charge/1827351876292', 'transfer/92873912873/chargeback'
|
30
30
|
# - id [string, default nil]: unique id returned when Transaction is created. ex: '7656565656565656'
|
31
|
-
# - fee [integer, default nil]: fee charged when
|
31
|
+
# - fee [integer, default nil]: fee charged when transaction is created. ex: 200 (= R$ 2.00)
|
32
|
+
# - balance [integer, default nil]: account balance after transaction was processed. ex: 100000000 (= R$ 1,000,000.00)
|
32
33
|
# - created [DateTime, default nil]: creation datetime for the boleto. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
33
34
|
class Transaction < StarkBank::Utils::Resource
|
34
35
|
attr_reader :amount, :description, :external_id, :receiver_id, :sender_id, :tags, :id, :fee, :created, :source
|
35
|
-
def initialize(amount:, description:, external_id:, receiver_id:, sender_id: nil, tags: nil, id: nil, fee: nil,
|
36
|
+
def initialize(amount:, description:, external_id:, receiver_id:, sender_id: nil, tags: nil, id: nil, fee: nil, source: nil, balance: nil, created: nil)
|
36
37
|
super(id)
|
37
38
|
@amount = amount
|
38
39
|
@description = description
|
@@ -42,6 +43,7 @@ module StarkBank
|
|
42
43
|
@tags = tags
|
43
44
|
@fee = fee
|
44
45
|
@source = source
|
46
|
+
@balance = balance
|
45
47
|
@created = StarkBank::Utils::Checks.check_datetime(created)
|
46
48
|
end
|
47
49
|
|
@@ -66,7 +68,7 @@ module StarkBank
|
|
66
68
|
# Receive a single Transaction object previously created in the Stark Bank API by passing its id
|
67
69
|
#
|
68
70
|
# ## Parameters (required):
|
69
|
-
# - id [string]: object unique id. ex:
|
71
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
70
72
|
#
|
71
73
|
# ## Parameters (optional):
|
72
74
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
@@ -83,8 +85,8 @@ module StarkBank
|
|
83
85
|
#
|
84
86
|
# ## Parameters (optional):
|
85
87
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
86
|
-
# - after [Date, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
87
|
-
# - before [Date, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
88
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
89
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
88
90
|
# - external_ids [list of strings, default nil]: list of external ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
89
91
|
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
90
92
|
#
|
@@ -109,8 +111,9 @@ module StarkBank
|
|
109
111
|
tags: json['tags'],
|
110
112
|
id: json['id'],
|
111
113
|
fee: json['fee'],
|
112
|
-
|
113
|
-
|
114
|
+
source: json['source'],
|
115
|
+
balance: json['balance'],
|
116
|
+
created: json['created']
|
114
117
|
)
|
115
118
|
}
|
116
119
|
}
|
data/lib/transfer/log.rb
CHANGED
@@ -14,11 +14,11 @@ module StarkBank
|
|
14
14
|
# user.
|
15
15
|
#
|
16
16
|
# ## Attributes:
|
17
|
-
# - id [string]: unique id returned when the log is created. ex:
|
17
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
18
18
|
# - transfer [Transfer]: Transfer entity to which the log refers to.
|
19
19
|
# - errors [list of strings]: list of errors linked to this BoletoPayment event.
|
20
|
-
# - type [string]: type of the Transfer event which triggered the log creation. ex:
|
21
|
-
# - created [DateTime]: creation datetime for the
|
20
|
+
# - type [string]: type of the Transfer event which triggered the log creation. ex: 'processing' or 'success'
|
21
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
22
22
|
class Log < StarkBank::Utils::Resource
|
23
23
|
attr_reader :id, :created, :type, :errors, :transfer
|
24
24
|
def initialize(id:, created:, type:, errors:, transfer:)
|
@@ -34,7 +34,7 @@ module StarkBank
|
|
34
34
|
# Receive a single Log object previously created by the Stark Bank API by passing its id
|
35
35
|
#
|
36
36
|
# ## Parameters (required):
|
37
|
-
# - id [string]: object unique id. ex:
|
37
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
38
38
|
#
|
39
39
|
# ## Parameters (optional):
|
40
40
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
@@ -51,8 +51,8 @@ module StarkBank
|
|
51
51
|
#
|
52
52
|
# ## Parameters (optional):
|
53
53
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
54
|
-
# - after [Date, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
55
|
-
# - before [Date, default nil] date filter for objects only before specified date. ex: Date.new(2020, 3, 10)
|
54
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
55
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
56
56
|
# - types [list of strings, default nil]: filter retrieved objects by types. ex: 'success' or 'failed'
|
57
57
|
# - transfer_ids [list of strings, default nil]: list of Transfer ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
58
58
|
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
data/lib/transfer/transfer.rb
CHANGED
@@ -15,7 +15,7 @@ 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]: 1 to 3 digits of the receiver bank institution in Brazil. ex: '200' or '341'
|
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
|
#
|
@@ -25,7 +25,7 @@ module StarkBank
|
|
25
25
|
# ## Attributes (return-only):
|
26
26
|
# - id [string, default nil]: unique id returned when Transfer is created. ex: '5656565656565656'
|
27
27
|
# - fee [integer, default nil]: fee charged when transfer is created. ex: 200 (= R$ 2.00)
|
28
|
-
# - status [string, default nil]: current
|
28
|
+
# - status [string, default nil]: current transfer status. ex: 'success' or 'failed'
|
29
29
|
# - transaction_ids [list of strings, default nil]: ledger transaction ids linked to this transfer (if there are two, second is the chargeback). ex: ['19827356981273']
|
30
30
|
# - created [DateTime, default nil]: creation datetime for the transfer. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
31
31
|
# - updated [DateTime, default nil]: latest update datetime for the transfer. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
@@ -68,7 +68,7 @@ module StarkBank
|
|
68
68
|
# Receive a single Transfer object previously created in the Stark Bank API by passing its id
|
69
69
|
#
|
70
70
|
# ## Parameters (required):
|
71
|
-
# - id [string]: object unique id. ex:
|
71
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
72
72
|
#
|
73
73
|
# ## Parameters (optional):
|
74
74
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
@@ -82,10 +82,10 @@ module StarkBank
|
|
82
82
|
# # Retrieve a specific Transfer pdf file
|
83
83
|
#
|
84
84
|
# Receive a single Transfer pdf receipt file generated in the Stark Bank API by passing its id.
|
85
|
-
# Only valid for transfers with
|
85
|
+
# Only valid for transfers with 'processing' and 'success' status.
|
86
86
|
#
|
87
87
|
# ## Parameters (required):
|
88
|
-
# - id [string]: object unique id. ex:
|
88
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
89
89
|
#
|
90
90
|
# ## Parameters (optional):
|
91
91
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
@@ -102,16 +102,17 @@ module StarkBank
|
|
102
102
|
#
|
103
103
|
# ## Parameters (optional):
|
104
104
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
105
|
-
# - after [Date, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
106
|
-
# - before [Date, default nil] date filter for objects only before specified date. ex: Date.new(2020, 3, 10)
|
105
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
|
106
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
|
107
107
|
# - transactionIds [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
108
|
-
# - status [string, default nil]: filter for status of retrieved objects. ex: '
|
108
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
|
109
|
+
# - tax_id [string, default nil]: filter for transfers sent to the specified tax ID. ex: "012.345.678-90"
|
109
110
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
110
111
|
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
111
112
|
#
|
112
113
|
# ## Return:
|
113
114
|
# - generator of Transfer objects with updated attributes
|
114
|
-
def self.query(limit: nil, after: nil, before: nil, transaction_ids: nil, status: nil, sort: nil, tags: nil, user: nil)
|
115
|
+
def self.query(limit: nil, after: nil, before: nil, transaction_ids: nil, status: nil, tax_id: nil, sort: nil, tags: nil, user: nil)
|
115
116
|
after = StarkBank::Utils::Checks.check_date(after)
|
116
117
|
before = StarkBank::Utils::Checks.check_date(before)
|
117
118
|
StarkBank::Utils::Rest.get_list(
|
@@ -120,6 +121,7 @@ module StarkBank
|
|
120
121
|
before: before,
|
121
122
|
transaction_ids: transaction_ids,
|
122
123
|
status: status,
|
124
|
+
tax_id: tax_id,
|
123
125
|
sort: sort,
|
124
126
|
tags: tags,
|
125
127
|
user: user,
|
@@ -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('utility_payment')
|
7
7
|
|
8
8
|
module StarkBank
|
9
9
|
class UtilityPayment
|
@@ -14,11 +14,11 @@ module StarkBank
|
|
14
14
|
# be retrieved to check additional information on the UtilityPayment.
|
15
15
|
#
|
16
16
|
# ## Attributes:
|
17
|
-
# - id [string]: unique id returned when the log is created. ex:
|
17
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
18
18
|
# - payment [UtilityPayment]: UtilityPayment entity to which the log refers to.
|
19
|
-
# - errors [list of strings]: list of errors linked to this
|
20
|
-
# - type [string]: type of the UtilityPayment event which triggered the log creation. ex:
|
21
|
-
# - created [DateTime]: creation datetime for the
|
19
|
+
# - errors [list of strings]: list of errors linked to this UtilityPayment event.
|
20
|
+
# - type [string]: type of the UtilityPayment event which triggered the log creation. ex: 'processing' or 'success'
|
21
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
22
22
|
class Log < StarkBank::Utils::Resource
|
23
23
|
attr_reader :id, :created, :type, :errors, :payment
|
24
24
|
def initialize(id:, created:, type:, errors:, payment:)
|
@@ -34,7 +34,7 @@ module StarkBank
|
|
34
34
|
# Receive a single Log object previously created by the Stark Bank API by passing its id
|
35
35
|
#
|
36
36
|
# ## Parameters (required):
|
37
|
-
# - id [string]: object unique id. ex:
|
37
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
38
38
|
#
|
39
39
|
# ## Parameters (optional):
|
40
40
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
@@ -51,8 +51,8 @@ module StarkBank
|
|
51
51
|
#
|
52
52
|
# ## Parameters (optional):
|
53
53
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
54
|
-
# - after [Date, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
55
|
-
# - before [Date, default nil] date filter for objects only before specified date. ex: Date.new(2020, 3, 10)
|
54
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
55
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
56
56
|
# - types [list of strings, default nil]: filter retrieved objects by event types. ex: 'paid' or 'registered'
|
57
57
|
# - payment_ids [list of strings, default nil]: list of UtilityPayment ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
58
58
|
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
@@ -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
|
# # UtilityPayment object
|
@@ -12,19 +12,19 @@ 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
|
-
# - description [string]: Text to be displayed in your statement (min. 10 characters). ex:
|
19
|
+
# - description [string]: Text to be displayed in your statement (min. 10 characters). ex: 'payment ABC'
|
20
20
|
#
|
21
21
|
# ## Parameters (optional):
|
22
|
-
# - scheduled [Date, default today]: payment scheduled date. ex: Date.new(2020, 3, 10)
|
22
|
+
# - scheduled [Date, DateTime, Time or string, default today]: payment scheduled date. ex: Date.new(2020, 3, 10)
|
23
23
|
# - tags [list of strings]: list of strings for tagging
|
24
24
|
#
|
25
25
|
# ## Attributes (return-only):
|
26
|
-
# - id [string, default nil]: unique id returned when payment is created. ex:
|
27
|
-
# - status [string, default nil]: current payment status. ex:
|
26
|
+
# - id [string, default nil]: unique id returned when payment is created. ex: '5656565656565656'
|
27
|
+
# - status [string, default nil]: current payment status. ex: 'success' or 'failed'
|
28
28
|
# - amount [int, default nil]: amount automatically calculated from line or bar_code. ex: 23456 (= R$ 234.56)
|
29
29
|
# - fee [integer, default nil]: fee charged when utility payment is created. ex: 200 (= R$ 2.00)
|
30
30
|
# - created [DateTime, default nil]: creation datetime for the payment. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
@@ -64,7 +64,7 @@ module StarkBank
|
|
64
64
|
# Receive a single UtilityPayment object previously created by the Stark Bank API by passing its id
|
65
65
|
#
|
66
66
|
# ## Parameters (required):
|
67
|
-
# - id [string]: object unique id. ex:
|
67
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
68
68
|
#
|
69
69
|
# ## Parameters (optional):
|
70
70
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
@@ -78,10 +78,10 @@ module StarkBank
|
|
78
78
|
# # Retrieve a specific UtilityPayment pdf file
|
79
79
|
#
|
80
80
|
# Receive a single UtilityPayment pdf file generated in the Stark Bank API by passing its id.
|
81
|
-
# Only valid for utility payments with
|
81
|
+
# Only valid for utility payments with 'success' status.
|
82
82
|
#
|
83
83
|
# ## Parameters (required):
|
84
|
-
# - id [string]: object unique id. ex:
|
84
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
85
85
|
#
|
86
86
|
# ## Parameters (optional):
|
87
87
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
@@ -98,8 +98,8 @@ module StarkBank
|
|
98
98
|
#
|
99
99
|
# ## Parameters (optional):
|
100
100
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
101
|
-
# - after [Date, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
102
|
-
# - before [Date, default nil] date filter for objects only before specified date. ex: Date.new(2020, 3, 10)
|
101
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
102
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
103
103
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
104
104
|
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
105
105
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid'
|
@@ -127,7 +127,7 @@ module StarkBank
|
|
127
127
|
# Delete a UtilityPayment entity previously created in the Stark Bank API
|
128
128
|
#
|
129
129
|
# ## Parameters (required):
|
130
|
-
# - id [string]: UtilityPayment unique id. ex:
|
130
|
+
# - id [string]: UtilityPayment unique id. ex:'5656565656565656'
|
131
131
|
#
|
132
132
|
# ## Parameters (optional):
|
133
133
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
data/lib/utils/api.rb
CHANGED
@@ -6,9 +6,13 @@ module StarkBank
|
|
6
6
|
module Utils
|
7
7
|
module API
|
8
8
|
def self.api_json(entity)
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
if entity.is_a?(Hash)
|
10
|
+
entity_hash = entity
|
11
|
+
else
|
12
|
+
entity_hash = {}
|
13
|
+
entity.instance_variables.each do |key|
|
14
|
+
entity_hash[key[1..-1]] = entity.instance_variable_get(key)
|
15
|
+
end
|
12
16
|
end
|
13
17
|
cast_json_to_api_format(entity_hash)
|
14
18
|
end
|
@@ -19,6 +23,15 @@ module StarkBank
|
|
19
23
|
next if value.nil?
|
20
24
|
|
21
25
|
value = value.is_a?(Date) || value.is_a?(DateTime) || value.is_a?(Time) ? value.strftime('%Y-%m-%d') : value
|
26
|
+
|
27
|
+
if value.is_a?(Array)
|
28
|
+
list = []
|
29
|
+
value.each do |v|
|
30
|
+
list << (v.is_a?(Hash) ? cast_json_to_api_format(v) : v)
|
31
|
+
end
|
32
|
+
value = list
|
33
|
+
end
|
34
|
+
|
22
35
|
entity_hash[StarkBank::Utils::Case.snake_to_camel(key)] = value
|
23
36
|
end
|
24
37
|
entity_hash
|
data/lib/utils/checks.rb
CHANGED
@@ -17,6 +17,14 @@ module StarkBank
|
|
17
17
|
user
|
18
18
|
end
|
19
19
|
|
20
|
+
def self.check_language
|
21
|
+
language = StarkBank.language
|
22
|
+
accepted_languages = %w[en-US pt-BR]
|
23
|
+
raise(ArgumentError, "Select a valid language: #{accepted_languages.join(', ')}") unless accepted_languages.include?(language)
|
24
|
+
|
25
|
+
language
|
26
|
+
end
|
27
|
+
|
20
28
|
def self.check_environment(environment)
|
21
29
|
environments = StarkBank::Utils::Environment.constants(false).map { |c| StarkBank::Utils::Environment.const_get(c) }
|
22
30
|
raise(ArgumentError, "Select a valid environment: #{environments.join(', ')}") unless environments.include?(environment)
|
data/lib/utils/request.rb
CHANGED
@@ -24,6 +24,7 @@ module StarkBank
|
|
24
24
|
|
25
25
|
def self.fetch(method:, path:, payload: nil, query: nil, user: nil)
|
26
26
|
user = Checks.check_user(user)
|
27
|
+
language = Checks.check_language
|
27
28
|
|
28
29
|
base_url = {
|
29
30
|
Environment::PRODUCTION => 'https://api.starkbank.com/',
|
@@ -60,7 +61,8 @@ module StarkBank
|
|
60
61
|
req['Access-Time'] = access_time
|
61
62
|
req['Access-Signature'] = signature
|
62
63
|
req['Content-Type'] = 'application/json'
|
63
|
-
req['User-Agent'] = "Ruby-#{RUBY_VERSION}-SDK-0.1
|
64
|
+
req['User-Agent'] = "Ruby-#{RUBY_VERSION}-SDK-0.4.1"
|
65
|
+
req['Accept-Language'] = language
|
64
66
|
|
65
67
|
request = Net::HTTP.start(uri.hostname, use_ssl: true) { |http| http.request(req) }
|
66
68
|
|
data/lib/utils/rest.rb
CHANGED
@@ -47,10 +47,11 @@ module StarkBank
|
|
47
47
|
StarkBank::Utils::API.from_api_json(resource_maker, entity)
|
48
48
|
end
|
49
49
|
|
50
|
-
def self.get_pdf(resource_name:, resource_maker:, id:, user: nil)
|
50
|
+
def self.get_pdf(resource_name:, resource_maker:, id:, user: nil, **query)
|
51
51
|
StarkBank::Utils::Request.fetch(
|
52
52
|
method: 'GET',
|
53
53
|
path: "#{StarkBank::Utils::API.endpoint(resource_name)}/#{id}/pdf",
|
54
|
+
query: StarkBank::Utils::API.cast_json_to_api_format(query),
|
54
55
|
user: user
|
55
56
|
).content
|
56
57
|
end
|
data/lib/webhook/webhook.rb
CHANGED
@@ -16,7 +16,7 @@ module StarkBank
|
|
16
16
|
# - subscriptions [list of strings]: list of any non-empty combination of the available services. ex: ['transfer', 'boleto-payment']
|
17
17
|
#
|
18
18
|
# ## Attributes:
|
19
|
-
# - id [string, default nil]: unique id returned when the
|
19
|
+
# - id [string, default nil]: unique id returned when the webhook is created. ex: '5656565656565656'
|
20
20
|
class Webhook < StarkBank::Utils::Resource
|
21
21
|
attr_reader :url, :subscriptions, :id
|
22
22
|
def initialize(url:, subscriptions:, id: nil)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starkbank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- starkbank
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0.
|
19
|
+
version: 0.0.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.0.
|
26
|
+
version: 0.0.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,21 +44,22 @@ executables: []
|
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
|
+
- lib/balance/balance.rb
|
47
48
|
- lib/boleto/boleto.rb
|
48
49
|
- lib/boleto/log.rb
|
50
|
+
- lib/boleto_payment/boleto_payment.rb
|
51
|
+
- lib/boleto_payment/log.rb
|
49
52
|
- lib/error.rb
|
53
|
+
- lib/event/event.rb
|
50
54
|
- lib/key.rb
|
51
|
-
- lib/ledger/balance.rb
|
52
|
-
- lib/ledger/transaction.rb
|
53
|
-
- lib/payment/boleto/boleto.rb
|
54
|
-
- lib/payment/boleto/log.rb
|
55
|
-
- lib/payment/utility/log.rb
|
56
|
-
- lib/payment/utility/utility.rb
|
57
55
|
- lib/starkbank.rb
|
56
|
+
- lib/transaction/transaction.rb
|
58
57
|
- lib/transfer/log.rb
|
59
58
|
- lib/transfer/transfer.rb
|
60
59
|
- lib/user/project.rb
|
61
60
|
- lib/user/user.rb
|
61
|
+
- lib/utility_payment/log.rb
|
62
|
+
- lib/utility_payment/utility_payment.rb
|
62
63
|
- lib/utils/api.rb
|
63
64
|
- lib/utils/cache.rb
|
64
65
|
- lib/utils/case.rb
|
@@ -68,7 +69,6 @@ files:
|
|
68
69
|
- lib/utils/resource.rb
|
69
70
|
- lib/utils/rest.rb
|
70
71
|
- lib/utils/url.rb
|
71
|
-
- lib/webhook/event.rb
|
72
72
|
- lib/webhook/webhook.rb
|
73
73
|
homepage: https://github.com/starkbank/sdk-ruby
|
74
74
|
licenses:
|