starkbank 2.2.0.beta2 → 2.2.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/boleto/boleto.rb +3 -2
- data/lib/boleto_payment/log.rb +1 -1
- data/lib/brcode_payment/brcode_payment.rb +167 -0
- data/lib/brcode_payment/log.rb +94 -0
- data/lib/brcode_preview/brcode_preview.rb +77 -0
- data/lib/deposit/deposit.rb +121 -0
- data/lib/deposit/log.rb +94 -0
- data/lib/dict_key/dict_key.rb +118 -0
- data/lib/event/event.rb +4 -0
- data/lib/invoice/invoice.rb +42 -4
- data/lib/invoice/log.rb +1 -1
- data/lib/starkbank.rb +6 -0
- data/lib/transfer/transfer.rb +3 -3
- data/lib/utils/api.rb +1 -0
- data/lib/utils/checks.rb +11 -0
- data/lib/utils/request.rb +1 -1
- data/lib/utils/rest.rb +9 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e965f06caeae2a43c2fc9baaba12d8e809e4d72cf3b3a1290fde4b6667b99af0
|
4
|
+
data.tar.gz: 909f49d2384c4195d8090a7632d072c5670685c0108f50f6831aa263ae9e485c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd47fb09e160dda9118f8e7909ab032454e976fbac17fd8e72b6e27855def6371f923f965ba581b686519d5bc99549b47ecf37a067da687cc2e6b5b4b16daa99
|
7
|
+
data.tar.gz: 4c9c9efc45a25b3383d9979df7531e7d94b9aaf594196b499a305a84988fbb03648f9581fd23faf5026fe0db35de231c9e49fd642ea243e7ad56e041b706f897
|
data/lib/boleto/boleto.rb
CHANGED
@@ -115,12 +115,13 @@ module StarkBank
|
|
115
115
|
#
|
116
116
|
# ## Parameters (optional):
|
117
117
|
# - layout [string]: Layout specification. Available options are "default" and "booklet"
|
118
|
+
# - hidden_fields [list of strings, default nil]: List of string fields to be hidden in Boleto pdf. ex: ["customerAddress"]
|
118
119
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
119
120
|
#
|
120
121
|
# ## Return:
|
121
122
|
# - Boleto pdf file
|
122
|
-
def self.pdf(id, layout: nil, user: nil)
|
123
|
-
StarkBank::Utils::Rest.get_pdf(id: id, layout: layout, user: user, **resource)
|
123
|
+
def self.pdf(id, layout: nil, hidden_fields: nil, user: nil)
|
124
|
+
StarkBank::Utils::Rest.get_pdf(id: id, layout: layout, hidden_fields: hidden_fields, user: user, **resource)
|
124
125
|
end
|
125
126
|
|
126
127
|
# # Retrieve Boletos
|
data/lib/boleto_payment/log.rb
CHANGED
@@ -54,7 +54,7 @@ module StarkBank
|
|
54
54
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
55
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
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: '
|
57
|
+
# - types [list of strings, default nil]: filter retrieved objects by event types. ex: 'success' or 'failed'
|
58
58
|
# - payment_ids [list of strings, default nil]: list of 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
|
#
|
@@ -0,0 +1,167 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
|
7
|
+
module StarkBank
|
8
|
+
# # BrcodePayment object
|
9
|
+
#
|
10
|
+
# When you initialize a BrcodePayment, the entity will not be automatically
|
11
|
+
# created in the Stark Bank API. The 'create' function sends the objects
|
12
|
+
# to the Stark Bank API and returns the list of created objects.
|
13
|
+
#
|
14
|
+
# ## Parameters (required):
|
15
|
+
# - brcode [string]: String loaded directly from the QRCode or copied from the invoice. ex: "00020126580014br.gov.bcb.pix0136a629532e-7693-4846-852d-1bbff817b5a8520400005303986540510.005802BR5908T'Challa6009Sao Paulo62090505123456304B14A"
|
16
|
+
# - tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex: "01234567890" or "20.018.183/0001-80"
|
17
|
+
# - description [string]: Text to be displayed in your statement (min. 10 characters). ex: "payment ABC"
|
18
|
+
#
|
19
|
+
# ## Parameters (conditionally required):
|
20
|
+
# - amount [int, default nil]: If the BRCode does not provide an amount, this parameter is mandatory, else it is optional. ex: 23456 (= R$ 234.56)
|
21
|
+
#
|
22
|
+
# ## Parameters (optional):
|
23
|
+
# - scheduled [datetime.date, datetime.datetime or string, default now]: payment scheduled date or datetime. ex: datetime.datetime(2020, 3, 10, 15, 17, 3)
|
24
|
+
# - tags [list of strings, default nil]: list of strings for tagging
|
25
|
+
#
|
26
|
+
# ## Attributes (return-only):
|
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
|
+
# - type [string, default nil]: brcode type. ex: "static" or "dynamic"
|
30
|
+
# - fee [integer, default nil]: fee charged when the brcode payment is created. ex: 200 (= R$ 2.00)
|
31
|
+
# - updated [datetime.datetime, default nil]: latest update datetime for the payment. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0)
|
32
|
+
# - created [datetime.datetime, default nil]: creation datetime for the payment. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0)
|
33
|
+
class BrcodePayment < StarkBank::Utils::Resource
|
34
|
+
attr_reader :brcode, :tax_id, :description, :amount, :scheduled, :tags, :id, :status, :type, :fee, :updated, :created
|
35
|
+
def initialize(brcode:, tax_id:, description:, amount: nil, scheduled: nil, tags: nil, id: nil, status: nil, type: nil, fee: nil, updated: nil, created: nil)
|
36
|
+
super(id)
|
37
|
+
@brcode = brcode
|
38
|
+
@tax_id = tax_id
|
39
|
+
@description = description
|
40
|
+
@amount = amount
|
41
|
+
@scheduled = StarkBank::Utils::Checks.check_date_or_datetime(scheduled)
|
42
|
+
@tags = tags
|
43
|
+
@status = status
|
44
|
+
@type = type
|
45
|
+
@fee = fee
|
46
|
+
@updated = StarkBank::Utils::Checks.check_datetime(updated)
|
47
|
+
@created = StarkBank::Utils::Checks.check_datetime(created)
|
48
|
+
end
|
49
|
+
|
50
|
+
# # Create BrcodePayments
|
51
|
+
#
|
52
|
+
# Send a list of BrcodePayment objects for creation in the Stark Bank API
|
53
|
+
#
|
54
|
+
# ## Parameters (required):
|
55
|
+
# - payments [list of BrcodePayment objects]: list of BrcodePayment objects to be created in the API
|
56
|
+
#
|
57
|
+
# ## Parameters (optional):
|
58
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
59
|
+
#
|
60
|
+
# ## Return:
|
61
|
+
# - list of BrcodePayment objects with updated attributes
|
62
|
+
def self.create(payments, user: nil)
|
63
|
+
StarkBank::Utils::Rest.post(entities: payments, user: user, **resource)
|
64
|
+
end
|
65
|
+
|
66
|
+
# # Retrieve a specific BrcodePayment
|
67
|
+
#
|
68
|
+
# Receive a single BrcodePayment object previously created by the Stark Bank API by passing its id
|
69
|
+
#
|
70
|
+
# ## Parameters (required):
|
71
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
72
|
+
#
|
73
|
+
# ## Parameters (optional):
|
74
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
75
|
+
#
|
76
|
+
# ## Return:
|
77
|
+
# - BrcodePayment object with updated attributes
|
78
|
+
def self.get(id, user: nil)
|
79
|
+
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
80
|
+
end
|
81
|
+
|
82
|
+
# # Retrieve a specific BrcodePayment pdf file
|
83
|
+
#
|
84
|
+
# Receive a single BrcodePayment pdf file generated in the Stark Bank API by passing its id.
|
85
|
+
#
|
86
|
+
# ## Parameters (required):
|
87
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
88
|
+
#
|
89
|
+
# ## Parameters (optional):
|
90
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
91
|
+
#
|
92
|
+
# ## Return:
|
93
|
+
# - BrcodePayment pdf file
|
94
|
+
def self.pdf(id, user: nil)
|
95
|
+
StarkBank::Utils::Rest.get_pdf(id: id, user: user, **resource)
|
96
|
+
end
|
97
|
+
|
98
|
+
# # Update a BrcodePayment entity
|
99
|
+
#
|
100
|
+
# Update a BrcodePayment entity previously created in the Stark Bank API
|
101
|
+
#
|
102
|
+
# ## Parameters (required):
|
103
|
+
# - id [string]: BrcodePayment unique id. ex: '5656565656565656'
|
104
|
+
# - status [string, nil]: You may cancel the payment by passing 'canceled' in the status
|
105
|
+
#
|
106
|
+
# ## Parameters (optional):
|
107
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
108
|
+
#
|
109
|
+
# ## Return:
|
110
|
+
# - updated BrcodePayment object
|
111
|
+
def self.update(id, status: nil, user: nil)
|
112
|
+
StarkBank::Utils::Rest.patch_id(id: id, status: status, user: user, **resource)
|
113
|
+
end
|
114
|
+
|
115
|
+
# # Retrieve BrcodePayments
|
116
|
+
#
|
117
|
+
# Receive a generator of BrcodePayment objects previously created in the Stark Bank API
|
118
|
+
#
|
119
|
+
# ## Parameters (optional):
|
120
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
121
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
122
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
123
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
124
|
+
# - ids [list of strings, default nil]: list of strings to get specific entities by ids. ex: ['12376517623', '1928367198236']
|
125
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid'
|
126
|
+
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
127
|
+
#
|
128
|
+
# ## Return:
|
129
|
+
# - generator of BrcodePayment objects with updated attributes
|
130
|
+
def self.query(limit: nil, after: nil, before: nil, tags: nil, ids: nil, status: nil, user: nil)
|
131
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
132
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
133
|
+
StarkBank::Utils::Rest.get_list(
|
134
|
+
user: user,
|
135
|
+
limit: limit,
|
136
|
+
after: after,
|
137
|
+
before: before,
|
138
|
+
tags: tags,
|
139
|
+
ids: ids,
|
140
|
+
status: status,
|
141
|
+
**resource
|
142
|
+
)
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.resource
|
146
|
+
{
|
147
|
+
resource_name: 'BrcodePayment',
|
148
|
+
resource_maker: proc { |json|
|
149
|
+
BrcodePayment.new(
|
150
|
+
brcode: json['brcode'],
|
151
|
+
tax_id: json['tax_id'],
|
152
|
+
description: json['description'],
|
153
|
+
amount: json['amount'],
|
154
|
+
scheduled: json['scheduled'],
|
155
|
+
tags: json['tags'],
|
156
|
+
id: json['id'],
|
157
|
+
status: json['status'],
|
158
|
+
type: json['type'],
|
159
|
+
fee: json['fee'],
|
160
|
+
updated: json['updated'],
|
161
|
+
created: json['created']
|
162
|
+
)
|
163
|
+
}
|
164
|
+
}
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
require_relative('brcode_payment')
|
7
|
+
|
8
|
+
module StarkBank
|
9
|
+
class BrcodePayment
|
10
|
+
# # BrcodePayment::Log object
|
11
|
+
#
|
12
|
+
# Every time a BrcodePayment entity is modified, a corresponding BrcodePayment::Log
|
13
|
+
# is generated for the entity. This log is never generated by the
|
14
|
+
# user, but it can be retrieved to check additional information
|
15
|
+
# on the BrcodePayment.
|
16
|
+
#
|
17
|
+
# ## Attributes:
|
18
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
19
|
+
# - payment [BrcodePayment]: BrcodePayment entity to which the log refers to.
|
20
|
+
# - errors [list of strings]: list of errors linked to this BrcodePayment event.
|
21
|
+
# - type [string]: type of the BrcodePayment event which triggered the log creation. ex: 'processing' or 'success'
|
22
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
23
|
+
class Log < StarkBank::Utils::Resource
|
24
|
+
attr_reader :id, :created, :type, :errors, :payment
|
25
|
+
def initialize(id:, created:, type:, errors:, payment:)
|
26
|
+
super(id)
|
27
|
+
@type = type
|
28
|
+
@errors = errors
|
29
|
+
@payment = payment
|
30
|
+
@created = StarkBank::Utils::Checks.check_datetime(created)
|
31
|
+
end
|
32
|
+
|
33
|
+
# # Retrieve a specific Log
|
34
|
+
#
|
35
|
+
# Receive a single Log object previously created by the Stark Bank API by passing its id
|
36
|
+
#
|
37
|
+
# ## Parameters (required):
|
38
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
39
|
+
#
|
40
|
+
# ## Parameters (optional):
|
41
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
42
|
+
#
|
43
|
+
# ## Return:
|
44
|
+
# - Log object with updated attributes
|
45
|
+
def self.get(id, user: nil)
|
46
|
+
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
47
|
+
end
|
48
|
+
|
49
|
+
# # Retrieve Logs
|
50
|
+
#
|
51
|
+
# Receive a generator of Log objects previously created in the Stark Bank API
|
52
|
+
#
|
53
|
+
# ## Parameters (optional):
|
54
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
55
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
56
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
57
|
+
# - types [list of strings, default nil]: filter retrieved objects by event types. ex: 'success' or 'failed'
|
58
|
+
# - payment_ids [list of strings, default nil]: list of BrcodePayment ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
59
|
+
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
60
|
+
#
|
61
|
+
# ## Return:
|
62
|
+
# - list of Log objects with updated attributes
|
63
|
+
def self.query(limit: nil, after: nil, before: nil, types: nil, payment_ids: nil, user: nil)
|
64
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
65
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
66
|
+
StarkBank::Utils::Rest.get_list(
|
67
|
+
limit: limit,
|
68
|
+
after: after,
|
69
|
+
before: before,
|
70
|
+
types: types,
|
71
|
+
payment_ids: payment_ids,
|
72
|
+
user: user,
|
73
|
+
**resource
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.resource
|
78
|
+
payment_maker = StarkBank::BrcodePayment.resource[:resource_maker]
|
79
|
+
{
|
80
|
+
resource_name: 'BrcodePaymentLog',
|
81
|
+
resource_maker: proc { |json|
|
82
|
+
Log.new(
|
83
|
+
id: json['id'],
|
84
|
+
created: json['created'],
|
85
|
+
type: json['type'],
|
86
|
+
errors: json['errors'],
|
87
|
+
payment: StarkBank::Utils::API.from_api_json(payment_maker, json['payment'])
|
88
|
+
)
|
89
|
+
}
|
90
|
+
}
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
|
7
|
+
module StarkBank
|
8
|
+
# # BrcodePreview object
|
9
|
+
#
|
10
|
+
# A BrcodePreview is used to get information from a BR Code you received to check the informations before paying it.
|
11
|
+
#
|
12
|
+
# ## Attributes (return-only):
|
13
|
+
# - status [string]: Payment status. ex: 'active', 'paid', 'canceled' or 'unknown'
|
14
|
+
# - name [string]: Payment receiver name. ex: 'Tony Stark'
|
15
|
+
# - tax_id [string]: Payment receiver tax ID. ex: '012.345.678-90'
|
16
|
+
# - bank_code [string]: Payment receiver bank code. ex: '20018183'
|
17
|
+
# - branch_code [string]: Payment receiver branch code. ex: '0001'
|
18
|
+
# - account_number [string]: Payment receiver account number. ex: '1234567'
|
19
|
+
# - account_type [string]: Payment receiver account type. ex: 'checking'
|
20
|
+
# - allow_change [bool]: If True, the payment is able to receive amounts that are diferent from the nominal one. ex: True or False
|
21
|
+
# - amount [integer]: Value in cents that this payment is expecting to receive. If 0, any value is accepted. ex: 123 (= R$1,23)
|
22
|
+
# - reconciliation_id [string]: Reconciliation ID linked to this payment. ex: 'txId', 'payment-123'
|
23
|
+
class BrcodePreview < StarkBank::Utils::Resource
|
24
|
+
attr_reader :status, :name, :tax_id, :bank_code, :branch_code, :account_number, :account_type, :allow_change, :amount, :reconciliation_id
|
25
|
+
def initialize(status:, name:, tax_id:, bank_code:, branch_code:, account_number:, account_type:, allow_change:, amount:, reconciliation_id:)
|
26
|
+
@status = status
|
27
|
+
@name = name
|
28
|
+
@tax_id = tax_id
|
29
|
+
@bank_code = bank_code
|
30
|
+
@branch_code = branch_code
|
31
|
+
@account_number = account_number
|
32
|
+
@account_type = account_type
|
33
|
+
@allow_change = allow_change
|
34
|
+
@amount = amount
|
35
|
+
@reconciliation_id = reconciliation_id
|
36
|
+
end
|
37
|
+
|
38
|
+
# # Retrieve BrcodePreviews
|
39
|
+
#
|
40
|
+
# Receive a generator of BrcodePreview objects previously created in the Stark Bank API
|
41
|
+
#
|
42
|
+
# ## Parameters (optional):
|
43
|
+
# - brcodes [list of strings]: List of brcodes to preview. ex: %w[00020126580014br.gov.bcb.pix0136a629532e-7693-4846-852d-1bbff817b5a8520400005303986540510.005802BR5908T'Challa6009Sao Paulo62090505123456304B14A]
|
44
|
+
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
45
|
+
#
|
46
|
+
# ## Return:
|
47
|
+
# - generator of BrcodePreview objects with updated attributes
|
48
|
+
def self.query(limit: nil, brcodes: nil, user: nil)
|
49
|
+
StarkBank::Utils::Rest.get_list(
|
50
|
+
user: user,
|
51
|
+
limit: nil,
|
52
|
+
brcodes: brcodes,
|
53
|
+
**resource
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.resource
|
58
|
+
{
|
59
|
+
resource_name: 'BrcodePreview',
|
60
|
+
resource_maker: proc { |json|
|
61
|
+
BrcodePreview.new(
|
62
|
+
status: json['status'],
|
63
|
+
name: json['name'],
|
64
|
+
tax_id: json['tax_id'],
|
65
|
+
bank_code: json['bank_code'],
|
66
|
+
branch_code: json['branch_code'],
|
67
|
+
account_number: json['account_number'],
|
68
|
+
account_type: json['account_type'],
|
69
|
+
allow_change: json['allow_change'],
|
70
|
+
amount: json['amount'],
|
71
|
+
reconciliation_id: json['reconciliation_id']
|
72
|
+
)
|
73
|
+
}
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
|
7
|
+
module StarkBank
|
8
|
+
# # Deposit object
|
9
|
+
#
|
10
|
+
# Deposits represent passive cash-in received by your account from external transfers
|
11
|
+
#
|
12
|
+
## Attributes (return-only):
|
13
|
+
# - id [string]: unique id associated with a Deposit when it is created. ex: '5656565656565656'
|
14
|
+
# - name [string]: payer name. ex: 'Iron Bank S.A.'
|
15
|
+
# - tax_id [string]: payer tax ID (CPF or CNPJ). ex: '012.345.678-90' or '20.018.183/0001-80'
|
16
|
+
# - bank_code [string]: payer bank code in Brazil. ex: '20018183' or '341'
|
17
|
+
# - branch_code [string]: payer bank account branch. ex: '1357-9's
|
18
|
+
# - account_number [string]: payer bank account number. ex: '876543-2'
|
19
|
+
# - amount [integer]: Deposit value in cents. ex: 1234 (= R$ 12.34)
|
20
|
+
# - type [string]: Type of settlement that originated the deposit. ex: 'pix' or 'ted'
|
21
|
+
# - status [string]: current Deposit status. ex: 'created'
|
22
|
+
# - tags [list of strings]: list of strings that are tagging the deposit. ex: ['reconciliationId', 'txId']
|
23
|
+
# - fee [integer]: fee charged by this deposit. ex: 50 (= R$ 0.50)
|
24
|
+
# - transaction_ids [list of strings]: ledger transaction ids linked to this Deposit (if there are more than one, all but first are reversals). ex: ['19827356981273']
|
25
|
+
# - created [datetime.datetime]: creation datetime for the Deposit. ex: datetime.datetime(2020, 12, 10, 10, 30, 0, 0)
|
26
|
+
# - updated [datetime.datetime]: latest update datetime for the Deposit. ex: datetime.datetime(2020, 12, 10, 10, 30, 0, 0)
|
27
|
+
class Deposit < StarkBank::Utils::Resource
|
28
|
+
attr_reader :id, :name, :tax_id, :bank_code, :branch_code, :account_number, :amount, :type, :status, :tags, :fee, :transaction_ids, :created, :updated
|
29
|
+
def initialize(
|
30
|
+
id:, name:, tax_id:, bank_code:, branch_code:, account_number:, amount:, type:, status:, tags:, fee:,
|
31
|
+
transaction_ids:, created:, updated:
|
32
|
+
)
|
33
|
+
super(id)
|
34
|
+
@name = name
|
35
|
+
@tax_id = tax_id
|
36
|
+
@bank_code = bank_code
|
37
|
+
@branch_code = branch_code
|
38
|
+
@account_number = account_number
|
39
|
+
@amount = amount
|
40
|
+
@type = type
|
41
|
+
@status = status
|
42
|
+
@tags = tags
|
43
|
+
@fee = fee
|
44
|
+
@transaction_ids = transaction_ids
|
45
|
+
@created = StarkBank::Utils::Checks.check_datetime(created)
|
46
|
+
@updated = StarkBank::Utils::Checks.check_datetime(updated)
|
47
|
+
end
|
48
|
+
|
49
|
+
# # Retrieve a specific Deposit
|
50
|
+
#
|
51
|
+
# Receive a single Deposit object previously created in the Stark Bank API by passing its id
|
52
|
+
#
|
53
|
+
# ## Parameters (required):
|
54
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
55
|
+
#
|
56
|
+
# ## Parameters (optional):
|
57
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
58
|
+
#
|
59
|
+
# ## Return:
|
60
|
+
# - Deposit object with updated attributes
|
61
|
+
def self.get(id, user: nil)
|
62
|
+
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
63
|
+
end
|
64
|
+
|
65
|
+
# # Retrieve Deposits
|
66
|
+
#
|
67
|
+
# Receive a generator of Deposit objects previously created in the Stark Bank API
|
68
|
+
#
|
69
|
+
# ## Parameters (optional):
|
70
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
71
|
+
# - after [Date , DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
72
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
73
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
|
74
|
+
# - sort [string, default '-created']: sort order considered in response. Valid options are 'created' or '-created'.
|
75
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
76
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
77
|
+
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
78
|
+
#
|
79
|
+
# ## Return:
|
80
|
+
# - generator of Deposit objects with updated attributes
|
81
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, sort: nil, tags: nil, ids: nil, user: nil)
|
82
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
83
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
84
|
+
StarkBank::Utils::Rest.get_list(
|
85
|
+
limit: limit,
|
86
|
+
after: after,
|
87
|
+
before: before,
|
88
|
+
status: status,
|
89
|
+
sort: sort,
|
90
|
+
tags: tags,
|
91
|
+
ids: ids,
|
92
|
+
user: user,
|
93
|
+
**resource
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.resource
|
98
|
+
{
|
99
|
+
resource_name: 'Deposit',
|
100
|
+
resource_maker: proc { |json|
|
101
|
+
Deposit.new(
|
102
|
+
id: json['id'],
|
103
|
+
name: json['name'],
|
104
|
+
tax_id: json['tax_id'],
|
105
|
+
bank_code: json['bank_code'],
|
106
|
+
branch_code: json['branch_code'],
|
107
|
+
account_number: json['account_number'],
|
108
|
+
amount: json['amount'],
|
109
|
+
type: json['type'],
|
110
|
+
status: json['status'],
|
111
|
+
tags: json['tags'],
|
112
|
+
fee: json['fee'],
|
113
|
+
transaction_ids: json['transaction_ids'],
|
114
|
+
created: json['created'],
|
115
|
+
updated: json['updated']
|
116
|
+
)
|
117
|
+
}
|
118
|
+
}
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/lib/deposit/log.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
require_relative('deposit')
|
7
|
+
|
8
|
+
module StarkBank
|
9
|
+
class Deposit
|
10
|
+
# # Deposit::Log object
|
11
|
+
#
|
12
|
+
# Every time a Deposit entity is updated, a corresponding Deposit::Log
|
13
|
+
# is generated for the entity. This log is never generated by the
|
14
|
+
# user, but it can be retrieved to check additional information
|
15
|
+
# on the Deposit.
|
16
|
+
#
|
17
|
+
# ## Attributes:
|
18
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
19
|
+
# - deposit [Deposit]: Deposit entity to which the log refers to.
|
20
|
+
# - errors [list of strings]: list of errors linked to this Deposit event
|
21
|
+
# - type [string]: type of the Deposit event which triggered the log creation. ex: 'canceled' or 'paid'
|
22
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
23
|
+
class Log < StarkBank::Utils::Resource
|
24
|
+
attr_reader :id, :created, :type, :errors, :deposit
|
25
|
+
def initialize(id:, created:, type:, errors:, deposit:)
|
26
|
+
super(id)
|
27
|
+
@type = type
|
28
|
+
@errors = errors
|
29
|
+
@deposit = deposit
|
30
|
+
@created = StarkBank::Utils::Checks.check_datetime(created)
|
31
|
+
end
|
32
|
+
|
33
|
+
# # Retrieve a specific Log
|
34
|
+
#
|
35
|
+
# Receive a single Log object previously created by the Stark Bank API by passing its id
|
36
|
+
#
|
37
|
+
# ## Parameters (required):
|
38
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
39
|
+
#
|
40
|
+
# ## Parameters (optional):
|
41
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
42
|
+
#
|
43
|
+
# ## Return:
|
44
|
+
# - Log object with updated attributes
|
45
|
+
def self.get(id, user: nil)
|
46
|
+
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
47
|
+
end
|
48
|
+
|
49
|
+
# # Retrieve Logs
|
50
|
+
#
|
51
|
+
# Receive a generator of Log objects previously created in the Stark Bank API
|
52
|
+
#
|
53
|
+
# ## Parameters (optional):
|
54
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
55
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
56
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
57
|
+
# - types [list of strings, default nil]: filter for log event types. ex: 'paid' or 'canceled'
|
58
|
+
# - deposit_ids [list of strings, default nil]: list of Deposit ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
59
|
+
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
60
|
+
#
|
61
|
+
# ## Return:
|
62
|
+
# - list of Log objects with updated attributes
|
63
|
+
def self.query(limit: nil, after: nil, before: nil, types: nil, deposit_ids: nil, user: nil)
|
64
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
65
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
66
|
+
StarkBank::Utils::Rest.get_list(
|
67
|
+
limit: limit,
|
68
|
+
after: after,
|
69
|
+
before: before,
|
70
|
+
types: types,
|
71
|
+
deposit_ids: deposit_ids,
|
72
|
+
user: user,
|
73
|
+
**resource
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.resource
|
78
|
+
deposit_maker = StarkBank::Deposit.resource[:resource_maker]
|
79
|
+
{
|
80
|
+
resource_name: 'DepositLog',
|
81
|
+
resource_maker: proc { |json|
|
82
|
+
Log.new(
|
83
|
+
id: json['id'],
|
84
|
+
created: json['created'],
|
85
|
+
type: json['type'],
|
86
|
+
errors: json['errors'],
|
87
|
+
deposit: StarkBank::Utils::API.from_api_json(deposit_maker, json['deposit'])
|
88
|
+
)
|
89
|
+
}
|
90
|
+
}
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource.rb')
|
4
|
+
require_relative('../utils/rest.rb')
|
5
|
+
require_relative('../utils/checks.rb')
|
6
|
+
|
7
|
+
module StarkBank
|
8
|
+
# # DictKey object
|
9
|
+
#
|
10
|
+
# DictKey represents a PIX key registered in Bacen's DICT system.
|
11
|
+
#
|
12
|
+
# ## Parameters (required):
|
13
|
+
# - id [string]: DictKey object unique id and PIX key itself. ex: 'tony@starkbank.com', '722.461.430-04', '20.018.183/0001-80', '+5511988887777', 'b6295ee1-f054-47d1-9e90-ee57b74f60d9'
|
14
|
+
#
|
15
|
+
# ## Attributes (return-only):
|
16
|
+
# - type [string, default nil]: DICT key type. ex: 'email', 'cpf', 'cnpj', 'phone' or 'evp'
|
17
|
+
# - name [string, default nil]: account owner full name. ex: 'Tony Stark'
|
18
|
+
# - tax_id [string, default nil]: key owner tax ID (CNPJ or masked CPF). ex: '***.345.678-**' or '20.018.183/0001-80'
|
19
|
+
# - owner_type [string, default nil]: DICT key owner type. ex 'naturalPerson' or 'legalPerson'
|
20
|
+
# - ispb [string, default nil]: bank ISPB associated with the DICT key. ex: '20018183'
|
21
|
+
# - branch_code [string, default nil]: bank account branch code associated with the DICT key. ex: '9585'
|
22
|
+
# - account_number [string, default nil]: bank account number associated with the DICT key. ex: '9828282578010513'
|
23
|
+
# - account_type [string, default nil]: bank account type associated with the DICT key. ex: 'checking', 'saving' e 'salary'
|
24
|
+
# - status [string, default nil]: current DICT key status. ex: 'created', 'registered', 'canceled' or 'failed'
|
25
|
+
# - account_created [DateTime or string, default nil]: creation datetime of the bank account associated with the DICT key. ex: '2020-11-05T14:55:08.812665+00:00'
|
26
|
+
# - owned [DateTime or string, default nil]: datetime since when the current owner hold this DICT key. ex : '2020-11-05T14:55:08.812665+00:00'
|
27
|
+
# - created [DateTime or string, default nil]: creation datetime for the DICT key. ex: '2020-03-10 10:30:00.000'
|
28
|
+
class DictKey < StarkBank::Utils::Resource
|
29
|
+
attr_reader :id, :type, :name, :tax_id, :owner_type, :ispb, :branch_code, :account_number, :account_type, :status, :account_created, :owned, :created
|
30
|
+
def initialize(
|
31
|
+
id:, type:, name:, tax_id:, owner_type:, ispb:, branch_code:, account_number:, account_type:,
|
32
|
+
status:, account_created:, owned:, created:
|
33
|
+
)
|
34
|
+
super(id)
|
35
|
+
@type = type
|
36
|
+
@name = name
|
37
|
+
@tax_id = tax_id
|
38
|
+
@owner_type = owner_type
|
39
|
+
@ispb = ispb
|
40
|
+
@branch_code = branch_code
|
41
|
+
@account_number = account_number
|
42
|
+
@account_type = account_type
|
43
|
+
@status = status
|
44
|
+
@account_created = StarkBank::Utils::Checks.check_datetime(account_created)
|
45
|
+
@owned = StarkBank::Utils::Checks.check_datetime(owned)
|
46
|
+
@created = StarkBank::Utils::Checks.check_datetime(created)
|
47
|
+
end
|
48
|
+
|
49
|
+
# # Retrieve a specific DictKey
|
50
|
+
#
|
51
|
+
# Receive a single DictKey object by passing its id
|
52
|
+
#
|
53
|
+
# ## Parameters (required):
|
54
|
+
# - id [string]: DictKey object unique id and PIX key itself. ex: 'tony@starkbank.com', '722.461.430-04', '20.018.183/0001-80', '+5511988887777', 'b6295ee1-f054-47d1-9e90-ee57b74f60d9'
|
55
|
+
#
|
56
|
+
# ## Parameters (optional):
|
57
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
58
|
+
#
|
59
|
+
# ## Return:
|
60
|
+
# - DictKey object with updated attributes
|
61
|
+
def self.get(id, user: nil)
|
62
|
+
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
63
|
+
end
|
64
|
+
|
65
|
+
# # Retrieve DitcKeys
|
66
|
+
#
|
67
|
+
# Receive a generator of DitcKey objects previously created in the Stark Bank API
|
68
|
+
#
|
69
|
+
# ## Parameters (optional):
|
70
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
71
|
+
# - type [string, default nil]: DictKey type. ex: 'cpf', 'cnpj', 'phone', 'email' or 'evp'
|
72
|
+
# - after [Date , DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
73
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
74
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
75
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'canceled', 'registered'
|
76
|
+
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
77
|
+
#
|
78
|
+
# ## Return:
|
79
|
+
# - generator of DitcKey objects with updated attributes
|
80
|
+
def self.query(limit: nil, type: nil, after: nil, before: nil, ids: nil, status: nil, user: nil)
|
81
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
82
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
83
|
+
StarkBank::Utils::Rest.get_list(
|
84
|
+
limit: limit,
|
85
|
+
type: type,
|
86
|
+
after: after,
|
87
|
+
before: before,
|
88
|
+
ids: ids,
|
89
|
+
status: status,
|
90
|
+
user: user,
|
91
|
+
**resource
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.resource
|
96
|
+
{
|
97
|
+
resource_name: 'DictKey',
|
98
|
+
resource_maker: proc { |json|
|
99
|
+
DictKey.new(
|
100
|
+
id: json['id'],
|
101
|
+
account_type: json['account_type'],
|
102
|
+
name: json['name'],
|
103
|
+
tax_id: json['tax_id'],
|
104
|
+
owner_type: json['owner_type'],
|
105
|
+
ispb: json['ispb'],
|
106
|
+
branch_code: json['branch_code'],
|
107
|
+
account_number: json['account_number'],
|
108
|
+
type: json['type'],
|
109
|
+
status: json['status'],
|
110
|
+
account_created: json['account_created'],
|
111
|
+
owned: json['owned'],
|
112
|
+
created: json['created']
|
113
|
+
)
|
114
|
+
}
|
115
|
+
}
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
data/lib/event/event.rb
CHANGED
@@ -10,6 +10,8 @@ require_relative('../error')
|
|
10
10
|
require_relative('../boleto/log')
|
11
11
|
require_relative('../boleto_holmes/log')
|
12
12
|
require_relative('../invoice/log')
|
13
|
+
require_relative('../deposit/log')
|
14
|
+
require_relative('../brcode_payment/log')
|
13
15
|
require_relative('../transfer/log')
|
14
16
|
require_relative('../boleto_payment/log')
|
15
17
|
require_relative('../utility_payment/log')
|
@@ -38,6 +40,8 @@ module StarkBank
|
|
38
40
|
resource = {
|
39
41
|
'transfer': StarkBank::Transfer::Log.resource,
|
40
42
|
'invoice': StarkBank::Invoice::Log.resource,
|
43
|
+
'deposit': StarkBank::Deposit::Log.resource,
|
44
|
+
'brcode-payment': StarkBank::BrcodePayment::Log.resource,
|
41
45
|
'boleto': StarkBank::Boleto::Log.resource,
|
42
46
|
'boleto-payment': StarkBank::BoletoPayment::Log.resource,
|
43
47
|
'utility-payment': StarkBank::UtilityPayment::Log.resource,
|
data/lib/invoice/invoice.rb
CHANGED
@@ -32,15 +32,16 @@ module StarkBank
|
|
32
32
|
# - interest_amount [integer, default nil]: Invoice interest value calculated over nominal_amount. ex: 10000
|
33
33
|
# - discount_amount [integer, default nil]: Invoice discount value calculated over nominal_amount. ex: 3000
|
34
34
|
# - brcode [string, default nil]: BR Code for the Invoice payment. ex: '00020101021226800014br.gov.bcb.pix2558invoice.starkbank.com/f5333103-3279-4db2-8389-5efe335ba93d5204000053039865802BR5913Arya Stark6009Sao Paulo6220051656565656565656566304A9A0'
|
35
|
+
# - fee [integer, default nil]: fee charged by the Invoice. ex: 65 (= R$ 0.65)
|
35
36
|
# - status [string, default nil]: current Invoice status. ex: 'registered' or 'paid'
|
36
37
|
# - created [DateTime, default nil]: creation datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
37
38
|
# - updated [DateTime, default nil]: latest update datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
38
39
|
class Invoice < StarkBank::Utils::Resource
|
39
|
-
attr_reader :amount, :due, :tax_id, :name, :expiration, :fine, :interest, :discounts, :tags, :descriptions, :nominal_amount, :fine_amount, :interest_amount, :discount_amount, :id, :brcode, :status, :created, :updated
|
40
|
+
attr_reader :amount, :due, :tax_id, :name, :expiration, :fine, :interest, :discounts, :tags, :descriptions, :nominal_amount, :fine_amount, :interest_amount, :discount_amount, :id, :brcode, :fee, :status, :created, :updated
|
40
41
|
def initialize(
|
41
42
|
amount:, due:, tax_id:, name:, expiration: nil, fine: nil, interest: nil, discounts: nil,
|
42
43
|
tags: nil, descriptions: nil, nominal_amount: nil, fine_amount: nil, interest_amount: nil,
|
43
|
-
discount_amount: nil, id: nil, brcode: nil, status: nil, created: nil, updated: nil
|
44
|
+
discount_amount: nil, id: nil, brcode: nil, fee: nil, status: nil, created: nil, updated: nil
|
44
45
|
)
|
45
46
|
super(id)
|
46
47
|
@amount = amount
|
@@ -58,6 +59,7 @@ module StarkBank
|
|
58
59
|
@interest_amount = interest_amount
|
59
60
|
@discount_amount = discount_amount
|
60
61
|
@brcode = brcode
|
62
|
+
@fee = fee
|
61
63
|
@status = status
|
62
64
|
@updated = StarkBank::Utils::Checks.check_datetime(updated)
|
63
65
|
@created = StarkBank::Utils::Checks.check_datetime(created)
|
@@ -95,6 +97,38 @@ module StarkBank
|
|
95
97
|
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
96
98
|
end
|
97
99
|
|
100
|
+
# # Retrieve a specific Invoice pdf file
|
101
|
+
#
|
102
|
+
# Receive a single Invoice pdf file generated in the Stark Bank API by passing its id.
|
103
|
+
#
|
104
|
+
# ## Parameters (required):
|
105
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
106
|
+
#
|
107
|
+
# ## Parameters (optional):
|
108
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
109
|
+
#
|
110
|
+
# ## Return:
|
111
|
+
# - Invoice pdf file
|
112
|
+
def self.pdf(id, user: nil)
|
113
|
+
StarkBank::Utils::Rest.get_pdf(id: id, user: user, **resource)
|
114
|
+
end
|
115
|
+
|
116
|
+
# # Retrieve a specific Invoice QR Code file
|
117
|
+
#
|
118
|
+
# Receive a single Invoice QR Code png file generated in the Stark Bank API by passing its id.
|
119
|
+
#
|
120
|
+
# ## Parameters (required):
|
121
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
122
|
+
#
|
123
|
+
# ## Parameters (optional):
|
124
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
125
|
+
#
|
126
|
+
# ## Return:
|
127
|
+
# - Invoice QR Code png blob
|
128
|
+
def self.qrcode(id, user: nil)
|
129
|
+
StarkBank::Utils::Rest.get_qrcode(id: id, user: user, **resource)
|
130
|
+
end
|
131
|
+
|
98
132
|
# # Retrieve Invoices
|
99
133
|
#
|
100
134
|
# Receive a generator of Invoice objects previously created in the Stark Bank API
|
@@ -133,10 +167,13 @@ module StarkBank
|
|
133
167
|
# - id [string]: Invoice unique id. ex: '5656565656565656'
|
134
168
|
#
|
135
169
|
# ## Parameters (optional):
|
136
|
-
# -
|
170
|
+
# - status [string, nil]: You may cancel the invoice by passing 'canceled' in the status
|
171
|
+
# - amount [string, nil]: Nominal amount charged by the invoice. ex: 100 (R$1.00)
|
172
|
+
# - due [datetime.date or string, default nil]: Invoice due date in UTC ISO format. ex: DateTime.new(2020, 3, 10, 10, 30, 12, 21)
|
173
|
+
# - expiration [number, default nil]: time interval in seconds between the due date and the expiration date. ex 123456789
|
137
174
|
#
|
138
175
|
# ## Return:
|
139
|
-
# -
|
176
|
+
# - updated Invoice object
|
140
177
|
def self.update(id, status: nil, amount: nil, due: nil, expiration: nil, user: nil)
|
141
178
|
StarkBank::Utils::Rest.patch_id(id: id, status: status, amount: amount, due: due, expiration: expiration, user: user, **resource)
|
142
179
|
end
|
@@ -162,6 +199,7 @@ module StarkBank
|
|
162
199
|
interest_amount: json['interest_amount'],
|
163
200
|
discount_amount: json['discount_amount'],
|
164
201
|
brcode: json['brcode'],
|
202
|
+
fee: json['fee'],
|
165
203
|
status: json['status'],
|
166
204
|
updated: json['updated'],
|
167
205
|
created: json['created'],
|
data/lib/invoice/log.rb
CHANGED
@@ -9,7 +9,7 @@ module StarkBank
|
|
9
9
|
class Invoice
|
10
10
|
# # Invoice::Log object
|
11
11
|
#
|
12
|
-
# Every time
|
12
|
+
# Every time an Invoice entity is updated, a corresponding Invoice::Log
|
13
13
|
# is generated for the entity. This log is never generated by the
|
14
14
|
# user, but it can be retrieved to check additional information
|
15
15
|
# on the Invoice.
|
data/lib/starkbank.rb
CHANGED
@@ -6,6 +6,12 @@ require_relative('balance/balance')
|
|
6
6
|
require_relative('transaction/transaction')
|
7
7
|
require_relative('invoice/invoice')
|
8
8
|
require_relative('invoice/log')
|
9
|
+
require_relative('dict_key/dict_key')
|
10
|
+
require_relative('deposit/deposit')
|
11
|
+
require_relative('deposit/log')
|
12
|
+
require_relative('brcode_preview/brcode_preview')
|
13
|
+
require_relative('brcode_payment/brcode_payment')
|
14
|
+
require_relative('brcode_payment/log')
|
9
15
|
require_relative('boleto/boleto')
|
10
16
|
require_relative('boleto/log')
|
11
17
|
require_relative('boleto_holmes/boleto_holmes')
|
data/lib/transfer/transfer.rb
CHANGED
@@ -15,13 +15,13 @@ module StarkBank
|
|
15
15
|
# - amount [integer]: amount in cents to be transferred. ex: 1234 (= R$ 12.34)
|
16
16
|
# - name [string]: receiver full name. ex: 'Anthony Edward Stark'
|
17
17
|
# - tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
|
18
|
-
# - bank_code [string]:
|
18
|
+
# - bank_code [string]: code of the receiver bank institution in Brazil. If an ISPB (8 digits) is informed, a PIX transfer will be created, else a TED will be issued. ex: '20018183' or '260'
|
19
19
|
# - branch_code [string]: receiver bank account branch. Use '-' in case there is a verifier digit. ex: '1357-9'
|
20
20
|
# - account_number [string]: Receiver Bank Account number. Use '-' before the verifier digit. ex: '876543-2'
|
21
21
|
#
|
22
22
|
# ## Parameters (optional):
|
23
23
|
# - tags [list of strings]: list of strings for reference when searching for transfers. ex: ['employees', 'monthly']
|
24
|
-
# - scheduled [string, default now]: datetime when the transfer will be processed. May be pushed to next business day if necessary. ex: DateTime.new(2020, 3, 11, 8,
|
24
|
+
# - scheduled [string, default now]: datetime when the transfer will be processed. May be pushed to next business day if necessary. ex: DateTime.new(2020, 3, 11, 8, 13, 12, 11)
|
25
25
|
#
|
26
26
|
# ## Attributes (return-only):
|
27
27
|
# - id [string, default nil]: unique id returned when Transfer is created. ex: '5656565656565656'
|
@@ -40,7 +40,7 @@ module StarkBank
|
|
40
40
|
@bank_code = bank_code
|
41
41
|
@branch_code = branch_code
|
42
42
|
@account_number = account_number
|
43
|
-
@scheduled = StarkBank::Utils::Checks.
|
43
|
+
@scheduled = StarkBank::Utils::Checks.check_date_or_datetime(scheduled)
|
44
44
|
@transaction_ids = transaction_ids
|
45
45
|
@fee = fee
|
46
46
|
@tags = tags
|
data/lib/utils/api.rb
CHANGED
data/lib/utils/checks.rb
CHANGED
@@ -39,6 +39,17 @@ module StarkBank
|
|
39
39
|
raise(ArgumentError, 'Private-key must be a valid secp256k1 ECDSA string in pem format')
|
40
40
|
end
|
41
41
|
|
42
|
+
def self.check_date_or_datetime(data)
|
43
|
+
return if data.nil?
|
44
|
+
|
45
|
+
return data if data.is_a?(Time) || data.is_a?(DateTime)
|
46
|
+
|
47
|
+
return data if data.is_a?(Date)
|
48
|
+
|
49
|
+
data, type = check_datetime_string(data)
|
50
|
+
type == 'date' ? Date.new(data.year, data.month, data.day) : data
|
51
|
+
end
|
52
|
+
|
42
53
|
def self.check_datetime(data)
|
43
54
|
return if data.nil?
|
44
55
|
|
data/lib/utils/request.rb
CHANGED
@@ -61,7 +61,7 @@ module StarkBank
|
|
61
61
|
req['Access-Time'] = access_time
|
62
62
|
req['Access-Signature'] = signature
|
63
63
|
req['Content-Type'] = 'application/json'
|
64
|
-
req['User-Agent'] = "Ruby-#{RUBY_VERSION}-SDK-2.2.0
|
64
|
+
req['User-Agent'] = "Ruby-#{RUBY_VERSION}-SDK-2.2.0"
|
65
65
|
req['Accept-Language'] = language
|
66
66
|
|
67
67
|
request = Net::HTTP.start(uri.hostname, use_ssl: true) { |http| http.request(req) }
|
data/lib/utils/rest.rb
CHANGED
@@ -56,6 +56,15 @@ module StarkBank
|
|
56
56
|
).content
|
57
57
|
end
|
58
58
|
|
59
|
+
def self.get_qrcode(resource_name:, resource_maker:, id:, user: nil, **query)
|
60
|
+
StarkBank::Utils::Request.fetch(
|
61
|
+
method: 'GET',
|
62
|
+
path: "#{StarkBank::Utils::API.endpoint(resource_name)}/#{id}/qrcode",
|
63
|
+
query: StarkBank::Utils::API.cast_json_to_api_format(query),
|
64
|
+
user: user
|
65
|
+
).content
|
66
|
+
end
|
67
|
+
|
59
68
|
def self.post(resource_name:, resource_maker:, entities:, user: nil)
|
60
69
|
jsons = []
|
61
70
|
entities.each do |entity|
|
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: 2.2.0
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- starkbank
|
@@ -79,6 +79,12 @@ files:
|
|
79
79
|
- lib/boleto_holmes/log.rb
|
80
80
|
- lib/boleto_payment/boleto_payment.rb
|
81
81
|
- lib/boleto_payment/log.rb
|
82
|
+
- lib/brcode_payment/brcode_payment.rb
|
83
|
+
- lib/brcode_payment/log.rb
|
84
|
+
- lib/brcode_preview/brcode_preview.rb
|
85
|
+
- lib/deposit/deposit.rb
|
86
|
+
- lib/deposit/log.rb
|
87
|
+
- lib/dict_key/dict_key.rb
|
82
88
|
- lib/error.rb
|
83
89
|
- lib/event/event.rb
|
84
90
|
- lib/invoice/invoice.rb
|
@@ -118,9 +124,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
124
|
version: '2.3'
|
119
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
126
|
requirements:
|
121
|
-
- - "
|
127
|
+
- - ">="
|
122
128
|
- !ruby/object:Gem::Version
|
123
|
-
version:
|
129
|
+
version: '0'
|
124
130
|
requirements: []
|
125
131
|
rubygems_version: 3.1.4
|
126
132
|
signing_key:
|