starkbank 0.5.0 → 2.2.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_holmes/boleto_holmes.rb +121 -0
- data/lib/boleto_holmes/log.rb +91 -0
- data/lib/boleto_payment/boleto_payment.rb +1 -1
- data/lib/event/event.rb +6 -2
- data/lib/invoice/invoice.rb +173 -0
- data/lib/invoice/log.rb +94 -0
- data/lib/payment_request/payment_request.rb +142 -0
- data/lib/starkbank.rb +5 -0
- data/lib/transaction/transaction.rb +12 -2
- data/lib/transfer/transfer.rb +4 -2
- data/lib/utility_payment/utility_payment.rb +1 -1
- data/lib/utils/api.rb +28 -14
- data/lib/utils/checks.rb +7 -6
- data/lib/utils/request.rb +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 766b123365232a3f071a9a12072eaf8fc2f30021a72ed0f4a41b54726fca81c5
|
4
|
+
data.tar.gz: 5c8349015b1ee06624223bdeb28ca9f3765e92bba3d62ebe04e76656a0ec14e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b397a9af3581435b2398b7d0e19ff6e252c73024b7bad74d1f49e909f1eda18c95b89b4a95741340e6519aab69d7c1247bfcdb5b05dca5ecf589bb2c404ce743
|
7
|
+
data.tar.gz: 1bf497cdc47b95a04bba1b3dc199ffda07cff053c9b4aeced2feb82538ad2d0183b8d5049b677068a4cc2bdbdc63d6f5f4d1ec64f615d602be27678f41b77514
|
data/lib/boleto/boleto.rb
CHANGED
@@ -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
|
+
# # 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
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
require_relative('boleto_holmes')
|
7
|
+
|
8
|
+
module StarkBank
|
9
|
+
class BoletoHolmes
|
10
|
+
# # BoletoHolmes::Log object
|
11
|
+
#
|
12
|
+
# Every time a BoletoHolmes entity is modified, a corresponding BoletoHolmes::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 BoletoHolmes.
|
16
|
+
#
|
17
|
+
# ## Attributes:
|
18
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
19
|
+
# - holmes [BoletoHolmes]: BoletoHolmes entity to which the log refers to.
|
20
|
+
# - type [string]: type of the Boleto event which triggered the log creation. ex: 'registered' or 'paid'
|
21
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
22
|
+
class Log < StarkBank::Utils::Resource
|
23
|
+
attr_reader :id, :holmes, :type, :created
|
24
|
+
def initialize(id:, holmes:, type:, created:)
|
25
|
+
super(id)
|
26
|
+
@holmes = holmes
|
27
|
+
@type = type
|
28
|
+
@created = StarkBank::Utils::Checks.check_datetime(created)
|
29
|
+
end
|
30
|
+
|
31
|
+
# # Retrieve a specific Log
|
32
|
+
#
|
33
|
+
# Receive a single Log object previously created by the Stark Bank API by passing its id
|
34
|
+
#
|
35
|
+
# ## Parameters (required):
|
36
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
37
|
+
#
|
38
|
+
# ## Parameters (optional):
|
39
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
40
|
+
#
|
41
|
+
# ## Return:
|
42
|
+
# - Log object with updated attributes
|
43
|
+
def self.get(id, user: nil)
|
44
|
+
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
45
|
+
end
|
46
|
+
|
47
|
+
# # Retrieve Logs
|
48
|
+
#
|
49
|
+
# Receive a generator of Log objects previously created in the Stark Bank API
|
50
|
+
#
|
51
|
+
# ## Parameters (optional):
|
52
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
53
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
54
|
+
# - 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 'registered'
|
56
|
+
# - holmes_ids [list of strings, default nil]: list of BoletoHolmes ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
57
|
+
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
58
|
+
#
|
59
|
+
# ## Return:
|
60
|
+
# - list of Log objects with updated attributes
|
61
|
+
def self.query(limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil, user: nil)
|
62
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
63
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
64
|
+
StarkBank::Utils::Rest.get_list(
|
65
|
+
limit: limit,
|
66
|
+
after: after,
|
67
|
+
before: before,
|
68
|
+
types: types,
|
69
|
+
holmes_ids: holmes_ids,
|
70
|
+
user: user,
|
71
|
+
**resource
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.resource
|
76
|
+
holmes_maker = StarkBank::BoletoHolmes.resource[:resource_maker]
|
77
|
+
{
|
78
|
+
resource_name: 'BoletoHolmesLog',
|
79
|
+
resource_maker: proc { |json|
|
80
|
+
Log.new(
|
81
|
+
id: json['id'],
|
82
|
+
holmes: StarkBank::Utils::API.from_api_json(holmes_maker, json['holmes']),
|
83
|
+
type: json['type'],
|
84
|
+
created: json['created']
|
85
|
+
)
|
86
|
+
}
|
87
|
+
}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -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,6 +8,8 @@ require_relative('../utils/checks')
|
|
8
8
|
require_relative('../utils/cache')
|
9
9
|
require_relative('../error')
|
10
10
|
require_relative('../boleto/log')
|
11
|
+
require_relative('../boleto_holmes/log')
|
12
|
+
require_relative('../invoice/log')
|
11
13
|
require_relative('../transfer/log')
|
12
14
|
require_relative('../boleto_payment/log')
|
13
15
|
require_relative('../utility_payment/log')
|
@@ -21,7 +23,7 @@ module StarkBank
|
|
21
23
|
#
|
22
24
|
# ## Attributes:
|
23
25
|
# - id [string]: unique id returned when the event is created. ex: '5656565656565656'
|
24
|
-
# - log [Log]: a Log object from one the subscription services (TransferLog, BoletoLog, BoletoPaymentlog or UtilityPaymentLog)
|
26
|
+
# - log [Log]: a Log object from one the subscription services (TransferLog, InvoiceLog, BoletoLog, BoletoPaymentlog or UtilityPaymentLog)
|
25
27
|
# - created [DateTime]: creation datetime for the notification event. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
26
28
|
# - is_delivered [bool]: true if the event has been successfully delivered to the user url. ex: False
|
27
29
|
# - subscription [string]: service that triggered this event. ex: 'transfer', 'utility-payment'
|
@@ -35,9 +37,11 @@ module StarkBank
|
|
35
37
|
|
36
38
|
resource = {
|
37
39
|
'transfer': StarkBank::Transfer::Log.resource,
|
40
|
+
'invoice': StarkBank::Invoice::Log.resource,
|
38
41
|
'boleto': StarkBank::Boleto::Log.resource,
|
39
42
|
'boleto-payment': StarkBank::BoletoPayment::Log.resource,
|
40
|
-
'utility-payment': StarkBank::UtilityPayment::Log.resource
|
43
|
+
'utility-payment': StarkBank::UtilityPayment::Log.resource,
|
44
|
+
'boleto-holmes': StarkBank::BoletoHolmes::Log.resource
|
41
45
|
}[subscription.to_sym]
|
42
46
|
|
43
47
|
@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
|
data/lib/invoice/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('invoice')
|
7
|
+
|
8
|
+
module StarkBank
|
9
|
+
class Invoice
|
10
|
+
# # Invoice::Log object
|
11
|
+
#
|
12
|
+
# Every time a Invoice entity is updated, a corresponding Invoice::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 Invoice.
|
16
|
+
#
|
17
|
+
# ## Attributes:
|
18
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
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'
|
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, :invoice
|
25
|
+
def initialize(id:, created:, type:, errors:, invoice:)
|
26
|
+
super(id)
|
27
|
+
@type = type
|
28
|
+
@errors = errors
|
29
|
+
@invoice = invoice
|
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
|
+
# - invoice_ids [list of strings, default nil]: list of Invoice 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, invoice_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
|
+
invoice_ids: invoice_ids,
|
72
|
+
user: user,
|
73
|
+
**resource
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.resource
|
78
|
+
invoice_maker = StarkBank::Invoice.resource[:resource_maker]
|
79
|
+
{
|
80
|
+
resource_name: 'InvoiceLog',
|
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
|
+
invoice: StarkBank::Utils::API.from_api_json(invoice_maker, json['invoice'])
|
88
|
+
)
|
89
|
+
}
|
90
|
+
}
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,142 @@
|
|
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
|
+
# # PaymentRequest object
|
9
|
+
# A PaymentRequest is an indirect request to access a specific cash-out service
|
10
|
+
# (such as Transfer, BoletoPayments, etc.) which goes through the cost center
|
11
|
+
# approval flow on our website. To emit a PaymentRequest, you must direct it to
|
12
|
+
# a specific cost center by its ID, which can be retrieved on our website at the
|
13
|
+
# cost center page.
|
14
|
+
#
|
15
|
+
# ## Parameters (required):
|
16
|
+
# - center_id [String]: target cost center ID. ex: '5656565656565656'
|
17
|
+
# - payment [Transfer, BoletoPayment, UtilityPayment, Transaction or dictionary]: payment entity that should be approved and executed.
|
18
|
+
#
|
19
|
+
# ## Parameters (optional):
|
20
|
+
# - type [String]: payment type, inferred from the payment parameter if it is not a dictionary. ex: 'transfer', 'boleto-payment'
|
21
|
+
# - due [Date, DateTime, Time or string]: Payment target date in ISO format. ex: 2020-12-31
|
22
|
+
# - tags [list of strings]: list of strings for tagging
|
23
|
+
#
|
24
|
+
# ## Attributes (return-only):
|
25
|
+
# - id [String]: unique id returned when PaymentRequest is created. ex: '5656565656565656'
|
26
|
+
# - amount [integer, default nil]: PaymentRequest amount. ex: 100000 = R$1.000,00
|
27
|
+
# - status [string, default nil]: current PaymentRequest status.ex: 'pending' or 'approved'
|
28
|
+
# - actions [list of dictionaries, default nil]: list of actions that are affecting this PaymentRequest. ex: [{'type': 'member', 'id': '56565656565656, 'action': 'requested'}]
|
29
|
+
# - updated [DateTime, default nil]: latest update datetime for the PaymentRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
30
|
+
# - created [DateTime, default nil]: creation datetime for the PaymentRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
31
|
+
#
|
32
|
+
class PaymentRequest < StarkBank::Utils::Resource
|
33
|
+
attr_reader :center_id, :payment, :type, :due, :tags, :amount, :status, :actions, :updated, :created
|
34
|
+
def initialize(
|
35
|
+
payment:, center_id:, id: nil, type: nil, due: nil, tags: nil, amount: nil, status: nil,
|
36
|
+
actions: nil, updated: nil, created: nil
|
37
|
+
)
|
38
|
+
super(id)
|
39
|
+
@center_id = center_id
|
40
|
+
@due = due
|
41
|
+
@tags = tags
|
42
|
+
@amount = amount
|
43
|
+
@status = status
|
44
|
+
@actions = actions
|
45
|
+
@updated = updated
|
46
|
+
@created = created
|
47
|
+
|
48
|
+
@payment, @type = parse_payment(payment: payment, type: type)
|
49
|
+
end
|
50
|
+
|
51
|
+
## Create PaymentRequests
|
52
|
+
# Sends a list of PaymentRequests objects for creating in the Stark Bank API
|
53
|
+
#
|
54
|
+
# ## Parameters
|
55
|
+
# - payment_requests [list of PaymentRequest objects]: list of PaymentRequest objects to be created in the API
|
56
|
+
# - user [Project object]: Project object. Not necessary if StarkBank.User.Default was set before function call
|
57
|
+
#
|
58
|
+
# ## Return
|
59
|
+
# - list of PaymentRequest objects with updated attributes
|
60
|
+
#
|
61
|
+
def self.create(payment_requests, user: nil)
|
62
|
+
StarkBank::Utils::Rest.post(entities: payment_requests, user: user, **resource)
|
63
|
+
end
|
64
|
+
|
65
|
+
# # Retrieve PaymentRequests
|
66
|
+
#
|
67
|
+
# Receive a generator of PaymentRequest objects previously created in the Stark Bank API
|
68
|
+
#
|
69
|
+
# ## Parameters (required):
|
70
|
+
# - center_id [string]: target cost center ID. ex: '5656565656565656'
|
71
|
+
# ## Parameters (optional):
|
72
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
73
|
+
# - after [Date , DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
74
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
75
|
+
# - status [string, default '-created']: sort order considered in response. Valid options are '-created' or '-due'.
|
76
|
+
# - type [string, default nil]: payment type, inferred from the payment parameter if it is not a dictionary. ex: 'transfer', 'boleto-payment'
|
77
|
+
# - sort [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
78
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
79
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
80
|
+
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
81
|
+
#
|
82
|
+
# ## Return:
|
83
|
+
# - generator of PaymentRequest objects with updated attributes
|
84
|
+
def self.query(center_id:, limit: nil, after: nil, before: nil, status: nil, type: nil, sort: nil, tags: nil, ids: nil, user: nil)
|
85
|
+
after = StarkBank::Utils::Checks.check_date(after)
|
86
|
+
before = StarkBank::Utils::Checks.check_date(before)
|
87
|
+
StarkBank::Utils::Rest.get_list(
|
88
|
+
center_id: center_id,
|
89
|
+
limit: limit,
|
90
|
+
after: after,
|
91
|
+
before: before,
|
92
|
+
status: status,
|
93
|
+
type: type,
|
94
|
+
sort: sort,
|
95
|
+
tags: tags,
|
96
|
+
ids: ids,
|
97
|
+
user: user,
|
98
|
+
**resource
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
def parse_payment(payment:, type:)
|
103
|
+
return [payment, 'transfer'] if payment.is_a?(StarkBank::Transfer)
|
104
|
+
return [payment, 'transaction'] if payment.is_a?(StarkBank::Transaction)
|
105
|
+
return [payment, 'boleto-payment'] if payment.is_a?(StarkBank::BoletoPayment)
|
106
|
+
return [payment, 'utility-payment'] if payment.is_a?(StarkBank::UtilityPayment)
|
107
|
+
|
108
|
+
raise(Exception('Payment must either be a Transfer, a Transaction, a BoletoPayment, a UtilityPayment or a hash.')) unless payment.is_a?(Hash)
|
109
|
+
|
110
|
+
resource = {
|
111
|
+
'transfer': StarkBank::Transfer.resource,
|
112
|
+
'transaction': StarkBank::Transaction.resource,
|
113
|
+
'boleto-payment': StarkBank::BoletoPayment.resource,
|
114
|
+
'utility-payment': StarkBank::UtilityPayment.resource
|
115
|
+
}[type.to_sym]
|
116
|
+
|
117
|
+
payment = StarkBank::Utils::API.from_api_json(resource[:resource_maker], payment) unless resource.nil?
|
118
|
+
|
119
|
+
[payment, type]
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.resource
|
123
|
+
{
|
124
|
+
resource_name: 'PaymentRequest',
|
125
|
+
resource_maker: proc { |json|
|
126
|
+
PaymentRequest.new(
|
127
|
+
id: json['id'],
|
128
|
+
payment: json['payment'],
|
129
|
+
center_id: json['centerId'],
|
130
|
+
type: json['type'],
|
131
|
+
tags: json['tags'],
|
132
|
+
amount: json['amount'],
|
133
|
+
status: json['status'],
|
134
|
+
actions: json['actions'],
|
135
|
+
updated: json['updated'],
|
136
|
+
created: json['created']
|
137
|
+
)
|
138
|
+
}
|
139
|
+
}
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
data/lib/starkbank.rb
CHANGED
@@ -4,8 +4,12 @@ require_relative('key')
|
|
4
4
|
require_relative('user/project')
|
5
5
|
require_relative('balance/balance')
|
6
6
|
require_relative('transaction/transaction')
|
7
|
+
require_relative('invoice/invoice')
|
8
|
+
require_relative('invoice/log')
|
7
9
|
require_relative('boleto/boleto')
|
8
10
|
require_relative('boleto/log')
|
11
|
+
require_relative('boleto_holmes/boleto_holmes')
|
12
|
+
require_relative('boleto_holmes/log')
|
9
13
|
require_relative('transfer/transfer')
|
10
14
|
require_relative('transfer/log')
|
11
15
|
require_relative('boleto_payment/boleto_payment')
|
@@ -14,6 +18,7 @@ require_relative('utility_payment/utility_payment')
|
|
14
18
|
require_relative('utility_payment/log')
|
15
19
|
require_relative('webhook/webhook')
|
16
20
|
require_relative('event/event')
|
21
|
+
require_relative('payment_request/payment_request')
|
17
22
|
|
18
23
|
# SDK to facilitate Ruby integrations with Stark Bank
|
19
24
|
module StarkBank
|
@@ -89,14 +89,24 @@ module StarkBank
|
|
89
89
|
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
90
90
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
91
91
|
# - external_ids [list of strings, default nil]: list of external ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
92
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
92
93
|
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
93
94
|
#
|
94
95
|
# ## Return:
|
95
96
|
# - generator of Transaction objects with updated attributes
|
96
|
-
def self.query(limit: nil, after: nil, before: nil, tags: nil, external_ids: nil, user: nil)
|
97
|
+
def self.query(limit: nil, after: nil, before: nil, tags: nil, external_ids: nil, ids: nil, user: nil)
|
97
98
|
after = StarkBank::Utils::Checks.check_date(after)
|
98
99
|
before = StarkBank::Utils::Checks.check_date(before)
|
99
|
-
StarkBank::Utils::Rest.get_list(
|
100
|
+
StarkBank::Utils::Rest.get_list(
|
101
|
+
limit: limit,
|
102
|
+
after: after,
|
103
|
+
before: before,
|
104
|
+
tags: tags,
|
105
|
+
external_ids: external_ids,
|
106
|
+
ids: ids,
|
107
|
+
user: user,
|
108
|
+
**resource
|
109
|
+
)
|
100
110
|
end
|
101
111
|
|
102
112
|
def self.resource
|
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
|
@@ -126,11 +126,12 @@ module StarkBank
|
|
126
126
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
|
127
127
|
# - tax_id [string, default nil]: filter for transfers sent to the specified tax ID. ex: "012.345.678-90"
|
128
128
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
129
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
129
130
|
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
130
131
|
#
|
131
132
|
# ## Return:
|
132
133
|
# - generator of Transfer objects with updated attributes
|
133
|
-
def self.query(limit: nil, after: nil, before: nil, transaction_ids: nil, status: nil, tax_id: nil, sort: nil, tags: nil, user: nil)
|
134
|
+
def self.query(limit: nil, after: nil, before: nil, transaction_ids: nil, status: nil, tax_id: nil, sort: nil, tags: nil, ids: nil, user: nil)
|
134
135
|
after = StarkBank::Utils::Checks.check_date(after)
|
135
136
|
before = StarkBank::Utils::Checks.check_date(before)
|
136
137
|
StarkBank::Utils::Rest.get_list(
|
@@ -142,6 +143,7 @@ module StarkBank
|
|
142
143
|
tax_id: tax_id,
|
143
144
|
sort: sort,
|
144
145
|
tags: tags,
|
146
|
+
ids: ids,
|
145
147
|
user: user,
|
146
148
|
**resource
|
147
149
|
)
|
data/lib/utils/api.rb
CHANGED
@@ -5,16 +5,22 @@ require_relative('case')
|
|
5
5
|
module StarkBank
|
6
6
|
module Utils
|
7
7
|
module API
|
8
|
-
def self.
|
8
|
+
def self.build_entity_hash(entity)
|
9
9
|
if entity.is_a?(Hash)
|
10
10
|
entity_hash = entity
|
11
11
|
else
|
12
12
|
entity_hash = {}
|
13
13
|
entity.instance_variables.each do |key|
|
14
|
-
|
14
|
+
variable = entity.instance_variable_get(key)
|
15
|
+
entity_hash[key[1..-1]] = variable.is_a?(StarkBank::Utils::Resource) ? build_entity_hash(variable) : entity.instance_variable_get(key)
|
15
16
|
end
|
16
17
|
end
|
17
|
-
|
18
|
+
entity_hash
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.api_json(entity)
|
22
|
+
built_hash = build_entity_hash(entity)
|
23
|
+
cast_json_to_api_format(built_hash)
|
18
24
|
end
|
19
25
|
|
20
26
|
def self.cast_json_to_api_format(hash)
|
@@ -22,19 +28,22 @@ module StarkBank
|
|
22
28
|
hash.each do |key, value|
|
23
29
|
next if value.nil?
|
24
30
|
|
25
|
-
|
31
|
+
entity_hash[StarkBank::Utils::Case.snake_to_camel(key)] = parse_value(value)
|
32
|
+
end
|
33
|
+
entity_hash
|
34
|
+
end
|
26
35
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
value = list
|
33
|
-
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)
|
34
41
|
|
35
|
-
|
42
|
+
list = []
|
43
|
+
value.each do |v|
|
44
|
+
list << (v.is_a?(Hash) ? cast_json_to_api_format(v) : v)
|
36
45
|
end
|
37
|
-
|
46
|
+
list
|
38
47
|
end
|
39
48
|
|
40
49
|
def self.from_api_json(resource_maker, json)
|
@@ -52,7 +61,12 @@ module StarkBank
|
|
52
61
|
end
|
53
62
|
|
54
63
|
def self.last_name_plural(resource_name)
|
55
|
-
|
64
|
+
base = last_name(resource_name)
|
65
|
+
|
66
|
+
return base if base[-1].eql?('s')
|
67
|
+
return "#{base[0...-1]}ies" if base[-1].eql?('y')
|
68
|
+
|
69
|
+
"#{base}s"
|
56
70
|
end
|
57
71
|
|
58
72
|
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-
|
64
|
+
req['User-Agent'] = "Ruby-#{RUBY_VERSION}-SDK-2.2.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,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starkbank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.2.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- starkbank
|
@@ -75,11 +75,16 @@ 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
|
78
80
|
- lib/boleto_payment/boleto_payment.rb
|
79
81
|
- lib/boleto_payment/log.rb
|
80
82
|
- lib/error.rb
|
81
83
|
- lib/event/event.rb
|
84
|
+
- lib/invoice/invoice.rb
|
85
|
+
- lib/invoice/log.rb
|
82
86
|
- lib/key.rb
|
87
|
+
- lib/payment_request/payment_request.rb
|
83
88
|
- lib/starkbank.rb
|
84
89
|
- lib/transaction/transaction.rb
|
85
90
|
- lib/transfer/log.rb
|
@@ -113,9 +118,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
118
|
version: '2.3'
|
114
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
120
|
requirements:
|
116
|
-
- - "
|
121
|
+
- - ">"
|
117
122
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
123
|
+
version: 1.3.1
|
119
124
|
requirements: []
|
120
125
|
rubygems_version: 3.1.4
|
121
126
|
signing_key:
|