starkinfra 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/brcodepreview/brcodepreview.rb +125 -0
- data/lib/cardmethod/cardmethod.rb +56 -0
- data/lib/creditholmes/creditholmes.rb +160 -0
- data/lib/creditnote/creditnote.rb +51 -355
- data/lib/creditnote/invoice/description.rb +51 -0
- data/lib/creditnote/invoice/discount.rb +49 -0
- data/lib/creditnote/invoice/invoice.rb +124 -0
- data/lib/creditnote/log.rb +18 -19
- data/lib/creditnote/transfer.rb +90 -0
- data/lib/creditpreview/creditnotepreview.rb +85 -0
- data/lib/creditpreview/creditpreview.rb +77 -0
- data/lib/creditsigner/creditsigner.rb +57 -0
- data/lib/dynamicbrcode/dynamicbrcode.rb +350 -0
- data/lib/event/attempt.rb +5 -4
- data/lib/event/event.rb +11 -11
- data/lib/individualdocument/individualdocument.rb +165 -0
- data/lib/individualdocument/log.rb +125 -0
- data/lib/individualidentity/individualidentity.rb +193 -0
- data/lib/individualidentity/log.rb +124 -0
- data/lib/issuingbalance/issuingbalance.rb +4 -4
- data/lib/issuingcard/issuingcard.rb +35 -33
- data/lib/issuingcard/log.rb +21 -21
- data/lib/issuingdesign/issuingdesign.rb +138 -0
- data/lib/issuingembossingkit/issuingembossingkit.rb +121 -0
- data/lib/issuingembossingrequest/issuingembossingrequest.rb +210 -0
- data/lib/issuingembossingrequest/log.rb +128 -0
- data/lib/issuingholder/issuingholder.rb +21 -15
- data/lib/issuingholder/log.rb +19 -19
- data/lib/issuinginvoice/issuinginvoice.rb +29 -14
- data/lib/issuinginvoice/log.rb +18 -18
- data/lib/{issuingbin/issuingbin.rb → issuingproduct/issuingproduct.rb} +27 -30
- data/lib/issuingpurchase/issuingpurchase.rb +111 -31
- data/lib/issuingpurchase/log.rb +16 -16
- data/lib/issuingrestock/issuingrestock.rb +162 -0
- data/lib/issuingrestock/log.rb +127 -0
- data/lib/issuingrule/issuingrule.rb +64 -18
- data/lib/issuingstock/issuingstock.rb +138 -0
- data/lib/issuingstock/log.rb +130 -0
- data/lib/issuingtransaction/issuingtransaction.rb +12 -13
- data/lib/issuingwithdrawal/issuingwithdrawal.rb +12 -11
- data/lib/merchantcategory/merchantcategory.rb +63 -0
- data/lib/merchantcountry/merchantcountry.rb +59 -0
- data/lib/pixbalance/pixbalance.rb +5 -5
- data/lib/pixchargeback/log.rb +15 -15
- data/lib/pixchargeback/pixchargeback.rb +32 -20
- data/lib/pixclaim/log.rb +21 -24
- data/lib/pixclaim/pixclaim.rb +44 -34
- data/lib/pixdirector/pixdirector.rb +9 -11
- data/lib/pixdomain/certificate.rb +1 -1
- data/lib/pixdomain/pixdomain.rb +5 -5
- data/lib/pixinfraction/log.rb +20 -20
- data/lib/pixinfraction/pixinfraction.rb +23 -15
- data/lib/pixkey/log.rb +23 -23
- data/lib/pixkey/pixkey.rb +14 -12
- data/lib/pixrequest/log.rb +24 -20
- data/lib/pixrequest/pixrequest.rb +54 -21
- data/lib/pixreversal/log.rb +3 -3
- data/lib/pixreversal/pixreversal.rb +48 -21
- data/lib/pixstatement/pixstatement.rb +13 -8
- data/lib/starkinfra.rb +40 -15
- data/lib/staticbrcode/staticbrcode.rb +170 -0
- data/lib/user/project.rb +1 -1
- data/lib/utils/api.rb +1 -0
- data/lib/utils/bacenid.rb +1 -1
- data/lib/utils/parse.rb +7 -3
- data/lib/utils/request.rb +1 -1
- data/lib/utils/resource.rb +1 -1
- data/lib/utils/sub_resource.rb +21 -22
- data/lib/webhook/webhook.rb +11 -11
- metadata +29 -4
- data/lib/issuingauthorization/issuingauthorization.rb +0 -141
data/lib/pixkey/log.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('
|
3
|
+
require_relative('pixkey')
|
4
4
|
require_relative('../utils/rest')
|
5
5
|
require_relative('../utils/checks')
|
6
|
-
require_relative('
|
6
|
+
require_relative('../utils/resource')
|
7
7
|
|
8
8
|
module StarkInfra
|
9
9
|
class PixKey
|
@@ -12,25 +12,25 @@ module StarkInfra
|
|
12
12
|
# Every time a PixKey entity is modified, a corresponding PixKey::Log is generated for the entity.
|
13
13
|
# This log is never generated by the user.
|
14
14
|
#
|
15
|
-
# ## Attributes:
|
15
|
+
# ## Attributes (return-only):
|
16
16
|
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
17
|
-
# -
|
17
|
+
# - key [PixKey]: PixKey entity to which the log refers to.
|
18
18
|
# - type [string]: type of the PixKey event which triggered the log creation. Options: 'created', 'registered', 'updated', 'failed', 'canceling', 'canceled'.
|
19
19
|
# - errors [list of strings]: list of errors linked to this PixKey event.
|
20
|
-
# -
|
20
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
21
21
|
class Log < StarkInfra::Utils::Resource
|
22
22
|
attr_reader :id, :created, :type, :errors, :key
|
23
23
|
def initialize(id:, created:, type:, errors:, key:)
|
24
24
|
super(id)
|
25
|
-
@
|
25
|
+
@key = key
|
26
26
|
@type = type
|
27
27
|
@errors = errors
|
28
|
-
@
|
28
|
+
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
29
29
|
end
|
30
30
|
|
31
|
-
# # Retrieve a specific Log
|
31
|
+
# # Retrieve a specific PixKey::Log
|
32
32
|
#
|
33
|
-
# Receive a single Log object previously created by the Stark Infra API by passing its id
|
33
|
+
# Receive a single PixKey::Log object previously created by the Stark Infra API by passing its id
|
34
34
|
#
|
35
35
|
# ## Parameters (required):
|
36
36
|
# - id [string]: object unique id. ex: '5656565656565656'
|
@@ -39,26 +39,26 @@ module StarkInfra
|
|
39
39
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
40
40
|
#
|
41
41
|
# ## Return:
|
42
|
-
# - Log object with updated attributes
|
42
|
+
# - PixKey::Log object with updated attributes
|
43
43
|
def self.get(id, user: nil)
|
44
44
|
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
45
45
|
end
|
46
46
|
|
47
|
-
# # Retrieve Logs
|
47
|
+
# # Retrieve PixKey::Logs
|
48
48
|
#
|
49
|
-
# Receive a generator of Log objects previously created in the Stark Infra API
|
49
|
+
# Receive a generator of PixKey::Log objects previously created in the Stark Infra API
|
50
50
|
#
|
51
51
|
# ## Parameters (optional):
|
52
|
-
# - ids [list of strings, default nil]: Log ids to filter PixKey Logs. ex: ['5656565656565656']
|
53
52
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
54
53
|
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
55
54
|
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
56
55
|
# - types [list of strings, default nil]: filter PixKey Logs by their types. Options: 'created', 'registered', 'updated', 'failed', 'canceling', 'canceled'.
|
57
|
-
# - key_ids [list of strings, default nil]: list of PixKey ids to filter retrieved objects. ex:
|
56
|
+
# - key_ids [list of strings, default nil]: list of PixKey ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
57
|
+
# - ids [list of strings, default nil]: Log ids to filter PixKey Logs. ex: ['5656565656565656']
|
58
58
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
59
59
|
#
|
60
60
|
# ## Return:
|
61
|
-
# - generator of Log objects with updated attributes
|
61
|
+
# - generator of PixKey::Log objects with updated attributes
|
62
62
|
def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, key_ids: nil, user: nil)
|
63
63
|
after = StarkInfra::Utils::Checks.check_date(after)
|
64
64
|
before = StarkInfra::Utils::Checks.check_date(before)
|
@@ -74,23 +74,23 @@ module StarkInfra
|
|
74
74
|
)
|
75
75
|
end
|
76
76
|
|
77
|
-
# # Retrieve paged Logs
|
77
|
+
# # Retrieve paged PixKey::Logs
|
78
78
|
#
|
79
|
-
# Receive a list of up to 100 Log objects previously created in the Stark Infra API and the cursor to the next page.
|
79
|
+
# Receive a list of up to 100 PixKey::Log objects previously created in the Stark Infra API and the cursor to the next page.
|
80
80
|
# Use this function instead of query if you want to manually page your keys.
|
81
81
|
#
|
82
82
|
# ## Parameters (optional):
|
83
|
-
# - ids [list of strings, default nil]: Log ids to filter PixKey Logs. ex: ['5656565656565656']
|
84
83
|
# - cursor [string, default nil]: cursor returned on the previous page function call
|
85
84
|
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
86
85
|
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
87
86
|
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
88
|
-
# - types [list of strings]: filter PixKey Logs by their types. Options: 'created', 'registered', 'updated', 'failed', 'canceling', 'canceled'.
|
89
|
-
# - key_ids [list of strings, default nil]: list of PixKey ids to filter retrieved objects. ex:
|
87
|
+
# - types [list of strings, default nil]: filter PixKey Logs by their types. Options: 'created', 'registered', 'updated', 'failed', 'canceling', 'canceled'.
|
88
|
+
# - key_ids [list of strings, default nil]: list of PixKey ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
89
|
+
# - ids [list of strings, default nil]: Log ids to filter PixKey Logs. ex: ['5656565656565656']
|
90
90
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
91
91
|
#
|
92
92
|
# ## Return:
|
93
|
-
# - list of Log objects with updated attributes
|
93
|
+
# - list of PixKey::Log objects with updated attributes
|
94
94
|
# - cursor to retrieve the next page of Log objects
|
95
95
|
def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, key_ids: nil, user: nil)
|
96
96
|
after = StarkInfra::Utils::Checks.check_date(after)
|
@@ -115,10 +115,10 @@ module StarkInfra
|
|
115
115
|
resource_maker: proc { |json|
|
116
116
|
Log.new(
|
117
117
|
id: json['id'],
|
118
|
-
|
118
|
+
key: StarkInfra::Utils::API.from_api_json(key_maker, json['key']),
|
119
119
|
type: json['type'],
|
120
120
|
errors: json['errors'],
|
121
|
-
|
121
|
+
created: json['created']
|
122
122
|
)
|
123
123
|
}
|
124
124
|
}
|
data/lib/pixkey/pixkey.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('../utils/resource')
|
4
3
|
require_relative('../utils/rest')
|
5
4
|
require_relative('../utils/checks')
|
5
|
+
require_relative('../utils/resource')
|
6
6
|
|
7
7
|
module StarkInfra
|
8
8
|
# # PixKey object
|
9
|
+
#
|
9
10
|
# PixKeys link bank account information to key ids.
|
10
11
|
# Key ids are a convenient way to search and pass bank account information.
|
12
|
+
#
|
11
13
|
# When you initialize a Pix Key, the entity will not be automatically
|
12
14
|
# created in the Stark Infra API. The 'create' function sends the objects
|
13
15
|
# to the Stark Infra API and returns the created object.
|
14
16
|
#
|
15
17
|
# ## Parameters (required):
|
16
|
-
# - account_created [DateTime
|
18
|
+
# - account_created [DateTime or string]: opening Date or DateTime for the linked account. ex: '2020-03-10T10:30:00.000000+00:00' or DateTime.new(2020, 3, 10, 10, 30, 0, 0).
|
17
19
|
# - account_number [string]: number of the linked account. ex: '76543'.
|
18
20
|
# - account_type [string]: type of the linked account. Options: 'checking', 'savings', 'salary' or 'payment'.
|
19
21
|
# - branch_code [string]: branch code of the linked account. ex: '1234'.
|
@@ -58,7 +60,7 @@ module StarkInfra
|
|
58
60
|
|
59
61
|
# # Create a PixKey
|
60
62
|
#
|
61
|
-
#
|
63
|
+
# Create a PixKey linked to a specific account in the Stark Infra API
|
62
64
|
#
|
63
65
|
# ## Parameters (required):
|
64
66
|
# - key [PixKey object]: PixKey object to be created in the API
|
@@ -77,7 +79,7 @@ module StarkInfra
|
|
77
79
|
# Receive a single PixKey object previously created in the Stark Infra API by passing its id
|
78
80
|
#
|
79
81
|
# ## Parameters (required):
|
80
|
-
# - id [string]: object unique id. ex: '
|
82
|
+
# - id [string]: object unique id. ex: '+5511989898989'
|
81
83
|
# - payer_id [string]: tax id (CPF/CNPJ) of the individual or business requesting the PixKey information. This id is used by the Central Bank to limit request rates. ex: '20.018.183/0001-80'.
|
82
84
|
#
|
83
85
|
# ## Parameters (optional):
|
@@ -106,7 +108,7 @@ module StarkInfra
|
|
106
108
|
# - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
|
107
109
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
|
108
110
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
109
|
-
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['
|
111
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['+5511989898989', '+5511967676767']
|
110
112
|
# - type [string, default nil]: filter for the type of retrieved PixKeys. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp'
|
111
113
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
112
114
|
#
|
@@ -140,7 +142,7 @@ module StarkInfra
|
|
140
142
|
# - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
|
141
143
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
|
142
144
|
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
143
|
-
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['
|
145
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['+5511989898989', '+5511967676767']
|
144
146
|
# - type [string, default nil]: filter for the type of retrieved PixKeys. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp'
|
145
147
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
146
148
|
#
|
@@ -166,14 +168,14 @@ module StarkInfra
|
|
166
168
|
|
167
169
|
# # Update a PixKey entity
|
168
170
|
#
|
169
|
-
#
|
171
|
+
# Update a PixKey parameters by passing id.
|
170
172
|
#
|
171
173
|
# ## Parameters (required):
|
172
|
-
# - id [string]: PixKey unique id. ex: '
|
174
|
+
# - id [string]: PixKey unique id. ex: '+5511989898989'
|
173
175
|
# - reason [string]: reason why the PixKey is being patched. Options: 'branchTransfer', 'reconciliation' or 'userRequested'.
|
174
176
|
#
|
175
177
|
# ## Parameters (optional):
|
176
|
-
# - account_created [Date, DateTime or string, default nil]: opening Date or DateTime for the account to be linked. ex: '2022-01-01.
|
178
|
+
# - account_created [Date, DateTime or string, default nil]: opening Date or DateTime for the account to be linked. ex: '2022-01-01', Date.new(2020, 3, 10) or DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
177
179
|
# - account_number [string, default nil]: number of the account to be linked. ex: '76543'.
|
178
180
|
# - account_type [string, default nil]: type of the account to be linked. Options: 'checking', 'savings', 'salary' or 'payment'.
|
179
181
|
# - branch_code [string, default nil]: branch code of the account to be linked. ex: 1234'.
|
@@ -181,7 +183,7 @@ module StarkInfra
|
|
181
183
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
182
184
|
#
|
183
185
|
# ## Return:
|
184
|
-
# -
|
186
|
+
# - PixKey object with updated attributes
|
185
187
|
def self.update(id, reason:, account_created: nil, account_number: nil, account_type: nil, branch_code: nil, name: nil, user: nil)
|
186
188
|
StarkInfra::Utils::Rest.patch_id(
|
187
189
|
id: id,
|
@@ -201,7 +203,7 @@ module StarkInfra
|
|
201
203
|
# Cancel a PixKey entity previously created in the Stark Infra API
|
202
204
|
#
|
203
205
|
# ## Parameters (required):
|
204
|
-
# - id [string]: PixKey unique id. ex: '
|
206
|
+
# - id [string]: PixKey unique id. ex: '+5511989898989'
|
205
207
|
#
|
206
208
|
# ## Parameters (optional):
|
207
209
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
@@ -217,13 +219,13 @@ module StarkInfra
|
|
217
219
|
resource_name: 'PixKey',
|
218
220
|
resource_maker: proc { |json|
|
219
221
|
PixKey.new(
|
222
|
+
id: json['id'],
|
220
223
|
account_created: json['account_created'],
|
221
224
|
account_number: json['account_number'],
|
222
225
|
account_type: json['account_type'],
|
223
226
|
branch_code: json['branch_code'],
|
224
227
|
name: json['name'],
|
225
228
|
tax_id: json['tax_id'],
|
226
|
-
id: json['id'],
|
227
229
|
tags: json['tags'],
|
228
230
|
owned: json['owned'],
|
229
231
|
owner_type: json['owner_type'],
|
data/lib/pixrequest/log.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('
|
3
|
+
require_relative('pixrequest')
|
4
4
|
require_relative('../utils/rest')
|
5
5
|
require_relative('../utils/checks')
|
6
|
-
require_relative('
|
6
|
+
require_relative('../utils/resource')
|
7
7
|
|
8
8
|
module StarkInfra
|
9
9
|
class PixRequest
|
@@ -12,12 +12,12 @@ module StarkInfra
|
|
12
12
|
# Every time a PixRequest entity is modified, a corresponding PixRequest::Log is generated for the entity.
|
13
13
|
# This log is never generated by the user.
|
14
14
|
#
|
15
|
-
# ## Attributes:
|
15
|
+
# ## Attributes (return-only):
|
16
16
|
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
17
|
-
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
18
|
-
# - type [string]: type of the PixRequest event which triggered the log creation. ex: 'processing' or 'success'
|
19
|
-
# - errors [list of strings]: list of errors linked to this PixRequest event.
|
20
17
|
# - request [PixRequest object]: PixRequest entity to which the log refers to.
|
18
|
+
# - type [string]: type of the PixRequest event which triggered the log creation. ex: "sent", "denied", "failed", "created", "success", "approved", "credited", "refunded", "processing"
|
19
|
+
# - errors [list of strings]: list of errors linked to this PixRequest event.
|
20
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
21
21
|
class Log < StarkInfra::Utils::Resource
|
22
22
|
attr_reader :id, :created, :type, :errors, :request
|
23
23
|
def initialize(id:, created:, type:, errors:, request:)
|
@@ -28,9 +28,9 @@ module StarkInfra
|
|
28
28
|
@request = request
|
29
29
|
end
|
30
30
|
|
31
|
-
# # Retrieve a specific Log
|
31
|
+
# # Retrieve a specific PixRequest::Log
|
32
32
|
#
|
33
|
-
# Receive a single Log object previously created by the Stark Infra API by passing its id
|
33
|
+
# Receive a single PixRequest::Log object previously created by the Stark Infra API by passing its id
|
34
34
|
#
|
35
35
|
# ## Parameters (required):
|
36
36
|
# - id [string]: object unique id. ex: '5656565656565656'
|
@@ -39,27 +39,28 @@ module StarkInfra
|
|
39
39
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
40
40
|
#
|
41
41
|
# ## Return:
|
42
|
-
# - Log object with updated attributes
|
42
|
+
# - PixRequest::Log object with updated attributes
|
43
43
|
def self.get(id, user: nil)
|
44
44
|
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
45
45
|
end
|
46
46
|
|
47
|
-
# # Retrieve Logs
|
47
|
+
# # Retrieve PixRequest::Logs
|
48
48
|
#
|
49
|
-
# Receive a generator of Log objects previously created in the Stark Infra API
|
49
|
+
# Receive a generator of PixRequest::Log objects previously created in the Stark Infra API
|
50
50
|
#
|
51
51
|
# ## Parameters (optional):
|
52
|
-
# - ids [list of strings, default nil]: Log ids to filter PixKey Logs. ex: ['5656565656565656']
|
53
52
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
54
53
|
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
55
54
|
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
56
55
|
# - types [list of strings, default nil]: filter retrieved objects by types. ex: 'success' or 'failed'
|
57
56
|
# - request_ids [list of strings, default nil]: list of PixRequest ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
57
|
+
# - reconciliation_id [string, default nil]: PixRequest reconciliation id to filter retrieved objects. ex: "b77f5236-7ab9-4487-9f95-66ee6eaf1781"
|
58
|
+
# - ids [list of strings, default nil]: Log ids to filter PixKey Logs. ex: ['5656565656565656']
|
58
59
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
59
60
|
#
|
60
61
|
# ## Return:
|
61
|
-
# - generator of Log objects with updated attributes
|
62
|
-
def self.query(limit: nil, after: nil, before: nil, types: nil, request_ids: nil, user: nil)
|
62
|
+
# - generator of PixRequest::Log objects with updated attributes
|
63
|
+
def self.query(limit: nil, after: nil, before: nil, types: nil, request_ids: nil, reconciliation_id: nil, user: nil)
|
63
64
|
after = StarkInfra::Utils::Checks.check_date(after)
|
64
65
|
before = StarkInfra::Utils::Checks.check_date(before)
|
65
66
|
StarkInfra::Utils::Rest.get_stream(
|
@@ -68,14 +69,15 @@ module StarkInfra
|
|
68
69
|
before: before,
|
69
70
|
types: types,
|
70
71
|
request_ids: request_ids,
|
72
|
+
reconciliation_id: reconciliation_id,
|
71
73
|
user: user,
|
72
74
|
**resource
|
73
75
|
)
|
74
76
|
end
|
75
77
|
|
76
|
-
# # Retrieve paged Logs
|
78
|
+
# # Retrieve paged PixRequest::Logs
|
77
79
|
#
|
78
|
-
# Receive a list of up to 100 Log objects previously created in the Stark Infra API and the cursor to the next page.
|
80
|
+
# Receive a list of up to 100 PixRequest::Log objects previously created in the Stark Infra API and the cursor to the next page.
|
79
81
|
# Use this function instead of query if you want to manually page your logs.
|
80
82
|
#
|
81
83
|
# ## Parameters (optional):
|
@@ -85,12 +87,13 @@ module StarkInfra
|
|
85
87
|
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
86
88
|
# - types [list of strings, default nil]: filter retrieved objects by types. ex: 'success' or 'failed'
|
87
89
|
# - request_ids [list of strings, default nil]: list of PixRequest ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
90
|
+
# - reconciliation_id [string]: PixRequest reconciliation id to filter retrieved objects. ex: "b77f5236-7ab9-4487-9f95-66ee6eaf1781"
|
88
91
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
89
92
|
#
|
90
93
|
# ## Return:
|
91
|
-
# - list of Log objects with updated attributes
|
94
|
+
# - list of PixRequest::Log objects with updated attributes
|
92
95
|
# - cursor to retrieve the next page of Log objects
|
93
|
-
def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, request_ids: nil, user: nil)
|
96
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, request_ids: nil, reconciliation_id: nil, user: nil)
|
94
97
|
after = StarkInfra::Utils::Checks.check_date(after)
|
95
98
|
before = StarkInfra::Utils::Checks.check_date(before)
|
96
99
|
StarkInfra::Utils::Rest.get_page(
|
@@ -100,6 +103,7 @@ module StarkInfra
|
|
100
103
|
before: before,
|
101
104
|
types: types,
|
102
105
|
request_ids: request_ids,
|
106
|
+
reconciliation_id: reconciliation_id,
|
103
107
|
user: user,
|
104
108
|
**resource
|
105
109
|
)
|
@@ -112,10 +116,10 @@ module StarkInfra
|
|
112
116
|
resource_maker: proc { |json|
|
113
117
|
Log.new(
|
114
118
|
id: json['id'],
|
115
|
-
|
119
|
+
request: StarkInfra::Utils::API.from_api_json(request_maker, json['request']),
|
116
120
|
type: json['type'],
|
117
121
|
errors: json['errors'],
|
118
|
-
|
122
|
+
created: json['created']
|
119
123
|
)
|
120
124
|
}
|
121
125
|
}
|
@@ -1,13 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('../utils/resource')
|
4
3
|
require_relative('../utils/rest')
|
5
|
-
require_relative('../utils/checks')
|
6
4
|
require_relative('../utils/parse')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
require_relative('../utils/resource')
|
7
7
|
|
8
8
|
module StarkInfra
|
9
9
|
# # PixRequest object
|
10
10
|
#
|
11
|
+
# PixRequests are used to receive or send instant payments to accounts
|
12
|
+
# hosted in any Pix participant.
|
13
|
+
#
|
11
14
|
# When you initialize a PixRequest, the entity will not be automatically
|
12
15
|
# created in the Stark Infra API. The 'create' function sends the objects
|
13
16
|
# to the Stark Infra API and returns the list of created objects.
|
@@ -28,16 +31,18 @@ module StarkInfra
|
|
28
31
|
# - receiver_account_type [string]: receiver bank account type. ex: 'checking', 'savings', 'salary' or 'payment'
|
29
32
|
# - end_to_end_id [string]: central bank's unique transaction ID. ex: 'E79457883202101262140HHX553UPqeq'
|
30
33
|
#
|
34
|
+
# ## Parameters (conditionally-required):
|
35
|
+
# - cashier_type [string]: Cashier's type. Required if the cash_amount is different from 0. Options: 'merchant', 'participant' and 'other'
|
36
|
+
# - cashier_bank_code [string]: Cashier's bank code. Required if the cash_amount is different from 0. ex: '20018183'
|
37
|
+
#
|
31
38
|
# ## Parameters (optional):
|
39
|
+
# - cash_amount [integer, default nil]: Amount to be withdrawal from the cashier in cents. ex: 1000 (= R$ 10.00)
|
32
40
|
# - receiver_key_id [string, default nil]: Receiver's dict key. Example: tax id (CPF/CNPJ).
|
33
41
|
# - description [string, default nil]: optional description to override default description to be shown in the bank statement. ex: 'Payment for service #1234'
|
34
42
|
# - reconciliation_id [string, default nil]: Reconciliation ID linked to this payment. ex: 'b77f5236-7ab9-4487-9f95-66ee6eaf1781'
|
35
43
|
# - initiator_tax_id [string, default nil]: Payment initiator's tax id (CPF/CNPJ). ex: '01234567890' or '20.018.183/0001-80'
|
36
|
-
# - cash_amount [integer, default nil]: Amount to be withdrawal from the cashier in cents. ex: 1000 (= R$ 10.00)
|
37
|
-
# - cashier_bank_code [string, default nil]: Cashier's bank code. ex: '00000000'
|
38
|
-
# - cashier_type [string, default nil]: Cashier's type. ex: [merchant, other, participant]
|
39
44
|
# - tags [list of strings, default nil]: list of strings for reference when searching for PixRequests. ex: ['employees', 'monthly']
|
40
|
-
# - method [string, default nil]: execution
|
45
|
+
# - method [string, default nil]: execution method of creation of the Pix. ex: 'manual', 'payerQrcode', 'dynamicQrcode'.
|
41
46
|
#
|
42
47
|
# ## Attributes (return-only):
|
43
48
|
# - id [string]: unique id returned when the PixRequest is created. ex: '5656565656565656'
|
@@ -50,15 +55,15 @@ module StarkInfra
|
|
50
55
|
class PixRequest < StarkInfra::Utils::Resource
|
51
56
|
attr_reader :amount, :external_id, :sender_name, :sender_tax_id, :sender_branch_code, :sender_account_number,
|
52
57
|
:sender_account_type, :receiver_name, :receiver_tax_id, :receiver_bank_code, :receiver_account_number,
|
53
|
-
:receiver_branch_code, :receiver_account_type, :end_to_end_id, :
|
54
|
-
:
|
55
|
-
:
|
58
|
+
:receiver_branch_code, :receiver_account_type, :end_to_end_id, :cashier_type,
|
59
|
+
:cashier_bank_code, :cash_amount, :receiver_key_id, :description, :reconciliation_id, :initiator_tax_id,
|
60
|
+
:tags, :method, :id, :fee, :status, :flow, :sender_bank_code, :created, :updated
|
56
61
|
def initialize(
|
57
62
|
amount:, external_id:, sender_name:, sender_tax_id:, sender_branch_code:, sender_account_number:,
|
58
63
|
sender_account_type:, receiver_name:, receiver_tax_id:, receiver_bank_code:, receiver_account_number:,
|
59
|
-
receiver_branch_code:, receiver_account_type:, end_to_end_id:,
|
60
|
-
|
61
|
-
tags: nil, id: nil, fee: nil, status:nil, flow: nil,
|
64
|
+
receiver_branch_code:, receiver_account_type:, end_to_end_id:, cashier_type: nil, cashier_bank_code: nil,
|
65
|
+
cash_amount: nil, receiver_key_id: nil, description: nil, reconciliation_id: nil, initiator_tax_id: nil,
|
66
|
+
tags: nil, method: nil, id: nil, fee: nil, status:nil, flow: nil, sender_bank_code: nil, created: nil, updated: nil
|
62
67
|
)
|
63
68
|
super(id)
|
64
69
|
@amount = amount
|
@@ -75,13 +80,13 @@ module StarkInfra
|
|
75
80
|
@receiver_branch_code = receiver_branch_code
|
76
81
|
@receiver_account_type = receiver_account_type
|
77
82
|
@end_to_end_id = end_to_end_id
|
83
|
+
@cashier_type = cashier_type
|
84
|
+
@cashier_bank_code = cashier_bank_code
|
85
|
+
@cash_amount = cash_amount
|
78
86
|
@receiver_key_id = receiver_key_id
|
79
87
|
@description = description
|
80
88
|
@reconciliation_id = reconciliation_id
|
81
89
|
@initiator_tax_id = initiator_tax_id
|
82
|
-
@cash_amount = cash_amount
|
83
|
-
@cashier_bank_code = cashier_bank_code
|
84
|
-
@cashier_type = cashier_type
|
85
90
|
@tags = tags
|
86
91
|
@method = method
|
87
92
|
@fee = fee
|
@@ -169,10 +174,10 @@ module StarkInfra
|
|
169
174
|
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
170
175
|
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
171
176
|
# - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
|
172
|
-
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
173
177
|
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
174
178
|
# - end_to_end_ids [list of strings, default nil]: central bank's unique transaction IDs. ex: ['E79457883202101262140HHX553UPqeq', 'E79457883202101262140HHX553UPxzx']
|
175
179
|
# - external_ids [list of strings, default nil]: url safe strings that must be unique among all your PixRequests. Duplicated external IDs will cause failures. By default, this parameter will block any PixRequests that repeats amount and receiver information on the same date. ex: ['my-internal-id-123456', 'my-internal-id-654321']
|
180
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
176
181
|
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
177
182
|
#
|
178
183
|
# ## Return:
|
@@ -212,7 +217,35 @@ module StarkInfra
|
|
212
217
|
# ## Return:
|
213
218
|
# - Parsed PixRequest object
|
214
219
|
def self.parse(content:, signature:, user: nil)
|
215
|
-
StarkInfra::Utils::Parse.parse_and_verify(content: content, signature: signature, user: user, resource: resource)
|
220
|
+
request = StarkInfra::Utils::Parse.parse_and_verify(content: content, signature: signature, user: user, resource: resource)
|
221
|
+
|
222
|
+
!request.fee.nil? ? request.fee : 0
|
223
|
+
!request.tags.nil? ? request.tags : []
|
224
|
+
!request.external_id.nil? ? request.external_id : ''
|
225
|
+
!request.description.nil? ? request.description : ''
|
226
|
+
|
227
|
+
request
|
228
|
+
end
|
229
|
+
|
230
|
+
# Helps you respond to a PixRequest authorization
|
231
|
+
#
|
232
|
+
## Parameters (required):
|
233
|
+
# - status [string]: response to the authorization. ex: 'approved' or 'denied'
|
234
|
+
#
|
235
|
+
## Parameters (conditionally required):
|
236
|
+
# - reason [string, default nil]: denial reason. Options: 'invalidAccountNumber', 'blockedAccount', 'accountClosed', 'invalidAccountType', 'invalidTransactionType', 'taxIdMismatch', 'invalidTaxId', 'orderRejected', 'reversalTimeExpired', 'settlementFailed'
|
237
|
+
#
|
238
|
+
## Return:
|
239
|
+
# - Dumped JSON string that must be returned to us
|
240
|
+
def self.response(status:, reason: nil)
|
241
|
+
response = {
|
242
|
+
authorization: {
|
243
|
+
status: status,
|
244
|
+
reason: reason
|
245
|
+
}
|
246
|
+
}.to_json
|
247
|
+
|
248
|
+
response
|
216
249
|
end
|
217
250
|
|
218
251
|
def self.resource
|
@@ -235,18 +268,18 @@ module StarkInfra
|
|
235
268
|
receiver_branch_code: json['receiver_branch_code'],
|
236
269
|
receiver_account_type: json['receiver_account_type'],
|
237
270
|
end_to_end_id: json['end_to_end_id'],
|
271
|
+
cashier_type: json['cashier_type'],
|
272
|
+
cashier_bank_code: json['cashier_bank_code'],
|
273
|
+
cash_amount: json['cash_amount'],
|
238
274
|
receiver_key_id: json['receiver_key_id'],
|
239
275
|
description: json['description'],
|
240
276
|
reconciliation_id: json['reconciliation_id'],
|
241
277
|
initiator_tax_id: json['initiator_tax_id'],
|
242
|
-
cash_amount: json['cash_amount'],
|
243
|
-
cashier_bank_code: json['cashier_bank_code'],
|
244
|
-
cashier_type: json['cashier_type'],
|
245
278
|
tags: json['tags'],
|
279
|
+
method: json['method'],
|
246
280
|
fee: json['fee'],
|
247
281
|
status: json['status'],
|
248
282
|
flow: json['flow'],
|
249
|
-
method: json['method'],
|
250
283
|
sender_bank_code: json['sender_bank_code'],
|
251
284
|
created: json['created'],
|
252
285
|
updated: json['updated']
|
data/lib/pixreversal/log.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative('
|
3
|
+
require_relative('pixreversal')
|
4
4
|
require_relative('../utils/rest')
|
5
5
|
require_relative('../utils/checks')
|
6
|
-
require_relative('
|
6
|
+
require_relative('../utils/resource')
|
7
7
|
|
8
8
|
module StarkInfra
|
9
9
|
class PixReversal
|
@@ -13,7 +13,7 @@ module StarkInfra
|
|
13
13
|
# is generated for the entity. This log is never generated by the
|
14
14
|
# user.
|
15
15
|
#
|
16
|
-
# ## Attributes:
|
16
|
+
# ## Attributes (return-only):
|
17
17
|
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
18
18
|
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
19
19
|
# - type [string]: type of the PixReversal event which triggered the log creation. ex: 'processing' or 'success'
|