starkinfra 0.0.1 → 0.1.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/creditnote/creditnote.rb +583 -0
- data/lib/creditnote/log.rb +126 -0
- data/lib/event/attempt.rb +126 -0
- data/lib/event/event.rb +125 -7
- data/lib/issuingauthorization/issuingauthorization.rb +141 -0
- data/lib/issuingbalance/issuingbalance.rb +55 -0
- data/lib/issuingbin/issuingbin.rb +89 -0
- data/lib/issuingcard/issuingcard.rb +261 -0
- data/lib/issuingcard/log.rb +123 -0
- data/lib/issuingholder/issuingholder.rb +206 -0
- data/lib/issuingholder/log.rb +123 -0
- data/lib/issuinginvoice/issuinginvoice.rb +152 -0
- data/lib/issuinginvoice/log.rb +120 -0
- data/lib/issuingpurchase/issuingpurchase.rb +209 -0
- data/lib/issuingpurchase/log.rb +131 -0
- data/lib/issuingrule/issuingrule.rb +79 -0
- data/lib/issuingtransaction/issuingtransaction.rb +136 -0
- data/lib/issuingwithdrawal/issuingwithdrawal.rb +153 -0
- data/lib/pixbalance/pixbalance.rb +15 -15
- data/lib/pixchargeback/log.rb +129 -0
- data/lib/pixchargeback/pixchargeback.rb +225 -0
- data/lib/pixclaim/log.rb +135 -0
- data/lib/pixclaim/pixclaim.rb +226 -0
- data/lib/pixdirector/pixdirector.rb +76 -0
- data/lib/pixdomain/certificate.rb +30 -0
- data/lib/pixdomain/pixdomain.rb +58 -0
- data/lib/pixinfraction/log.rb +129 -0
- data/lib/pixinfraction/pixinfraction.rb +212 -0
- data/lib/pixkey/log.rb +128 -0
- data/lib/pixkey/pixkey.rb +240 -0
- data/lib/pixrequest/log.rb +16 -16
- data/lib/pixrequest/pixrequest.rb +66 -67
- data/lib/pixreversal/log.rb +13 -12
- data/lib/pixreversal/pixreversal.rb +74 -72
- data/lib/pixstatement/pixstatement.rb +24 -25
- data/lib/starkinfra.rb +32 -3
- data/lib/user/organization.rb +54 -0
- data/lib/user/project.rb +37 -0
- data/lib/user/user.rb +20 -0
- data/lib/utils/api.rb +10 -2
- data/lib/utils/bacenid.rb +19 -0
- data/lib/utils/checks.rb +2 -3
- data/lib/utils/endtoendid.rb +11 -0
- data/lib/utils/parse.rb +13 -13
- data/lib/utils/request.rb +2 -2
- data/lib/utils/rest.rb +6 -5
- data/lib/utils/returnid.rb +11 -0
- data/lib/webhook/webhook.rb +124 -0
- metadata +45 -24
@@ -0,0 +1,212 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
|
7
|
+
module StarkInfra
|
8
|
+
# # PixInfraction object
|
9
|
+
#
|
10
|
+
# PixInfractions are used to report transactions that are suspected of
|
11
|
+
# fraud, to request a refund or to reverse a refund.
|
12
|
+
# When you initialize a PixInfraction, the entity will not be automatically
|
13
|
+
# created in the Stark Infra API. The 'create' function sends the objects
|
14
|
+
# to the Stark Infra API and returns the created object.
|
15
|
+
#
|
16
|
+
# ## Parameters (required):
|
17
|
+
# - reference_id [string]: end_to_end_id or return_id of the transaction being reported. ex: 'E20018183202201201450u34sDGd19lz'
|
18
|
+
# - type [string]: type of infraction report. Options: 'fraud', 'reversal', 'reversalChargeback'
|
19
|
+
#
|
20
|
+
# ## Parameters (optional):
|
21
|
+
# - description [string, default nil]: description for any details that can help with the infraction investigation.
|
22
|
+
#
|
23
|
+
# ## Attributes (return-only):
|
24
|
+
# - id [string]: unique id returned when the PixInfraction is created. ex: '5656565656565656'
|
25
|
+
# - credited_bank_code [string]: bank_code of the credited Pix participant in the reported transaction. ex: '20018183'
|
26
|
+
# - debited_bank_code [string]: bank_code of the debited Pix participant in the reported transaction. ex: '20018183'
|
27
|
+
# - agent [string]: Options: 'reporter' if you created the PixInfraction, 'reported' if you received the PixInfraction.
|
28
|
+
# - analysis [string]: analysis that led to the result.
|
29
|
+
# - bacen_id [string]: central bank's unique UUID that identifies the infraction report.
|
30
|
+
# - reported_by [string]: agent that reported the PixInfraction. Options: 'debited', 'credited'.
|
31
|
+
# - result [string]: result after the analysis of the PixInfraction by the receiving party. Options: 'agreed', 'disagreed'
|
32
|
+
# - status [string]: current PixInfraction status. Options: 'created', 'failed', 'delivered', 'closed', 'canceled'.
|
33
|
+
# - created [DateTime]: creation datetime for the PixInfraction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
34
|
+
# - updated [DateTime]: latest update datetime for the PixInfraction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
35
|
+
class PixInfraction < StarkInfra::Utils::Resource
|
36
|
+
attr_reader :reference_id, :type, :description, :id, :credited_bank_code, :agent, :analysis, :bacen_id,
|
37
|
+
:debited_bank_code, :reported_by, :result, :status, :created, :updated
|
38
|
+
def initialize(
|
39
|
+
reference_id:, type:, description:, id: nil, credited_bank_code: nil, agent: nil, analysis: nil, bacen_id: nil,
|
40
|
+
debited_bank_code: nil, reported_by: nil, result: nil, status: nil, created: nil, updated: nil
|
41
|
+
)
|
42
|
+
super(id)
|
43
|
+
@reference_id = reference_id
|
44
|
+
@type = type
|
45
|
+
@description = description
|
46
|
+
@credited_bank_code = credited_bank_code
|
47
|
+
@agent = agent
|
48
|
+
@analysis = analysis
|
49
|
+
@bacen_id = bacen_id
|
50
|
+
@debited_bank_code = debited_bank_code
|
51
|
+
@reported_by = reported_by
|
52
|
+
@result = result
|
53
|
+
@status = status
|
54
|
+
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
55
|
+
@updated = StarkInfra::Utils::Checks.check_datetime(updated)
|
56
|
+
end
|
57
|
+
|
58
|
+
# # Create PixInfractions
|
59
|
+
#
|
60
|
+
# Send a list of PixInfraction objects for creation in the Stark Infra API
|
61
|
+
#
|
62
|
+
# ## Parameters (required):
|
63
|
+
# - infractions [list of PixInfraction objects]: list of PixInfraction objects to be created in the API. ex: [PixInfraction.new()]
|
64
|
+
#
|
65
|
+
# ## Parameters (optional):
|
66
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
67
|
+
#
|
68
|
+
# ## Return:
|
69
|
+
# - list of PixInfraction objects with updated attributes
|
70
|
+
def self.create(infractions, user: nil)
|
71
|
+
StarkInfra::Utils::Rest.post(entities: infractions, user: user, **resource)
|
72
|
+
end
|
73
|
+
|
74
|
+
# # Retrieve a specific PixInfraction
|
75
|
+
#
|
76
|
+
# Receive a single PixInfraction object previously created in the Stark Infra API by passing its id
|
77
|
+
#
|
78
|
+
# ## Parameters (required):
|
79
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
80
|
+
#
|
81
|
+
# ## Parameters (optional):
|
82
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
83
|
+
#
|
84
|
+
# ## Return:
|
85
|
+
# - PixInfraction object with updated attributes
|
86
|
+
def self.get(id, user: nil)
|
87
|
+
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
88
|
+
end
|
89
|
+
|
90
|
+
# # Retrieve PixInfractions
|
91
|
+
#
|
92
|
+
# Receive a generator of PixInfraction objects previously created in the Stark Infra API
|
93
|
+
#
|
94
|
+
# ## Parameters (optional):
|
95
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
96
|
+
# - after [Date or string, default nil]: date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
|
97
|
+
# - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
|
98
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
|
99
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
100
|
+
# - type [string]: filter for the type of retrieved PixInfractions. Options: 'fraud', 'reversal', 'reversalChargeback'
|
101
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
102
|
+
#
|
103
|
+
# ## Return:
|
104
|
+
# - generator of PixInfraction objects with updated attributes
|
105
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, ids: nil, type: nil, user: nil)
|
106
|
+
after = StarkInfra::Utils::Checks.check_date(after)
|
107
|
+
before = StarkInfra::Utils::Checks.check_date(before)
|
108
|
+
StarkInfra::Utils::Rest.get_stream(
|
109
|
+
limit: limit,
|
110
|
+
after: after,
|
111
|
+
before: before,
|
112
|
+
status: status,
|
113
|
+
ids: ids,
|
114
|
+
type: type,
|
115
|
+
user: user,
|
116
|
+
**resource
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
# # Retrieve paged PixInfractions
|
121
|
+
#
|
122
|
+
# Receive a list of up to 100 PixInfraction objects previously created in the Stark infra API and the cursor to the next page.
|
123
|
+
# Use this function instead of query if you want to manually page your infractions.
|
124
|
+
#
|
125
|
+
# ## Parameters (optional):
|
126
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
127
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
128
|
+
# - after [Date or string, default nil]: date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
|
129
|
+
# - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
|
130
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
|
131
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
132
|
+
# - type [string, default nil]: filter for the type of retrieved PixInfractions. Options: 'fraud', 'reversal', 'reversalChargeback'
|
133
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
134
|
+
#
|
135
|
+
# ## Return:
|
136
|
+
# - list of PixInfraction objects with updated attributes
|
137
|
+
# - cursor to retrieve the next page of PixInfraction objects
|
138
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil, type: nil, user: nil)
|
139
|
+
after = StarkInfra::Utils::Checks.check_date(after)
|
140
|
+
before = StarkInfra::Utils::Checks.check_date(before)
|
141
|
+
StarkInfra::Utils::Rest.get_page(
|
142
|
+
cursor: cursor,
|
143
|
+
limit: limit,
|
144
|
+
after: after,
|
145
|
+
before: before,
|
146
|
+
status: status,
|
147
|
+
ids: ids,
|
148
|
+
type: type,
|
149
|
+
user: user,
|
150
|
+
**resource
|
151
|
+
)
|
152
|
+
end
|
153
|
+
|
154
|
+
# # Update a PixInfraction entity
|
155
|
+
#
|
156
|
+
# Respond to a received PixInfraction.
|
157
|
+
#
|
158
|
+
# ## Parameters (required):
|
159
|
+
# - id [string]: PixInfraction unique id. ex: '5656565656565656'
|
160
|
+
# - result [string]: result after the analysis of the PixInfraction. Options: 'agreed', 'disagreed'
|
161
|
+
#
|
162
|
+
# ## Parameters (optional):
|
163
|
+
# - analysis [string, nil]: analysis that led to the result.
|
164
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
165
|
+
#
|
166
|
+
# ## Return:
|
167
|
+
# - updated PixInfraction object
|
168
|
+
def self.update(id, result:, analysis: nil, user: nil)
|
169
|
+
StarkInfra::Utils::Rest.patch_id(id: id, result: result, analysis: analysis, user: user, **resource)
|
170
|
+
end
|
171
|
+
|
172
|
+
# # Cancel a PixInfraction entity
|
173
|
+
#
|
174
|
+
# Cancel a PixInfraction entity previously created in the Stark Infra API
|
175
|
+
#
|
176
|
+
# ## Parameters (required):
|
177
|
+
# - id [string]: PixInfraction unique id. ex: '5656565656565656'
|
178
|
+
#
|
179
|
+
# ## Parameters (optional):
|
180
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
181
|
+
#
|
182
|
+
# ## Return:
|
183
|
+
# - canceled PixInfraction object
|
184
|
+
def self.cancel(id, user: nil)
|
185
|
+
StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
|
186
|
+
end
|
187
|
+
|
188
|
+
def self.resource
|
189
|
+
{
|
190
|
+
resource_name: 'PixInfraction',
|
191
|
+
resource_maker: proc { |json|
|
192
|
+
PixInfraction.new(
|
193
|
+
id: json['id'],
|
194
|
+
reference_id: json['reference_id'],
|
195
|
+
type: json['type'],
|
196
|
+
description: json['description'],
|
197
|
+
credited_bank_code: json['credited_bank_code'],
|
198
|
+
agent: json['agent'],
|
199
|
+
analysis: json['analysis'],
|
200
|
+
bacen_id: json['bacen_id'],
|
201
|
+
debited_bank_code: json['debited_bank_code'],
|
202
|
+
reported_by: json['reported_by'],
|
203
|
+
result: json['result'],
|
204
|
+
status: json['status'],
|
205
|
+
created: json['created'],
|
206
|
+
updated: json['updated']
|
207
|
+
)
|
208
|
+
}
|
209
|
+
}
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
data/lib/pixkey/log.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
require_relative('pixkey')
|
7
|
+
|
8
|
+
module StarkInfra
|
9
|
+
class PixKey
|
10
|
+
# # PixKey::Log object
|
11
|
+
#
|
12
|
+
# Every time a PixKey entity is modified, a corresponding PixKey::Log is generated for the entity.
|
13
|
+
# This log is never generated by the user.
|
14
|
+
#
|
15
|
+
# ## Attributes:
|
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 PixKey event which triggered the log creation. Options: 'created', 'registered', 'updated', 'failed', 'canceling', 'canceled'.
|
19
|
+
# - errors [list of strings]: list of errors linked to this PixKey event.
|
20
|
+
# - key [PixKey]: PixKey entity to which the log refers to.
|
21
|
+
class Log < StarkInfra::Utils::Resource
|
22
|
+
attr_reader :id, :created, :type, :errors, :key
|
23
|
+
def initialize(id:, created:, type:, errors:, key:)
|
24
|
+
super(id)
|
25
|
+
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
26
|
+
@type = type
|
27
|
+
@errors = errors
|
28
|
+
@key = key
|
29
|
+
end
|
30
|
+
|
31
|
+
# # Retrieve a specific Log
|
32
|
+
#
|
33
|
+
# Receive a single Log object previously created by the Stark Infra API by passing its id
|
34
|
+
#
|
35
|
+
# ## Parameters (required):
|
36
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
37
|
+
#
|
38
|
+
# ## Parameters (optional):
|
39
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
40
|
+
#
|
41
|
+
# ## Return:
|
42
|
+
# - Log object with updated attributes
|
43
|
+
def self.get(id, user: nil)
|
44
|
+
StarkInfra::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 Infra API
|
50
|
+
#
|
51
|
+
# ## Parameters (optional):
|
52
|
+
# - ids [list of strings, default nil]: Log ids to filter PixKey Logs. ex: ['5656565656565656']
|
53
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
54
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
55
|
+
# - before [Date 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 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: %w[5656565656565656 4545454545454545]
|
58
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
59
|
+
#
|
60
|
+
# ## Return:
|
61
|
+
# - generator of Log objects with updated attributes
|
62
|
+
def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, key_ids: nil, user: nil)
|
63
|
+
after = StarkInfra::Utils::Checks.check_date(after)
|
64
|
+
before = StarkInfra::Utils::Checks.check_date(before)
|
65
|
+
StarkInfra::Utils::Rest.get_stream(
|
66
|
+
ids: ids,
|
67
|
+
limit: limit,
|
68
|
+
after: after,
|
69
|
+
before: before,
|
70
|
+
types: types,
|
71
|
+
key_ids: key_ids,
|
72
|
+
user: user,
|
73
|
+
**resource
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
# # Retrieve paged Logs
|
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.
|
80
|
+
# Use this function instead of query if you want to manually page your keys.
|
81
|
+
#
|
82
|
+
# ## Parameters (optional):
|
83
|
+
# - ids [list of strings, default nil]: Log ids to filter PixKey Logs. ex: ['5656565656565656']
|
84
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
85
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
86
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
87
|
+
# - 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: %w[5656565656565656 4545454545454545]
|
90
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
91
|
+
#
|
92
|
+
# ## Return:
|
93
|
+
# - list of Log objects with updated attributes
|
94
|
+
# - cursor to retrieve the next page of Log objects
|
95
|
+
def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, key_ids: nil, user: nil)
|
96
|
+
after = StarkInfra::Utils::Checks.check_date(after)
|
97
|
+
before = StarkInfra::Utils::Checks.check_date(before)
|
98
|
+
StarkInfra::Utils::Rest.get_page(
|
99
|
+
cursor: cursor,
|
100
|
+
ids: ids,
|
101
|
+
limit: limit,
|
102
|
+
after: after,
|
103
|
+
before: before,
|
104
|
+
types: types,
|
105
|
+
key_ids: key_ids,
|
106
|
+
user: user,
|
107
|
+
**resource
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.resource
|
112
|
+
key_maker = StarkInfra::PixKey.resource[:resource_maker]
|
113
|
+
{
|
114
|
+
resource_name: 'PixKeyLog',
|
115
|
+
resource_maker: proc { |json|
|
116
|
+
Log.new(
|
117
|
+
id: json['id'],
|
118
|
+
created: json['created'],
|
119
|
+
type: json['type'],
|
120
|
+
errors: json['errors'],
|
121
|
+
key: StarkInfra::Utils::API.from_api_json(key_maker, json['key'])
|
122
|
+
)
|
123
|
+
}
|
124
|
+
}
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,240 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
|
7
|
+
module StarkInfra
|
8
|
+
# # PixKey object
|
9
|
+
# PixKeys link bank account information to key ids.
|
10
|
+
# Key ids are a convenient way to search and pass bank account information.
|
11
|
+
# When you initialize a Pix Key, the entity will not be automatically
|
12
|
+
# created in the Stark Infra API. The 'create' function sends the objects
|
13
|
+
# to the Stark Infra API and returns the created object.
|
14
|
+
#
|
15
|
+
# ## Parameters (required):
|
16
|
+
# - account_created [DateTime, Date or string]: opening Date or DateTime for the linked account. ex: '2022-01-01T12:00:00:00'.
|
17
|
+
# - account_number [string]: number of the linked account. ex: '76543'.
|
18
|
+
# - account_type [string]: type of the linked account. Options: 'checking', 'savings', 'salary' or 'payment'.
|
19
|
+
# - branch_code [string]: branch code of the linked account. ex: '1234'.
|
20
|
+
# - name [string]: holder's name of the linked account. ex: 'Jamie Lannister'.
|
21
|
+
# - tax_id [string]: holder's taxId (CPF/CNPJ) of the linked account. ex: '012.345.678-90'.
|
22
|
+
#
|
23
|
+
# ## Parameters (optional):
|
24
|
+
# - id [string, default nil]: id of the registered PixKey. Allowed types are: CPF, CNPJ, phone number or email. If this parameter is not passed, an EVP will be created. ex: '+5511989898989'
|
25
|
+
# - tags [list of strings, default nil]: list of strings for reference when searching for PixKeys. ex: ['employees', 'monthly']
|
26
|
+
#
|
27
|
+
# ## Attributes (return-only):
|
28
|
+
# - owned [DateTime]: datetime when the key was owned by the holder. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
29
|
+
# - owner_type [string]: type of the owner of the PixKey. Options: 'business' or 'individual'.
|
30
|
+
# - status [string]: current PixKey status. Options: 'created', 'registered', 'canceled', 'failed'
|
31
|
+
# - bank_code [string]: bank_code of the account linked to the Pix Key. ex: '20018183'.
|
32
|
+
# - bank_name [string]: name of the bank that holds the account linked to the PixKey. ex: 'StarkBank'
|
33
|
+
# - type [string]: type of the PixKey. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp',
|
34
|
+
# - created [DateTime]: creation datetime for the PixKey. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
35
|
+
class PixKey < StarkInfra::Utils::Resource
|
36
|
+
attr_reader :account_created, :account_number, :account_type, :branch_code, :name, :tax_id, :id,
|
37
|
+
:tags, :owned, :owner_type, :status, :bank_code, :bank_name, :type, :created
|
38
|
+
def initialize(
|
39
|
+
account_created:, account_number:, account_type:, branch_code:, name:, tax_id:, id: nil, tags: nil, owned: nil,
|
40
|
+
owner_type: nil, status: nil, bank_code: nil, bank_name: nil, type: nil, created: nil
|
41
|
+
)
|
42
|
+
super(id)
|
43
|
+
@account_created = account_created
|
44
|
+
@account_number = account_number
|
45
|
+
@account_type = account_type
|
46
|
+
@branch_code = branch_code
|
47
|
+
@name = name
|
48
|
+
@tax_id = tax_id
|
49
|
+
@tags = tags
|
50
|
+
@owned = StarkInfra::Utils::Checks.check_datetime(owned)
|
51
|
+
@owner_type = owner_type
|
52
|
+
@status = status
|
53
|
+
@bank_code = bank_code
|
54
|
+
@bank_name = bank_name
|
55
|
+
@type = type
|
56
|
+
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
57
|
+
end
|
58
|
+
|
59
|
+
# # Create a PixKey
|
60
|
+
#
|
61
|
+
# Send a PixKey objects for creation in the Stark Infra API
|
62
|
+
#
|
63
|
+
# ## Parameters (required):
|
64
|
+
# - key [PixKey object]: PixKey object to be created in the API
|
65
|
+
#
|
66
|
+
# ## Parameters (optional):
|
67
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
68
|
+
#
|
69
|
+
# ## Return:
|
70
|
+
# - PixKey object with updated attributes
|
71
|
+
def self.create(key, user: nil)
|
72
|
+
StarkInfra::Utils::Rest.post_single(entity: key, user: user, **resource)
|
73
|
+
end
|
74
|
+
|
75
|
+
# # Retrieve a specific PixKey
|
76
|
+
#
|
77
|
+
# Receive a single PixKey object previously created in the Stark Infra API by passing its id
|
78
|
+
#
|
79
|
+
# ## Parameters (required):
|
80
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
81
|
+
# - 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
|
+
#
|
83
|
+
# ## Parameters (optional):
|
84
|
+
# - end_to_end_id [string, default nil]: central bank's unique transaction id. If the request results in the creation of a PixRequest, the same end_to_end_id should be used. If this parameter is not passed, one end_to_end_id will be automatically created. Example: 'E00002649202201172211u34srod19le'
|
85
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
86
|
+
#
|
87
|
+
# ## Return:
|
88
|
+
# - PixKey object with updated attributes
|
89
|
+
def self.get(id, payer_id:, end_to_end_id: nil, user: nil)
|
90
|
+
StarkInfra::Utils::Rest.get_id(
|
91
|
+
id: id,
|
92
|
+
payer_id: payer_id,
|
93
|
+
end_to_end_id: end_to_end_id,
|
94
|
+
user: user,
|
95
|
+
**resource
|
96
|
+
)
|
97
|
+
end
|
98
|
+
|
99
|
+
# # Retrieve PixKeys
|
100
|
+
#
|
101
|
+
# Receive a generator of PixKey objects previously created in the Stark Infra API
|
102
|
+
#
|
103
|
+
# ## Parameters (optional):
|
104
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
105
|
+
# - after [Date or string, default nil]: date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
|
106
|
+
# - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
|
107
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
|
108
|
+
# - 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: ['5656565656565656', '4545454545454545']
|
110
|
+
# - type [string, default nil]: filter for the type of retrieved PixKeys. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp'
|
111
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
112
|
+
#
|
113
|
+
# ## Return:
|
114
|
+
# - generator of PixKey objects with updated attributes
|
115
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, type: nil, user: nil)
|
116
|
+
after = StarkInfra::Utils::Checks.check_date(after)
|
117
|
+
before = StarkInfra::Utils::Checks.check_date(before)
|
118
|
+
StarkInfra::Utils::Rest.get_stream(
|
119
|
+
limit: limit,
|
120
|
+
after: after,
|
121
|
+
before: before,
|
122
|
+
status: status,
|
123
|
+
tags: tags,
|
124
|
+
ids: ids,
|
125
|
+
type: type,
|
126
|
+
user: user,
|
127
|
+
**resource
|
128
|
+
)
|
129
|
+
end
|
130
|
+
|
131
|
+
# # Retrieve paged PixKeys
|
132
|
+
#
|
133
|
+
# Receive a list of up to 100 PixKey objects previously created in the Stark infra API and the cursor to the next page.
|
134
|
+
# Use this function instead of query if you want to manually page your keys.
|
135
|
+
#
|
136
|
+
# ## Parameters (optional):
|
137
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
138
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
139
|
+
# - after [Date or string, default nil]: date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
|
140
|
+
# - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
|
141
|
+
# - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
|
142
|
+
# - 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: ['5656565656565656', '4545454545454545']
|
144
|
+
# - type [string, default nil]: filter for the type of retrieved PixKeys. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp'
|
145
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
146
|
+
#
|
147
|
+
# ## Return:
|
148
|
+
# - list of PixKey objects with updated attributes
|
149
|
+
# - cursor to retrieve the next page of PixKey objects
|
150
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, type: nil, user: nil)
|
151
|
+
after = StarkInfra::Utils::Checks.check_date(after)
|
152
|
+
before = StarkInfra::Utils::Checks.check_date(before)
|
153
|
+
StarkInfra::Utils::Rest.get_page(
|
154
|
+
cursor: cursor,
|
155
|
+
limit: limit,
|
156
|
+
after: after,
|
157
|
+
before: before,
|
158
|
+
status: status,
|
159
|
+
tags: tags,
|
160
|
+
ids: ids,
|
161
|
+
type: type,
|
162
|
+
user: user,
|
163
|
+
**resource
|
164
|
+
)
|
165
|
+
end
|
166
|
+
|
167
|
+
# # Update a PixKey entity
|
168
|
+
#
|
169
|
+
# Respond to a received PixKey.
|
170
|
+
#
|
171
|
+
# ## Parameters (required):
|
172
|
+
# - id [string]: PixKey unique id. ex: '5656565656565656'
|
173
|
+
# - reason [string]: reason why the PixKey is being patched. Options: 'branchTransfer', 'reconciliation' or 'userRequested'.
|
174
|
+
#
|
175
|
+
# ## 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.
|
177
|
+
# - account_number [string, default nil]: number of the account to be linked. ex: '76543'.
|
178
|
+
# - account_type [string, default nil]: type of the account to be linked. Options: 'checking', 'savings', 'salary' or 'payment'.
|
179
|
+
# - branch_code [string, default nil]: branch code of the account to be linked. ex: 1234'.
|
180
|
+
# - name [string, default nil]: holder's name of the account to be linked. ex: 'Jamie Lannister'.
|
181
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
182
|
+
#
|
183
|
+
# ## Return:
|
184
|
+
# - updated PixKey object
|
185
|
+
def self.update(id, reason:, account_created: nil, account_number: nil, account_type: nil, branch_code: nil, name: nil, user: nil)
|
186
|
+
StarkInfra::Utils::Rest.patch_id(
|
187
|
+
id: id,
|
188
|
+
reason: reason,
|
189
|
+
account_created: account_created,
|
190
|
+
account_number: account_number,
|
191
|
+
account_type: account_type,
|
192
|
+
branch_code: branch_code,
|
193
|
+
name: name,
|
194
|
+
user: user,
|
195
|
+
**resource
|
196
|
+
)
|
197
|
+
end
|
198
|
+
|
199
|
+
# # Cancel a PixKey entity
|
200
|
+
#
|
201
|
+
# Cancel a PixKey entity previously created in the Stark Infra API
|
202
|
+
#
|
203
|
+
# ## Parameters (required):
|
204
|
+
# - id [string]: PixKey unique id. ex: '5656565656565656'
|
205
|
+
#
|
206
|
+
# ## Parameters (optional):
|
207
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
208
|
+
#
|
209
|
+
# ## Return:
|
210
|
+
# - canceled PixKey object
|
211
|
+
def self.cancel(id, user: nil)
|
212
|
+
StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
|
213
|
+
end
|
214
|
+
|
215
|
+
def self.resource
|
216
|
+
{
|
217
|
+
resource_name: 'PixKey',
|
218
|
+
resource_maker: proc { |json|
|
219
|
+
PixKey.new(
|
220
|
+
account_created: json['account_created'],
|
221
|
+
account_number: json['account_number'],
|
222
|
+
account_type: json['account_type'],
|
223
|
+
branch_code: json['branch_code'],
|
224
|
+
name: json['name'],
|
225
|
+
tax_id: json['tax_id'],
|
226
|
+
id: json['id'],
|
227
|
+
tags: json['tags'],
|
228
|
+
owned: json['owned'],
|
229
|
+
owner_type: json['owner_type'],
|
230
|
+
status: json['status'],
|
231
|
+
bank_code: json['bank_code'],
|
232
|
+
bank_name: json['bank_name'],
|
233
|
+
type: json['type'],
|
234
|
+
created: json['created']
|
235
|
+
)
|
236
|
+
}
|
237
|
+
}
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
data/lib/pixrequest/log.rb
CHANGED
@@ -9,16 +9,15 @@ module StarkInfra
|
|
9
9
|
class PixRequest
|
10
10
|
# # PixRequest::Log object
|
11
11
|
#
|
12
|
-
# Every time a PixRequest entity is modified, a corresponding PixRequest::Log
|
13
|
-
#
|
14
|
-
# user.
|
12
|
+
# Every time a PixRequest entity is modified, a corresponding PixRequest::Log is generated for the entity.
|
13
|
+
# This log is never generated by the user.
|
15
14
|
#
|
16
15
|
# ## Attributes:
|
17
16
|
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
18
17
|
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
19
18
|
# - type [string]: type of the PixRequest event which triggered the log creation. ex: 'processing' or 'success'
|
20
19
|
# - errors [list of strings]: list of errors linked to this PixRequest event.
|
21
|
-
# - request [PixRequest]: PixRequest entity to which the log refers to.
|
20
|
+
# - request [PixRequest object]: PixRequest entity to which the log refers to.
|
22
21
|
class Log < StarkInfra::Utils::Resource
|
23
22
|
attr_reader :id, :created, :type, :errors, :request
|
24
23
|
def initialize(id:, created:, type:, errors:, request:)
|
@@ -37,7 +36,7 @@ module StarkInfra
|
|
37
36
|
# - id [string]: object unique id. ex: '5656565656565656'
|
38
37
|
#
|
39
38
|
# ## Parameters (optional):
|
40
|
-
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
39
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
41
40
|
#
|
42
41
|
# ## Return:
|
43
42
|
# - Log object with updated attributes
|
@@ -50,15 +49,16 @@ module StarkInfra
|
|
50
49
|
# Receive a generator of Log objects previously created in the Stark Infra API
|
51
50
|
#
|
52
51
|
# ## Parameters (optional):
|
52
|
+
# - ids [list of strings, default nil]: Log ids to filter PixKey Logs. ex: ['5656565656565656']
|
53
53
|
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
54
|
-
# - after [Date
|
55
|
-
# - before [Date
|
54
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
55
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
56
56
|
# - types [list of strings, default nil]: filter retrieved objects by types. ex: 'success' or 'failed'
|
57
57
|
# - request_ids [list of strings, default nil]: list of PixRequest ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
58
|
-
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
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
|
-
# -
|
61
|
+
# - generator of Log objects with updated attributes
|
62
62
|
def self.query(limit: nil, after: nil, before: nil, types: nil, request_ids: nil, user: nil)
|
63
63
|
after = StarkInfra::Utils::Checks.check_date(after)
|
64
64
|
before = StarkInfra::Utils::Checks.check_date(before)
|
@@ -76,24 +76,24 @@ module StarkInfra
|
|
76
76
|
# # Retrieve paged Logs
|
77
77
|
#
|
78
78
|
# Receive a list of up to 100 Log objects previously created in the Stark Infra API and the cursor to the next page.
|
79
|
-
# Use this function instead of query if you want to manually page your
|
79
|
+
# Use this function instead of query if you want to manually page your logs.
|
80
80
|
#
|
81
81
|
# ## Parameters (optional):
|
82
82
|
# - cursor [string, default nil]: cursor returned on the previous page function call
|
83
|
-
# - limit [integer, default
|
84
|
-
# - after [Date
|
85
|
-
# - before [Date
|
83
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
84
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
85
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
86
86
|
# - types [list of strings, default nil]: filter retrieved objects by types. ex: 'success' or 'failed'
|
87
87
|
# - request_ids [list of strings, default nil]: list of PixRequest ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
88
|
-
# - user [Organization/Project object]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
88
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
89
89
|
#
|
90
90
|
# ## Return:
|
91
91
|
# - list of Log objects with updated attributes
|
92
|
-
# -
|
92
|
+
# - cursor to retrieve the next page of Log objects
|
93
93
|
def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, request_ids: nil, user: nil)
|
94
94
|
after = StarkInfra::Utils::Checks.check_date(after)
|
95
95
|
before = StarkInfra::Utils::Checks.check_date(before)
|
96
|
-
|
96
|
+
StarkInfra::Utils::Rest.get_page(
|
97
97
|
cursor: cursor,
|
98
98
|
limit: limit,
|
99
99
|
after: after,
|