starkbank 0.0.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/{ledger → balance}/balance.rb +2 -2
- data/lib/boleto/boleto.rb +47 -27
- data/lib/boleto/log.rb +19 -11
- data/lib/{payment/boleto/boleto.rb → boleto_payment/boleto_payment.rb} +35 -25
- data/lib/{payment/boleto → boleto_payment}/log.rb +23 -15
- data/lib/{webhook → event}/event.rb +29 -17
- data/lib/starkbank.rb +9 -8
- data/lib/{ledger → transaction}/transaction.rb +22 -19
- data/lib/transfer/log.rb +19 -11
- data/lib/transfer/transfer.rb +34 -22
- data/lib/user/project.rb +6 -6
- data/lib/{payment/utility → utility_payment}/log.rb +24 -16
- data/lib/{payment/utility/utility.rb → utility_payment/utility_payment.rb} +33 -24
- data/lib/utils/api.rb +16 -3
- data/lib/utils/checks.rb +8 -0
- data/lib/utils/request.rb +3 -1
- data/lib/utils/rest.rb +2 -1
- data/lib/webhook/webhook.rb +8 -8
- metadata +8 -8
@@ -9,8 +9,8 @@ require_relative('../utils/cache')
|
|
9
9
|
require_relative('../error')
|
10
10
|
require_relative('../boleto/log')
|
11
11
|
require_relative('../transfer/log')
|
12
|
-
require_relative('../
|
13
|
-
require_relative('../
|
12
|
+
require_relative('../boleto_payment/log')
|
13
|
+
require_relative('../utility_payment/log')
|
14
14
|
|
15
15
|
module StarkBank
|
16
16
|
# # Webhook Event object
|
@@ -20,11 +20,11 @@ module StarkBank
|
|
20
20
|
# list all generated updates on entities.
|
21
21
|
#
|
22
22
|
# ## Attributes:
|
23
|
-
# - id [string]: unique id returned when the
|
23
|
+
# - id [string]: unique id returned when the event is created. ex: '5656565656565656'
|
24
24
|
# - log [Log]: a Log object from one the subscription services (TransferLog, BoletoLog, BoletoPaymentlog or UtilityPaymentLog)
|
25
25
|
# - created [DateTime]: creation datetime for the notification event. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
26
26
|
# - is_delivered [bool]: true if the event has been successfully delivered to the user url. ex: False
|
27
|
-
# - subscription [string]: service that triggered this event. ex:
|
27
|
+
# - subscription [string]: service that triggered this event. ex: 'transfer', 'utility-payment'
|
28
28
|
class Event < StarkBank::Utils::Resource
|
29
29
|
attr_reader :id, :log, :created, :is_delivered, :subscription
|
30
30
|
def initialize(id:, log:, created:, is_delivered:, subscription:)
|
@@ -48,14 +48,14 @@ module StarkBank
|
|
48
48
|
# Receive a single notification Event object previously created in the Stark Bank API by passing its id
|
49
49
|
#
|
50
50
|
# ## Parameters (required):
|
51
|
-
# - id [string]: object unique id. ex:
|
51
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
52
52
|
#
|
53
53
|
# ## Parameters (optional):
|
54
54
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
55
55
|
#
|
56
56
|
# ## Return:
|
57
57
|
# - Event object with updated attributes
|
58
|
-
def self.get(id
|
58
|
+
def self.get(id, user: nil)
|
59
59
|
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
60
60
|
end
|
61
61
|
|
@@ -65,17 +65,24 @@ module StarkBank
|
|
65
65
|
#
|
66
66
|
# ## Parameters (optional):
|
67
67
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
68
|
+
# - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
69
|
+
# - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
68
70
|
# - is_delivered [bool, default nil]: bool to filter successfully delivered events. ex: True or False
|
69
|
-
# - after [Date, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
70
|
-
# - before [Date, default nil]: date filter for objects only before specified date. ex: Date.new(2020, 3, 10)
|
71
71
|
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
72
72
|
#
|
73
73
|
# ## Return:
|
74
74
|
# - generator of Event objects with updated attributes
|
75
|
-
def self.query(limit: nil,
|
75
|
+
def self.query(limit: nil, after: nil, before: nil, is_delivered: nil, user: nil)
|
76
76
|
after = StarkBank::Utils::Checks.check_date(after)
|
77
77
|
before = StarkBank::Utils::Checks.check_date(before)
|
78
|
-
StarkBank::Utils::Rest.get_list(
|
78
|
+
StarkBank::Utils::Rest.get_list(
|
79
|
+
user: user,
|
80
|
+
limit: limit,
|
81
|
+
after: after,
|
82
|
+
before: before,
|
83
|
+
is_delivered: is_delivered,
|
84
|
+
**resource
|
85
|
+
)
|
79
86
|
end
|
80
87
|
|
81
88
|
# # Delete a notification Event
|
@@ -83,14 +90,14 @@ module StarkBank
|
|
83
90
|
# Delete a of notification Event entity previously created in the Stark Bank API by its ID
|
84
91
|
#
|
85
92
|
# ## Parameters (required):
|
86
|
-
# - id [string]: Event unique id. ex:
|
93
|
+
# - id [string]: Event unique id. ex: '5656565656565656'
|
87
94
|
#
|
88
95
|
# ## Parameters (optional):
|
89
96
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
90
97
|
#
|
91
98
|
# ## Return:
|
92
99
|
# - deleted Event with updated attributes
|
93
|
-
def self.delete(id
|
100
|
+
def self.delete(id, user: nil)
|
94
101
|
StarkBank::Utils::Rest.delete_id(id: id, user: user, **resource)
|
95
102
|
end
|
96
103
|
|
@@ -100,7 +107,7 @@ module StarkBank
|
|
100
107
|
# If is_delivered is True, the event will no longer be returned on queries with is_delivered=False.
|
101
108
|
#
|
102
109
|
# ## Parameters (required):
|
103
|
-
# - id [list of strings]: Event unique ids. ex:
|
110
|
+
# - id [list of strings]: Event unique ids. ex: '5656565656565656'
|
104
111
|
# - is_delivered [bool]: If True and event hasn't been delivered already, event will be set as delivered. ex: True
|
105
112
|
#
|
106
113
|
# ## Parameters (optional):
|
@@ -108,7 +115,7 @@ module StarkBank
|
|
108
115
|
#
|
109
116
|
# ## Return:
|
110
117
|
# - target Event with updated attributes
|
111
|
-
def self.update(id
|
118
|
+
def self.update(id, is_delivered:, user: nil)
|
112
119
|
StarkBank::Utils::Rest.patch_id(id: id, user: user, is_delivered: is_delivered, **resource)
|
113
120
|
end
|
114
121
|
|
@@ -120,7 +127,7 @@ module StarkBank
|
|
120
127
|
#
|
121
128
|
# ## Parameters (required):
|
122
129
|
# - content [string]: response content from request received at user endpoint (not parsed)
|
123
|
-
# - signature [string]: base-64 digital signature received at response header
|
130
|
+
# - signature [string]: base-64 digital signature received at response header 'Digital-Signature'
|
124
131
|
#
|
125
132
|
# ## Parameters (optional):
|
126
133
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
@@ -130,6 +137,12 @@ module StarkBank
|
|
130
137
|
def self.parse(content:, signature:, user: nil)
|
131
138
|
event = StarkBank::Utils::API.from_api_json(resource[:resource_maker], JSON.parse(content)['event'])
|
132
139
|
|
140
|
+
begin
|
141
|
+
signature = EllipticCurve::Signature.fromBase64(signature)
|
142
|
+
rescue
|
143
|
+
raise(StarkBank::Error::InvalidSignatureError, 'The provided signature is not valid')
|
144
|
+
end
|
145
|
+
|
133
146
|
return event if verify_signature(content: content, signature: signature, user: user)
|
134
147
|
|
135
148
|
return event if verify_signature(content: content, signature: signature, user: user, refresh: true)
|
@@ -141,7 +154,6 @@ module StarkBank
|
|
141
154
|
private
|
142
155
|
|
143
156
|
def verify_signature(content:, signature:, user:, refresh: false)
|
144
|
-
signature = EllipticCurve::Signature.fromBase64(signature)
|
145
157
|
public_key = StarkBank::Utils::Cache.starkbank_public_key
|
146
158
|
if public_key.nil? || refresh
|
147
159
|
pem = get_public_key_pem(user)
|
@@ -152,7 +164,7 @@ module StarkBank
|
|
152
164
|
end
|
153
165
|
|
154
166
|
def get_public_key_pem(user)
|
155
|
-
StarkBank::Utils::Request.fetch(method: 'GET', path: 'public-key', query: {limit: 1}, user: user).json['publicKeys'][0]['content']
|
167
|
+
StarkBank::Utils::Request.fetch(method: 'GET', path: 'public-key', query: { limit: 1 }, user: user).json['publicKeys'][0]['content']
|
156
168
|
end
|
157
169
|
|
158
170
|
def resource
|
data/lib/starkbank.rb
CHANGED
@@ -2,21 +2,22 @@
|
|
2
2
|
|
3
3
|
require_relative('key')
|
4
4
|
require_relative('user/project')
|
5
|
-
require_relative('
|
6
|
-
require_relative('
|
5
|
+
require_relative('balance/balance')
|
6
|
+
require_relative('transaction/transaction')
|
7
7
|
require_relative('boleto/boleto')
|
8
8
|
require_relative('boleto/log')
|
9
9
|
require_relative('transfer/transfer')
|
10
10
|
require_relative('transfer/log')
|
11
|
-
require_relative('
|
12
|
-
require_relative('
|
13
|
-
require_relative('
|
14
|
-
require_relative('
|
11
|
+
require_relative('boleto_payment/boleto_payment')
|
12
|
+
require_relative('boleto_payment/log')
|
13
|
+
require_relative('utility_payment/utility_payment')
|
14
|
+
require_relative('utility_payment/log')
|
15
15
|
require_relative('webhook/webhook')
|
16
|
-
require_relative('
|
16
|
+
require_relative('event/event')
|
17
17
|
|
18
18
|
# SDK to facilitate Ruby integrations with Stark Bank
|
19
19
|
module StarkBank
|
20
20
|
@user = nil
|
21
|
-
|
21
|
+
@language = 'en-US'
|
22
|
+
class << self; attr_accessor :user, :language; end
|
22
23
|
end
|
@@ -17,22 +17,23 @@ module StarkBank
|
|
17
17
|
#
|
18
18
|
# ## Parameters (required):
|
19
19
|
# - amount [integer]: amount in cents to be transferred. ex: 1234 (= R$ 12.34)
|
20
|
-
# - description [string]: text to be displayed in the receiver and the sender statements (Min. 10 characters). ex:
|
21
|
-
# - external_id [string]: unique id, generated by user, to avoid duplicated transactions. ex:
|
22
|
-
# - received_id [string]: unique id of the receiving workspace. ex:
|
20
|
+
# - description [string]: text to be displayed in the receiver and the sender statements (Min. 10 characters). ex: 'funds redistribution'
|
21
|
+
# - external_id [string]: unique id, generated by user, to avoid duplicated transactions. ex: 'transaction ABC 2020-03-30'
|
22
|
+
# - received_id [string]: unique id of the receiving workspace. ex: '5656565656565656'
|
23
23
|
#
|
24
24
|
# ## Parameters (optional):
|
25
|
-
# - tags [list of strings]: list of strings for reference when searching transactions (may be empty). ex: [
|
25
|
+
# - tags [list of strings]: list of strings for reference when searching transactions (may be empty). ex: ['abc', 'test']
|
26
26
|
#
|
27
27
|
# ## Attributes (return-only):
|
28
|
-
# - sender_id [string]: unique id of the sending workspace. ex:
|
29
|
-
# - source [string, default nil]: locator of the entity that generated the transaction. ex:
|
30
|
-
# - id [string, default nil]: unique id returned when Transaction is created. ex:
|
31
|
-
# - fee [integer, default nil]: fee charged when
|
28
|
+
# - sender_id [string]: unique id of the sending workspace. ex: '5656565656565656'
|
29
|
+
# - source [string, default nil]: locator of the entity that generated the transaction. ex: 'charge/1827351876292', 'transfer/92873912873/chargeback'
|
30
|
+
# - id [string, default nil]: unique id returned when Transaction is created. ex: '7656565656565656'
|
31
|
+
# - fee [integer, default nil]: fee charged when transaction is created. ex: 200 (= R$ 2.00)
|
32
|
+
# - balance [integer, default nil]: account balance after transaction was processed. ex: 100000000 (= R$ 1,000,000.00)
|
32
33
|
# - created [DateTime, default nil]: creation datetime for the boleto. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
33
34
|
class Transaction < StarkBank::Utils::Resource
|
34
35
|
attr_reader :amount, :description, :external_id, :receiver_id, :sender_id, :tags, :id, :fee, :created, :source
|
35
|
-
def initialize(amount:, description:, external_id:, receiver_id:, sender_id: nil, tags: nil, id: nil, fee: nil,
|
36
|
+
def initialize(amount:, description:, external_id:, receiver_id:, sender_id: nil, tags: nil, id: nil, fee: nil, source: nil, balance: nil, created: nil)
|
36
37
|
super(id)
|
37
38
|
@amount = amount
|
38
39
|
@description = description
|
@@ -42,6 +43,7 @@ module StarkBank
|
|
42
43
|
@tags = tags
|
43
44
|
@fee = fee
|
44
45
|
@source = source
|
46
|
+
@balance = balance
|
45
47
|
@created = StarkBank::Utils::Checks.check_datetime(created)
|
46
48
|
end
|
47
49
|
|
@@ -57,7 +59,7 @@ module StarkBank
|
|
57
59
|
#
|
58
60
|
# ## Return:
|
59
61
|
# - list of Transaction objects with updated attributes
|
60
|
-
def self.create(transactions
|
62
|
+
def self.create(transactions, user: nil)
|
61
63
|
StarkBank::Utils::Rest.post(entities: transactions, user: user, **resource)
|
62
64
|
end
|
63
65
|
|
@@ -66,14 +68,14 @@ module StarkBank
|
|
66
68
|
# Receive a single Transaction object previously created in the Stark Bank API by passing its id
|
67
69
|
#
|
68
70
|
# ## Parameters (required):
|
69
|
-
# - id [string]: object unique id. ex:
|
71
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
70
72
|
#
|
71
73
|
# ## Parameters (optional):
|
72
74
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
73
75
|
#
|
74
76
|
# ## Return:
|
75
77
|
# - Transaction object with updated attributes
|
76
|
-
def self.get(id
|
78
|
+
def self.get(id, user: nil)
|
77
79
|
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
78
80
|
end
|
79
81
|
|
@@ -83,17 +85,17 @@ module StarkBank
|
|
83
85
|
#
|
84
86
|
# ## Parameters (optional):
|
85
87
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
86
|
-
# -
|
87
|
-
# -
|
88
|
-
# -
|
88
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
89
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
90
|
+
# - external_ids [list of strings, default nil]: list of external ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
89
91
|
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
90
92
|
#
|
91
93
|
# ## Return:
|
92
94
|
# - generator of Transaction objects with updated attributes
|
93
|
-
def self.query(limit: nil,
|
95
|
+
def self.query(limit: nil, after: nil, before: nil, external_ids: nil, user: nil)
|
94
96
|
after = StarkBank::Utils::Checks.check_date(after)
|
95
97
|
before = StarkBank::Utils::Checks.check_date(before)
|
96
|
-
StarkBank::Utils::Rest.get_list(user: user, limit: limit,
|
98
|
+
StarkBank::Utils::Rest.get_list(user: user, limit: limit, after: after, before: before, external_ids: external_ids, **resource)
|
97
99
|
end
|
98
100
|
|
99
101
|
def self.resource
|
@@ -109,8 +111,9 @@ module StarkBank
|
|
109
111
|
tags: json['tags'],
|
110
112
|
id: json['id'],
|
111
113
|
fee: json['fee'],
|
112
|
-
|
113
|
-
|
114
|
+
source: json['source'],
|
115
|
+
balance: json['balance'],
|
116
|
+
created: json['created']
|
114
117
|
)
|
115
118
|
}
|
116
119
|
}
|
data/lib/transfer/log.rb
CHANGED
@@ -14,11 +14,11 @@ module StarkBank
|
|
14
14
|
# user.
|
15
15
|
#
|
16
16
|
# ## Attributes:
|
17
|
-
# - id [string]: unique id returned when the log is created. ex:
|
17
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
18
18
|
# - transfer [Transfer]: Transfer entity to which the log refers to.
|
19
19
|
# - errors [list of strings]: list of errors linked to this BoletoPayment event.
|
20
|
-
# - type [string]: type of the Transfer event which triggered the log creation. ex:
|
21
|
-
# - created [DateTime]: creation datetime for the
|
20
|
+
# - type [string]: type of the Transfer event which triggered the log creation. ex: 'processing' or 'success'
|
21
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
22
22
|
class Log < StarkBank::Utils::Resource
|
23
23
|
attr_reader :id, :created, :type, :errors, :transfer
|
24
24
|
def initialize(id:, created:, type:, errors:, transfer:)
|
@@ -34,14 +34,14 @@ module StarkBank
|
|
34
34
|
# Receive a single Log object previously created by the Stark Bank API by passing its id
|
35
35
|
#
|
36
36
|
# ## Parameters (required):
|
37
|
-
# - id [string]: object unique id. ex:
|
37
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
38
38
|
#
|
39
39
|
# ## Parameters (optional):
|
40
40
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
41
41
|
#
|
42
42
|
# ## Return:
|
43
43
|
# - Log object with updated attributes
|
44
|
-
def self.get(id
|
44
|
+
def self.get(id, user: nil)
|
45
45
|
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
46
46
|
end
|
47
47
|
|
@@ -51,18 +51,26 @@ module StarkBank
|
|
51
51
|
#
|
52
52
|
# ## Parameters (optional):
|
53
53
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
54
|
-
# -
|
55
|
-
# -
|
56
|
-
# -
|
57
|
-
# -
|
54
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
55
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
56
|
+
# - types [list of strings, default nil]: filter retrieved objects by types. ex: 'success' or 'failed'
|
57
|
+
# - transfer_ids [list of strings, default nil]: list of Transfer ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
58
58
|
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
59
59
|
#
|
60
60
|
# ## Return:
|
61
61
|
# - list of Log objects with updated attributes
|
62
|
-
def self.query(limit: nil,
|
62
|
+
def self.query(limit: nil, after: nil, before: nil, types: nil, transfer_ids: nil, user: nil)
|
63
63
|
after = StarkBank::Utils::Checks.check_date(after)
|
64
64
|
before = StarkBank::Utils::Checks.check_date(before)
|
65
|
-
StarkBank::Utils::Rest.get_list(
|
65
|
+
StarkBank::Utils::Rest.get_list(
|
66
|
+
limit: limit,
|
67
|
+
after: after,
|
68
|
+
before: before,
|
69
|
+
types: types,
|
70
|
+
transfer_ids: transfer_ids,
|
71
|
+
user: user,
|
72
|
+
**resource
|
73
|
+
)
|
66
74
|
end
|
67
75
|
|
68
76
|
def self.resource
|
data/lib/transfer/transfer.rb
CHANGED
@@ -13,20 +13,20 @@ module StarkBank
|
|
13
13
|
#
|
14
14
|
# ## Parameters (required):
|
15
15
|
# - amount [integer]: amount in cents to be transferred. ex: 1234 (= R$ 12.34)
|
16
|
-
# - name [string]: receiver full name. ex:
|
17
|
-
# - tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex:
|
18
|
-
# - bank_code [string]:
|
19
|
-
# - branch_code [string]: receiver bank account branch. Use '-' in case there is a verifier digit. ex:
|
20
|
-
# - account_number [string]: Receiver Bank Account number. Use '-' before the verifier digit. ex:
|
16
|
+
# - name [string]: receiver full name. ex: 'Anthony Edward Stark'
|
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]: 1 to 3 digits of the receiver bank institution in Brazil. ex: '200' or '341'
|
19
|
+
# - branch_code [string]: receiver bank account branch. Use '-' in case there is a verifier digit. ex: '1357-9'
|
20
|
+
# - account_number [string]: Receiver Bank Account number. Use '-' before the verifier digit. ex: '876543-2'
|
21
21
|
#
|
22
22
|
# ## Parameters (optional):
|
23
|
-
# - tags [list of strings]: list of strings for reference when searching for transfers. ex: [
|
23
|
+
# - tags [list of strings]: list of strings for reference when searching for transfers. ex: ['employees', 'monthly']
|
24
24
|
#
|
25
25
|
# ## Attributes (return-only):
|
26
|
-
# - id [string, default nil]: unique id returned when Transfer is created. ex:
|
26
|
+
# - id [string, default nil]: unique id returned when Transfer is created. ex: '5656565656565656'
|
27
27
|
# - fee [integer, default nil]: fee charged when transfer is created. ex: 200 (= R$ 2.00)
|
28
|
-
# - status [string, default nil]: current
|
29
|
-
# - transaction_ids [list of strings, default nil]: ledger transaction ids linked to this transfer (if there are two, second is the chargeback). ex: [
|
28
|
+
# - status [string, default nil]: current transfer status. ex: 'success' or 'failed'
|
29
|
+
# - transaction_ids [list of strings, default nil]: ledger transaction ids linked to this transfer (if there are two, second is the chargeback). ex: ['19827356981273']
|
30
30
|
# - created [DateTime, default nil]: creation datetime for the transfer. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
31
31
|
# - updated [DateTime, default nil]: latest update datetime for the transfer. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
32
32
|
class Transfer < StarkBank::Utils::Resource
|
@@ -59,7 +59,7 @@ module StarkBank
|
|
59
59
|
#
|
60
60
|
# ## Return:
|
61
61
|
# - list of Transfer objects with updated attributes
|
62
|
-
def self.create(transfers
|
62
|
+
def self.create(transfers, user: nil)
|
63
63
|
StarkBank::Utils::Rest.post(entities: transfers, user: user, **resource)
|
64
64
|
end
|
65
65
|
|
@@ -68,31 +68,31 @@ module StarkBank
|
|
68
68
|
# Receive a single Transfer object previously created in the Stark Bank API by passing its id
|
69
69
|
#
|
70
70
|
# ## Parameters (required):
|
71
|
-
# - id [string]: object unique id. ex:
|
71
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
72
72
|
#
|
73
73
|
# ## Parameters (optional):
|
74
74
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
75
75
|
#
|
76
76
|
# ## Return:
|
77
77
|
# - Transfer object with updated attributes
|
78
|
-
def self.get(id
|
78
|
+
def self.get(id, user: nil)
|
79
79
|
StarkBank::Utils::Rest.get_id(id: id, user: user, **resource)
|
80
80
|
end
|
81
81
|
|
82
82
|
# # Retrieve a specific Transfer pdf file
|
83
83
|
#
|
84
84
|
# Receive a single Transfer pdf receipt file generated in the Stark Bank API by passing its id.
|
85
|
-
# Only valid for transfers with
|
85
|
+
# Only valid for transfers with 'processing' and 'success' status.
|
86
86
|
#
|
87
87
|
# ## Parameters (required):
|
88
|
-
# - id [string]: object unique id. ex:
|
88
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
89
89
|
#
|
90
90
|
# ## Parameters (optional):
|
91
91
|
# - user [Project object]: Project object. Not necessary if StarkBank.user was set before function call
|
92
92
|
#
|
93
93
|
# ## Return:
|
94
94
|
# - Transfer pdf file
|
95
|
-
def self.pdf(id
|
95
|
+
def self.pdf(id, user: nil)
|
96
96
|
StarkBank::Utils::Rest.get_pdf(id: id, user: user, **resource)
|
97
97
|
end
|
98
98
|
|
@@ -102,19 +102,31 @@ module StarkBank
|
|
102
102
|
#
|
103
103
|
# ## Parameters (optional):
|
104
104
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
105
|
-
# -
|
106
|
-
# -
|
107
|
-
# -
|
108
|
-
# -
|
109
|
-
# -
|
105
|
+
# - after [Date, DateTime, Time or string, default nil] date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
|
106
|
+
# - before [Date, DateTime, Time or string, default nil] date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
|
107
|
+
# - transactionIds [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
108
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
|
109
|
+
# - tax_id [string, default nil]: filter for transfers sent to the specified tax ID. ex: "012.345.678-90"
|
110
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
110
111
|
# - user [Project object, default nil]: Project object. Not necessary if StarkBank.user was set before function call
|
111
112
|
#
|
112
113
|
# ## Return:
|
113
114
|
# - generator of Transfer objects with updated attributes
|
114
|
-
def self.query(limit: nil,
|
115
|
+
def self.query(limit: nil, after: nil, before: nil, transaction_ids: nil, status: nil, tax_id: nil, sort: nil, tags: nil, user: nil)
|
115
116
|
after = StarkBank::Utils::Checks.check_date(after)
|
116
117
|
before = StarkBank::Utils::Checks.check_date(before)
|
117
|
-
StarkBank::Utils::Rest.get_list(
|
118
|
+
StarkBank::Utils::Rest.get_list(
|
119
|
+
limit: limit,
|
120
|
+
after: after,
|
121
|
+
before: before,
|
122
|
+
transaction_ids: transaction_ids,
|
123
|
+
status: status,
|
124
|
+
tax_id: tax_id,
|
125
|
+
sort: sort,
|
126
|
+
tags: tags,
|
127
|
+
user: user,
|
128
|
+
**resource
|
129
|
+
)
|
118
130
|
end
|
119
131
|
|
120
132
|
def self.resource
|
data/lib/user/project.rb
CHANGED
@@ -13,14 +13,14 @@ module StarkBank
|
|
13
13
|
# each request or may be defined as the default user at the start (See README).
|
14
14
|
#
|
15
15
|
# ## Parameters (required):
|
16
|
-
# - id [string]: unique id required to identify project. ex:
|
17
|
-
# - private_key [EllipticCurve.Project()]: PEM string of the private key linked to the project. ex:
|
18
|
-
# - environment [string]: environment where the project is being used. ex:
|
16
|
+
# - id [string]: unique id required to identify project. ex: '5656565656565656'
|
17
|
+
# - private_key [EllipticCurve.Project()]: PEM string of the private key linked to the project. ex: '-----BEGIN PUBLIC KEY-----\nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEyTIHK6jYuik6ktM9FIF3yCEYzpLjO5X/\ntqDioGM+R2RyW0QEo+1DG8BrUf4UXHSvCjtQ0yLppygz23z0yPZYfw==\n-----END PUBLIC KEY-----'
|
18
|
+
# - environment [string]: environment where the project is being used. ex: 'sandbox' or 'production'
|
19
19
|
#
|
20
20
|
# ## Attributes (return-only):
|
21
|
-
# - name [string, default
|
22
|
-
# - allowed_ips [list of strings]: list containing the strings of the ips allowed to make requests on behalf of this project. ex: [
|
23
|
-
# - pem [string]: private key in pem format. ex:
|
21
|
+
# - name [string, default ']: project name. ex: 'MyProject'
|
22
|
+
# - allowed_ips [list of strings]: list containing the strings of the ips allowed to make requests on behalf of this project. ex: ['190.190.0.50']
|
23
|
+
# - pem [string]: private key in pem format. ex: '-----BEGIN PUBLIC KEY-----\nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEyTIHK6jYuik6ktM9FIF3yCEYzpLjO5X/\ntqDioGM+R2RyW0QEo+1DG8BrUf4UXHSvCjtQ0yLppygz23z0yPZYfw==\n-----END PUBLIC KEY-----'
|
24
24
|
class Project < StarkBank::User
|
25
25
|
attr_reader :name, :allowed_ips
|
26
26
|
def initialize(environment:, id:, private_key:, name: '', allowed_ips: nil)
|