starkbank 2.1.0.beta1 → 2.1.0.beta2
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 +1 -1
- data/lib/boleto_payment/boleto_payment.rb +1 -1
- data/lib/event/event.rb +4 -4
- data/lib/invoice/invoice.rb +173 -0
- data/lib/{boleto_holmes → invoice}/log.rb +21 -18
- data/lib/transfer/transfer.rb +1 -1
- data/lib/utility_payment/utility_payment.rb +1 -1
- data/lib/utils/api.rb +14 -18
- data/lib/utils/checks.rb +7 -6
- data/lib/utils/request.rb +1 -1
- metadata +5 -5
- data/lib/boleto_holmes/boleto_holmes.rb +0 -121
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98835d3b25dff96530638da6c2da72f1c8acbe7cb3a5fdb45a25e5506f8cb153
|
4
|
+
data.tar.gz: b298cf063b7b824658c247122c3135302096924332b311d638089573aea432cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 778c03a3493122b36fc1f1cd521e96c9a45035f5ff4590fc8189c17da4d3be177e890f8de65978e1c16eda9f4d3362e97e018e3f032186a0fe99a011df45e6d8
|
7
|
+
data.tar.gz: 8a992c980902e97809cded32d229f72b4ef8e4c1adc6d2d8e8f67c7eb8a0c7efc5bf7bbc6faec265ad5a741ae0219de1f5d2bb507f501cef9e5c55338e34e5e7
|
data/lib/boleto/boleto.rb
CHANGED
@@ -37,7 +37,7 @@ module StarkBank
|
|
37
37
|
@description = description
|
38
38
|
@line = line
|
39
39
|
@bar_code = bar_code
|
40
|
-
@scheduled = StarkBank::Utils::Checks.
|
40
|
+
@scheduled = StarkBank::Utils::Checks.check_date(scheduled)
|
41
41
|
@tags = tags
|
42
42
|
@status = status
|
43
43
|
@amount = amount
|
data/lib/event/event.rb
CHANGED
@@ -8,7 +8,7 @@ require_relative('../utils/checks')
|
|
8
8
|
require_relative('../utils/cache')
|
9
9
|
require_relative('../error')
|
10
10
|
require_relative('../boleto/log')
|
11
|
-
require_relative('../
|
11
|
+
require_relative('../invoice/log')
|
12
12
|
require_relative('../transfer/log')
|
13
13
|
require_relative('../boleto_payment/log')
|
14
14
|
require_relative('../utility_payment/log')
|
@@ -22,7 +22,7 @@ module StarkBank
|
|
22
22
|
#
|
23
23
|
# ## Attributes:
|
24
24
|
# - id [string]: unique id returned when the event is created. ex: '5656565656565656'
|
25
|
-
# - log [Log]: a Log object from one the subscription services (TransferLog, BoletoLog, BoletoPaymentlog or UtilityPaymentLog)
|
25
|
+
# - log [Log]: a Log object from one the subscription services (TransferLog, InvoiceLog, BoletoLog, BoletoPaymentlog or UtilityPaymentLog)
|
26
26
|
# - created [DateTime]: creation datetime for the notification event. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
27
27
|
# - is_delivered [bool]: true if the event has been successfully delivered to the user url. ex: False
|
28
28
|
# - subscription [string]: service that triggered this event. ex: 'transfer', 'utility-payment'
|
@@ -36,10 +36,10 @@ module StarkBank
|
|
36
36
|
|
37
37
|
resource = {
|
38
38
|
'transfer': StarkBank::Transfer::Log.resource,
|
39
|
+
'invoice': StarkBank::Invoice::Log.resource,
|
39
40
|
'boleto': StarkBank::Boleto::Log.resource,
|
40
41
|
'boleto-payment': StarkBank::BoletoPayment::Log.resource,
|
41
|
-
'utility-payment': StarkBank::UtilityPayment::Log.resource
|
42
|
-
'boleto-holmes': StarkBank::BoletoHolmes::Log.resource
|
42
|
+
'utility-payment': StarkBank::UtilityPayment::Log.resource
|
43
43
|
}[subscription.to_sym]
|
44
44
|
|
45
45
|
@log = log
|
@@ -0,0 +1,173 @@
|
|
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
|
+
# # Invoice object
|
9
|
+
#
|
10
|
+
# When you initialize an Invoice, the entity will not be automatically
|
11
|
+
# sent to 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
|
+
# - amount [integer]: Invoice value in cents. Minimum = 0 (any value will be accepted). ex: 1234 (= R$ 12.34)
|
16
|
+
# - tax_id [string]: payer tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
|
17
|
+
# - name [string]: payer name. ex: 'Iron Bank S.A.'
|
18
|
+
#
|
19
|
+
# ## Parameters (optional):
|
20
|
+
# - due [DateTime or string, default today + 2 days]: Invoice due date in UTC ISO format. ex: '2020-10-28T17:59:26.249976+00:00'
|
21
|
+
# - expiration [integer, default 5097600 (59 days)]: time interval in seconds between due date and expiration date. ex 123456789
|
22
|
+
# - fine [float, default 0.0]: Invoice fine for overdue payment in %. ex: 2.5
|
23
|
+
# - interest [float, default 0.0]: Invoice monthly interest for overdue payment in %. ex: 5.2
|
24
|
+
# - discounts [list of hashes, default nil]: list of hashes with 'percentage':float and 'due':DateTime or string pairs
|
25
|
+
# - descriptions [list of hashes, default nil]: list of hashes with 'key':string and 'value':string pairs
|
26
|
+
# - tags [list of strings, default nil]: list of strings for tagging
|
27
|
+
#
|
28
|
+
# ## Attributes (return-only):
|
29
|
+
# - id [string, default nil]: unique id returned when Invoice is created. ex: '5656565656565656'
|
30
|
+
# - nominal_amount [integer, default nil]: Invoice emission value in cents (will change if invoice is updated, but not if it's paid). ex: 400000
|
31
|
+
# - fine_amount [integer, default nil]: Invoice fine value calculated over nominal_amount. ex: 20000
|
32
|
+
# - interest_amount [integer, default nil]: Invoice interest value calculated over nominal_amount. ex: 10000
|
33
|
+
# - discount_amount [integer, default nil]: Invoice discount value calculated over nominal_amount. ex: 3000
|
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
|
+
# - status [string, default nil]: current Invoice status. ex: 'registered' or 'paid'
|
36
|
+
# - created [DateTime, default nil]: creation datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
37
|
+
# - updated [DateTime, default nil]: latest update datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
38
|
+
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
|
+
def initialize(
|
41
|
+
amount:, due:, tax_id:, name:, expiration: nil, fine: nil, interest: nil, discounts: nil,
|
42
|
+
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
|
+
)
|
45
|
+
super(id)
|
46
|
+
@amount = amount
|
47
|
+
@due = StarkBank::Utils::Checks.check_datetime(due)
|
48
|
+
@tax_id = tax_id
|
49
|
+
@name = name
|
50
|
+
@expiration = expiration
|
51
|
+
@fine = fine
|
52
|
+
@interest = interest
|
53
|
+
@discounts = discounts
|
54
|
+
@tags = tags
|
55
|
+
@descriptions = descriptions
|
56
|
+
@nominal_amount = nominal_amount
|
57
|
+
@fine_amount = fine_amount
|
58
|
+
@interest_amount = interest_amount
|
59
|
+
@discount_amount = discount_amount
|
60
|
+
@brcode = brcode
|
61
|
+
@status = status
|
62
|
+
@updated = StarkBank::Utils::Checks.check_datetime(updated)
|
63
|
+
@created = StarkBank::Utils::Checks.check_datetime(created)
|
64
|
+
end
|
65
|
+
|
66
|
+
# # Create Invoices
|
67
|
+
#
|
68
|
+
# Send a list of Invoice objects for creation in the Stark Bank API
|
69
|
+
#
|
70
|
+
# ## Parameters (required):
|
71
|
+
# - invoices [list of Invoice objects]: list of Invoice objects to be created in the API
|
72
|
+
#
|
73
|
+
# ## Parameters (optional):
|
74
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
75
|
+
#
|
76
|
+
# ## Return:
|
77
|
+
# - list of Invoice objects with updated attributes
|
78
|
+
def self.create(invoices, user: nil)
|
79
|
+
StarkBank::Utils::Rest.post(entities: invoices, user: user, **resource)
|
80
|
+
end
|
81
|
+
|
82
|
+
# # Retrieve a specific Invoice
|
83
|
+
#
|
84
|
+
# Receive a single Invoice object previously created 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
|
+
# - Invoice object with updated attributes
|
94
|
+
def self.get(id, user: nil)
|
95
|
+
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
96
|
+
end
|
97
|
+
|
98
|
+
# # Retrieve Invoices
|
99
|
+
#
|
100
|
+
# Receive a generator of Invoice objects previously created in the Stark Bank API
|
101
|
+
#
|
102
|
+
# ## Parameters (optional):
|
103
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
104
|
+
# - after [Date , DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
105
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
106
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
|
107
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
108
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
109
|
+
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
110
|
+
#
|
111
|
+
# ## Return:
|
112
|
+
# - generator of Invoice objects with updated attributes
|
113
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
114
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
115
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
116
|
+
StarkBank::Utils::Rest.get_list(
|
117
|
+
limit: limit,
|
118
|
+
after: after,
|
119
|
+
before: before,
|
120
|
+
status: status,
|
121
|
+
tags: tags,
|
122
|
+
ids: ids,
|
123
|
+
user: user,
|
124
|
+
**resource
|
125
|
+
)
|
126
|
+
end
|
127
|
+
|
128
|
+
# # Update an Invoice entity
|
129
|
+
#
|
130
|
+
# Update an Invoice entity previously created in the Stark Bank API
|
131
|
+
#
|
132
|
+
# ## Parameters (required):
|
133
|
+
# - id [string]: Invoice unique id. ex: '5656565656565656'
|
134
|
+
#
|
135
|
+
# ## Parameters (optional):
|
136
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
137
|
+
#
|
138
|
+
# ## Return:
|
139
|
+
# - deleted Invoice object
|
140
|
+
def self.update(id, status: nil, amount: nil, due: nil, expiration: nil, user: nil)
|
141
|
+
StarkBank::Utils::Rest.patch_id(id: id, status: status, amount: amount, due: due, expiration: expiration, user: user, **resource)
|
142
|
+
end
|
143
|
+
|
144
|
+
def self.resource
|
145
|
+
{
|
146
|
+
resource_name: 'Invoice',
|
147
|
+
resource_maker: proc { |json|
|
148
|
+
Invoice.new(
|
149
|
+
id: json['id'],
|
150
|
+
amount: json['amount'],
|
151
|
+
due: json['due'],
|
152
|
+
tax_id: json['tax_id'],
|
153
|
+
name: json['name'],
|
154
|
+
expiration: json['expiration'],
|
155
|
+
fine: json['fine'],
|
156
|
+
interest: json['interest'],
|
157
|
+
discounts: json['discounts'],
|
158
|
+
tags: json['tags'],
|
159
|
+
descriptions: json['descriptions'],
|
160
|
+
nominal_amount: json['nominal_amount'],
|
161
|
+
fine_amount: json['fine_amount'],
|
162
|
+
interest_amount: json['interest_amount'],
|
163
|
+
discount_amount: json['discount_amount'],
|
164
|
+
brcode: json['brcode'],
|
165
|
+
status: json['status'],
|
166
|
+
updated: json['updated'],
|
167
|
+
created: json['created'],
|
168
|
+
)
|
169
|
+
}
|
170
|
+
}
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -3,28 +3,30 @@
|
|
3
3
|
require_relative('../utils/resource')
|
4
4
|
require_relative('../utils/rest')
|
5
5
|
require_relative('../utils/checks')
|
6
|
-
require_relative('
|
6
|
+
require_relative('invoice')
|
7
7
|
|
8
8
|
module StarkBank
|
9
|
-
class
|
10
|
-
# #
|
9
|
+
class Invoice
|
10
|
+
# # Invoice::Log object
|
11
11
|
#
|
12
|
-
# Every time a
|
12
|
+
# Every time a 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
|
-
# on the
|
15
|
+
# on the Invoice.
|
16
16
|
#
|
17
17
|
# ## Attributes:
|
18
18
|
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
19
|
-
# -
|
20
|
-
# -
|
19
|
+
# - invoice [Invoice]: Invoice entity to which the log refers to.
|
20
|
+
# - errors [list of strings]: list of errors linked to this Invoice event
|
21
|
+
# - type [string]: type of the Invoice event which triggered the log creation. ex: 'canceled' or 'paid'
|
21
22
|
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
22
23
|
class Log < StarkBank::Utils::Resource
|
23
|
-
attr_reader :id, :
|
24
|
-
def initialize(id:,
|
24
|
+
attr_reader :id, :created, :type, :errors, :invoice
|
25
|
+
def initialize(id:, created:, type:, errors:, invoice:)
|
25
26
|
super(id)
|
26
|
-
@holmes = holmes
|
27
27
|
@type = type
|
28
|
+
@errors = errors
|
29
|
+
@invoice = invoice
|
28
30
|
@created = StarkBank::Utils::Checks.check_datetime(created)
|
29
31
|
end
|
30
32
|
|
@@ -52,13 +54,13 @@ module StarkBank
|
|
52
54
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
53
55
|
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
54
56
|
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
55
|
-
# - types [list of strings, default nil]: filter for log event types. ex: 'paid' or '
|
56
|
-
# -
|
57
|
+
# - types [list of strings, default nil]: filter for log event types. ex: 'paid' or 'canceled'
|
58
|
+
# - invoice_ids [list of strings, default nil]: list of Invoice ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
57
59
|
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
58
60
|
#
|
59
61
|
# ## Return:
|
60
62
|
# - list of Log objects with updated attributes
|
61
|
-
def self.query(limit: nil, after: nil, before: nil, types: nil,
|
63
|
+
def self.query(limit: nil, after: nil, before: nil, types: nil, invoice_ids: nil, user: nil)
|
62
64
|
after = StarkBank::Utils::Checks.check_date(after)
|
63
65
|
before = StarkBank::Utils::Checks.check_date(before)
|
64
66
|
StarkBank::Utils::Rest.get_list(
|
@@ -66,22 +68,23 @@ module StarkBank
|
|
66
68
|
after: after,
|
67
69
|
before: before,
|
68
70
|
types: types,
|
69
|
-
|
71
|
+
invoice_ids: invoice_ids,
|
70
72
|
user: user,
|
71
73
|
**resource
|
72
74
|
)
|
73
75
|
end
|
74
76
|
|
75
77
|
def self.resource
|
76
|
-
|
78
|
+
invoice_maker = StarkBank::Invoice.resource[:resource_maker]
|
77
79
|
{
|
78
|
-
resource_name: '
|
80
|
+
resource_name: 'InvoiceLog',
|
79
81
|
resource_maker: proc { |json|
|
80
82
|
Log.new(
|
81
83
|
id: json['id'],
|
82
|
-
|
84
|
+
created: json['created'],
|
83
85
|
type: json['type'],
|
84
|
-
|
86
|
+
errors: json['errors'],
|
87
|
+
invoice: StarkBank::Utils::API.from_api_json(invoice_maker, json['invoice'])
|
85
88
|
)
|
86
89
|
}
|
87
90
|
}
|
data/lib/transfer/transfer.rb
CHANGED
@@ -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(scheduled)
|
44
44
|
@transaction_ids = transaction_ids
|
45
45
|
@fee = fee
|
46
46
|
@tags = tags
|
data/lib/utils/api.rb
CHANGED
@@ -28,21 +28,22 @@ module StarkBank
|
|
28
28
|
hash.each do |key, value|
|
29
29
|
next if value.nil?
|
30
30
|
|
31
|
-
|
31
|
+
entity_hash[StarkBank::Utils::Case.snake_to_camel(key)] = parse_value(value)
|
32
|
+
end
|
33
|
+
entity_hash
|
34
|
+
end
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
value = list
|
39
|
-
elsif value.is_a?(Hash)
|
40
|
-
value = cast_json_to_api_format(value)
|
41
|
-
end
|
36
|
+
def self.parse_value(value)
|
37
|
+
return value.strftime('%Y-%m-%d') if value.is_a?(Date)
|
38
|
+
return value.strftime('%Y-%m-%dT%H:%M:%S+00:00') if value.is_a?(DateTime) || value.is_a?(Time)
|
39
|
+
return cast_json_to_api_format(value) if value.is_a?(Hash)
|
40
|
+
return value unless value.is_a?(Array)
|
42
41
|
|
43
|
-
|
42
|
+
list = []
|
43
|
+
value.each do |v|
|
44
|
+
list << (v.is_a?(Hash) ? cast_json_to_api_format(v) : v)
|
44
45
|
end
|
45
|
-
|
46
|
+
list
|
46
47
|
end
|
47
48
|
|
48
49
|
def self.from_api_json(resource_maker, json)
|
@@ -60,12 +61,7 @@ module StarkBank
|
|
60
61
|
end
|
61
62
|
|
62
63
|
def self.last_name_plural(resource_name)
|
63
|
-
|
64
|
-
|
65
|
-
return base if base[-1].eql?('s')
|
66
|
-
return "#{base[0...-1]}ies" if base[-1].eql?('y')
|
67
|
-
|
68
|
-
"#{base}s"
|
64
|
+
"#{last_name(resource_name)}s"
|
69
65
|
end
|
70
66
|
|
71
67
|
def self.last_name(resource_name)
|
data/lib/utils/checks.rb
CHANGED
@@ -46,7 +46,8 @@ module StarkBank
|
|
46
46
|
|
47
47
|
return Time.new(data.year, data.month, data.day) if data.is_a?(Date)
|
48
48
|
|
49
|
-
check_datetime_string(data)
|
49
|
+
data, _type = check_datetime_string(data)
|
50
|
+
data
|
50
51
|
end
|
51
52
|
|
52
53
|
def self.check_date(data)
|
@@ -56,9 +57,9 @@ module StarkBank
|
|
56
57
|
|
57
58
|
return data if data.is_a?(Date)
|
58
59
|
|
59
|
-
data = check_datetime_string(data)
|
60
|
+
data, type = check_datetime_string(data)
|
60
61
|
|
61
|
-
Date.new(data.year, data.month, data.day)
|
62
|
+
type == 'date' ? Date.new(data.year, data.month, data.day) : data
|
62
63
|
end
|
63
64
|
|
64
65
|
class << self
|
@@ -68,17 +69,17 @@ module StarkBank
|
|
68
69
|
data = data.to_s
|
69
70
|
|
70
71
|
begin
|
71
|
-
return DateTime.strptime(data, '%Y-%m-%dT%H:%M:%S.%L+00:00')
|
72
|
+
return [DateTime.strptime(data, '%Y-%m-%dT%H:%M:%S.%L+00:00'), 'datetime']
|
72
73
|
rescue ArgumentError
|
73
74
|
end
|
74
75
|
|
75
76
|
begin
|
76
|
-
return DateTime.strptime(data, '%Y-%m-%dT%H:%M:%S+00:00')
|
77
|
+
return [DateTime.strptime(data, '%Y-%m-%dT%H:%M:%S+00:00'), 'datetime']
|
77
78
|
rescue ArgumentError
|
78
79
|
end
|
79
80
|
|
80
81
|
begin
|
81
|
-
return DateTime.strptime(data, '%Y-%m-%d')
|
82
|
+
return [DateTime.strptime(data, '%Y-%m-%d'), 'date']
|
82
83
|
rescue ArgumentError
|
83
84
|
raise(ArgumentError, 'invalid datetime string ' + data)
|
84
85
|
end
|
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.0.
|
64
|
+
req['User-Agent'] = "Ruby-#{RUBY_VERSION}-SDK-2.1.0.beta2"
|
65
65
|
req['Accept-Language'] = language
|
66
66
|
|
67
67
|
request = Net::HTTP.start(uri.hostname, use_ssl: true) { |http| http.request(req) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starkbank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.0.
|
4
|
+
version: 2.1.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- starkbank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: starkbank-ecdsa
|
@@ -75,12 +75,12 @@ files:
|
|
75
75
|
- lib/balance/balance.rb
|
76
76
|
- lib/boleto/boleto.rb
|
77
77
|
- lib/boleto/log.rb
|
78
|
-
- lib/boleto_holmes/boleto_holmes.rb
|
79
|
-
- lib/boleto_holmes/log.rb
|
80
78
|
- lib/boleto_payment/boleto_payment.rb
|
81
79
|
- lib/boleto_payment/log.rb
|
82
80
|
- lib/error.rb
|
83
81
|
- lib/event/event.rb
|
82
|
+
- lib/invoice/invoice.rb
|
83
|
+
- lib/invoice/log.rb
|
84
84
|
- lib/key.rb
|
85
85
|
- lib/payment_request/payment_request.rb
|
86
86
|
- lib/starkbank.rb
|
@@ -101,7 +101,7 @@ files:
|
|
101
101
|
- lib/utils/rest.rb
|
102
102
|
- lib/utils/url.rb
|
103
103
|
- lib/webhook/webhook.rb
|
104
|
-
homepage: https://github.com/starkbank/sdk-ruby
|
104
|
+
homepage: https://github.com/starkbank/sdk-ruby
|
105
105
|
licenses:
|
106
106
|
- MIT
|
107
107
|
metadata: {}
|
@@ -1,121 +0,0 @@
|
|
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
|
-
# # BoletoHolmes object
|
9
|
-
#
|
10
|
-
# When you initialize a BoletoHolmes, 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
|
-
# - boleto_id [string]: investigated boleto entity ID. ex: '5656565656565656'
|
16
|
-
#
|
17
|
-
# ## Parameters (optional):
|
18
|
-
# - tags [list of strings]: list of strings for tagging
|
19
|
-
#
|
20
|
-
# ## Attributes (return-only):
|
21
|
-
# - id [string, default nil]: unique id returned when holmes is created. ex: '5656565656565656'
|
22
|
-
# - status [string, default nil]: current holmes status. ex: 'solving' or 'solved'
|
23
|
-
# - result [string, default nil]: result of boleto status investigation. ex: 'paid' or 'cancelled'
|
24
|
-
# - created [DateTime, default nil]: creation datetime for the Boleto. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
25
|
-
# - updated [DateTime, default nil]: latest update datetime for the holmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
26
|
-
class BoletoHolmes < StarkBank::Utils::Resource
|
27
|
-
attr_reader :boleto_id, :tags, :id, :status, :result, :created, :updated
|
28
|
-
def initialize(
|
29
|
-
boleto_id:, tags: nil, id: nil, status: nil, result: nil, created: nil, updated: nil
|
30
|
-
)
|
31
|
-
super(id)
|
32
|
-
@boleto_id = boleto_id
|
33
|
-
@tags = tags
|
34
|
-
@status = status
|
35
|
-
@result = result
|
36
|
-
@created = StarkBank::Utils::Checks.check_datetime(created)
|
37
|
-
@updated = StarkBank::Utils::Checks.check_datetime(updated)
|
38
|
-
end
|
39
|
-
|
40
|
-
# # Create BoletoHolmes
|
41
|
-
#
|
42
|
-
# Send a list of BoletoHolmes objects for creation in the Stark Bank API
|
43
|
-
#
|
44
|
-
# ## Parameters (required):
|
45
|
-
# - holmes [list of BoletoHolmes objects]: list of BoletoHolmes objects to be created in the API
|
46
|
-
#
|
47
|
-
# ## Parameters (optional):
|
48
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
49
|
-
#
|
50
|
-
# ## Return:
|
51
|
-
# - list of BoletoHolmes objects with updated attributes
|
52
|
-
def self.create(holmes, user: nil)
|
53
|
-
StarkBank::Utils::Rest.post(entities: holmes, user: user, **resource)
|
54
|
-
end
|
55
|
-
|
56
|
-
# # Retrieve a specific BoletoHolmes
|
57
|
-
#
|
58
|
-
# Receive a single BoletoHolmes object previously created by the Stark Bank API by passing its id
|
59
|
-
#
|
60
|
-
# ## Parameters (required):
|
61
|
-
# - id [string]: object unique id. ex: '5656565656565656'
|
62
|
-
#
|
63
|
-
# ## Parameters (optional):
|
64
|
-
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
65
|
-
#
|
66
|
-
# ## Return:
|
67
|
-
# - BoletoHolmes object with updated attributes
|
68
|
-
def self.get(id, user: nil)
|
69
|
-
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
70
|
-
end
|
71
|
-
|
72
|
-
# # Retrieve BoletoHolmes
|
73
|
-
#
|
74
|
-
# Receive a generator of BoletoHolmes objects previously created in the Stark Bank API
|
75
|
-
#
|
76
|
-
# ## Parameters (optional):
|
77
|
-
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
78
|
-
# - after [Date , DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
79
|
-
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
80
|
-
# - status [string, default nil]: filter for status of retrieved objects. ex: 'solved'
|
81
|
-
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
82
|
-
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
83
|
-
# - boleto_id [string, default nil]: filter for holmes that investigate a specific boleto by its ID. ex: '5656565656565656'
|
84
|
-
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
85
|
-
#
|
86
|
-
# ## Return:
|
87
|
-
# - generator of BoletoHolmes objects with updated attributes
|
88
|
-
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, boleto_id: nil, user: nil)
|
89
|
-
after = StarkBank::Utils::Checks.check_date(after)
|
90
|
-
before = StarkBank::Utils::Checks.check_date(before)
|
91
|
-
StarkBank::Utils::Rest.get_list(
|
92
|
-
limit: limit,
|
93
|
-
after: after,
|
94
|
-
before: before,
|
95
|
-
status: status,
|
96
|
-
tags: tags,
|
97
|
-
ids: ids,
|
98
|
-
boleto_id: boleto_id,
|
99
|
-
user: user,
|
100
|
-
**resource
|
101
|
-
)
|
102
|
-
end
|
103
|
-
|
104
|
-
def self.resource
|
105
|
-
{
|
106
|
-
resource_name: 'BoletoHolmes',
|
107
|
-
resource_maker: proc { |json|
|
108
|
-
BoletoHolmes.new(
|
109
|
-
boleto_id: json['boleto_id'],
|
110
|
-
tags: json['tags'],
|
111
|
-
id: json['id'],
|
112
|
-
status: json['status'],
|
113
|
-
result: json['result'],
|
114
|
-
created: json['created'],
|
115
|
-
updated: json['updated']
|
116
|
-
)
|
117
|
-
}
|
118
|
-
}
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|