starkinfra 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/creditnote/creditnote.rb +561 -0
  3. data/lib/creditnote/log.rb +126 -0
  4. data/lib/event/attempt.rb +126 -0
  5. data/lib/event/event.rb +125 -7
  6. data/lib/issuingauthorization/issuingauthorization.rb +141 -0
  7. data/lib/issuingbalance/issuingbalance.rb +55 -0
  8. data/lib/issuingbin/issuingbin.rb +89 -0
  9. data/lib/issuingcard/issuingcard.rb +260 -0
  10. data/lib/issuingcard/log.rb +123 -0
  11. data/lib/issuingholder/issuingholder.rb +206 -0
  12. data/lib/issuingholder/log.rb +123 -0
  13. data/lib/issuinginvoice/issuinginvoice.rb +152 -0
  14. data/lib/issuinginvoice/log.rb +120 -0
  15. data/lib/issuingpurchase/issuingpurchase.rb +209 -0
  16. data/lib/issuingpurchase/log.rb +131 -0
  17. data/lib/issuingrule/issuingrule.rb +81 -0
  18. data/lib/issuingtransaction/issuingtransaction.rb +136 -0
  19. data/lib/issuingwithdrawal/issuingwithdrawal.rb +153 -0
  20. data/lib/pixbalance/pixbalance.rb +13 -13
  21. data/lib/pixchargeback/log.rb +129 -0
  22. data/lib/pixchargeback/pixchargeback.rb +225 -0
  23. data/lib/pixclaim/log.rb +135 -0
  24. data/lib/pixclaim/pixclaim.rb +225 -0
  25. data/lib/pixdirector/pixdirector.rb +76 -0
  26. data/lib/pixdomain/certificate.rb +30 -0
  27. data/lib/pixdomain/pixdomain.rb +58 -0
  28. data/lib/pixinfraction/log.rb +129 -0
  29. data/lib/pixinfraction/pixinfraction.rb +212 -0
  30. data/lib/pixkey/log.rb +128 -0
  31. data/lib/pixkey/pixkey.rb +239 -0
  32. data/lib/pixrequest/log.rb +16 -16
  33. data/lib/pixrequest/pixrequest.rb +66 -67
  34. data/lib/pixreversal/log.rb +13 -12
  35. data/lib/pixreversal/pixreversal.rb +72 -71
  36. data/lib/pixstatement/pixstatement.rb +22 -23
  37. data/lib/starkinfra.rb +32 -2
  38. data/lib/user/organization.rb +54 -0
  39. data/lib/user/project.rb +37 -0
  40. data/lib/user/user.rb +20 -0
  41. data/lib/utils/api.rb +10 -2
  42. data/lib/utils/bacenid.rb +19 -0
  43. data/lib/utils/checks.rb +2 -3
  44. data/lib/utils/endtoendid.rb +11 -0
  45. data/lib/utils/parse.rb +13 -13
  46. data/lib/utils/request.rb +1 -1
  47. data/lib/utils/rest.rb +7 -5
  48. data/lib/utils/returnid.rb +11 -0
  49. data/lib/webhook/webhook.rb +124 -0
  50. metadata +45 -24
@@ -0,0 +1,239 @@
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, :tags, :owned, :owner_type, :status, :bank_code, :bank_name, :type, :created
37
+ def initialize(
38
+ account_created:, account_number:, account_type:, branch_code:, name:, tax_id:, id: nil, tags: nil, owned: nil,
39
+ owner_type: nil, status: nil, bank_code: nil, bank_name: nil, type: nil, created: nil
40
+ )
41
+ super(id)
42
+ @account_created = account_created
43
+ @account_number = account_number
44
+ @account_type = account_type
45
+ @branch_code = branch_code
46
+ @name = name
47
+ @tax_id = tax_id
48
+ @tags = tags
49
+ @owned = StarkInfra::Utils::Checks.check_datetime(owned)
50
+ @owner_type = owner_type
51
+ @status = status
52
+ @bank_code = bank_code
53
+ @bank_name = bank_name
54
+ @type = type
55
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
56
+ end
57
+
58
+ # # Create a PixKey
59
+ #
60
+ # Send a PixKey objects for creation in the Stark Infra API
61
+ #
62
+ # ## Parameters (required):
63
+ # - key [PixKey object]: PixKey object to be created in the API
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
+ # - PixKey object with updated attributes
70
+ def self.create(key, user: nil)
71
+ StarkInfra::Utils::Rest.post_single(entity: key, user: user, **resource)
72
+ end
73
+
74
+ # # Retrieve a specific PixKey
75
+ #
76
+ # Receive a single PixKey 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
+ # - 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'.
81
+ #
82
+ # ## Parameters (optional):
83
+ # - 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'
84
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
85
+ #
86
+ # ## Return:
87
+ # - PixKey object with updated attributes
88
+ def self.get(id, payer_id:, end_to_end_id: nil, user: nil)
89
+ StarkInfra::Utils::Rest.get_id(
90
+ id: id,
91
+ payer_id: payer_id,
92
+ end_to_end_id: end_to_end_id,
93
+ user: user,
94
+ **resource
95
+ )
96
+ end
97
+
98
+ # # Retrieve PixKeys
99
+ #
100
+ # Receive a generator of PixKey objects previously created in the Stark Infra API
101
+ #
102
+ # ## Parameters (optional):
103
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
104
+ # - after [Date or string, default nil]: date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
105
+ # - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
106
+ # - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
107
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
108
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
109
+ # - type [string, default nil]: filter for the type of retrieved PixKeys. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp'
110
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
111
+ #
112
+ # ## Return:
113
+ # - generator of PixKey objects with updated attributes
114
+ def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, type: nil, user: nil)
115
+ after = StarkInfra::Utils::Checks.check_date(after)
116
+ before = StarkInfra::Utils::Checks.check_date(before)
117
+ StarkInfra::Utils::Rest.get_stream(
118
+ limit: limit,
119
+ after: after,
120
+ before: before,
121
+ status: status,
122
+ tags: tags,
123
+ ids: ids,
124
+ type: type,
125
+ user: user,
126
+ **resource
127
+ )
128
+ end
129
+
130
+ # # Retrieve paged PixKeys
131
+ #
132
+ # Receive a list of up to 100 PixKey objects previously created in the Stark infra API and the cursor to the next page.
133
+ # Use this function instead of query if you want to manually page your keys.
134
+ #
135
+ # ## Parameters (optional):
136
+ # - cursor [string, default nil]: cursor returned on the previous page function call
137
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
138
+ # - after [Date or string, default nil]: date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
139
+ # - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
140
+ # - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
141
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
142
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
143
+ # - type [string, default nil]: filter for the type of retrieved PixKeys. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp'
144
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
145
+ #
146
+ # ## Return:
147
+ # - list of PixKey objects with updated attributes
148
+ # - cursor to retrieve the next page of PixKey objects
149
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, type: nil, user: nil)
150
+ after = StarkInfra::Utils::Checks.check_date(after)
151
+ before = StarkInfra::Utils::Checks.check_date(before)
152
+ StarkInfra::Utils::Rest.get_page(
153
+ cursor: cursor,
154
+ limit: limit,
155
+ after: after,
156
+ before: before,
157
+ status: status,
158
+ tags: tags,
159
+ ids: ids,
160
+ type: type,
161
+ user: user,
162
+ **resource
163
+ )
164
+ end
165
+
166
+ # # Update a PixKey entity
167
+ #
168
+ # Respond to a received PixKey.
169
+ #
170
+ # ## Parameters (required):
171
+ # - id [string]: PixKey unique id. ex: '5656565656565656'
172
+ # - reason [string]: reason why the PixKey is being patched. Options: 'branchTransfer', 'reconciliation' or 'userRequested'.
173
+ #
174
+ # ## Parameters (optional):
175
+ # - account_created [Date, DateTime or string, default nil]: opening Date or DateTime for the account to be linked. ex: '2022-01-01.
176
+ # - account_number [string, default nil]: number of the account to be linked. ex: '76543'.
177
+ # - account_type [string, default nil]: type of the account to be linked. Options: 'checking', 'savings', 'salary' or 'payment'.
178
+ # - branch_code [string, default nil]: branch code of the account to be linked. ex: 1234'.
179
+ # - name [string, default nil]: holder's name of the account to be linked. ex: 'Jamie Lannister'.
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
+ # - updated PixKey object
184
+ def self.update(id, reason:, account_created: nil, account_number: nil, account_type: nil, branch_code: nil, name: nil, user: nil)
185
+ StarkInfra::Utils::Rest.patch_id(
186
+ id: id,
187
+ reason: reason,
188
+ account_created: account_created,
189
+ account_number: account_number,
190
+ account_type: account_type,
191
+ branch_code: branch_code,
192
+ name: name,
193
+ user: user,
194
+ **resource
195
+ )
196
+ end
197
+
198
+ # # Cancel a PixKey entity
199
+ #
200
+ # Cancel a PixKey entity previously created in the Stark Infra API
201
+ #
202
+ # ## Parameters (required):
203
+ # - id [string]: PixKey unique id. ex: '5656565656565656'
204
+ #
205
+ # ## Parameters (optional):
206
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
207
+ #
208
+ # ## Return:
209
+ # - canceled PixKey object
210
+ def self.cancel(id, user: nil)
211
+ StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
212
+ end
213
+
214
+ def self.resource
215
+ {
216
+ resource_name: 'PixKey',
217
+ resource_maker: proc { |json|
218
+ PixKey.new(
219
+ account_created: json['account_created'],
220
+ account_number: json['account_number'],
221
+ account_type: json['account_type'],
222
+ branch_code: json['branch_code'],
223
+ name: json['name'],
224
+ tax_id: json['tax_id'],
225
+ id: json['id'],
226
+ tags: json['tags'],
227
+ owned: json['owned'],
228
+ owner_type: json['owner_type'],
229
+ status: json['status'],
230
+ bank_code: json['bank_code'],
231
+ bank_name: json['bank_name'],
232
+ type: json['type'],
233
+ created: json['created']
234
+ )
235
+ }
236
+ }
237
+ end
238
+ end
239
+ end
@@ -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
- # is generated for the entity. This log is never generated by the
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, 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)
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
- # - list of Log objects with updated attributes
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 requests.
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 nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
84
- # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
85
- # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
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
- # - Cursor to retrieve the next page of Log objects
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
- return StarkInfra::Utils::Rest.get_page(
96
+ StarkInfra::Utils::Rest.get_page(
97
97
  cursor: cursor,
98
98
  limit: limit,
99
99
  after: after,
@@ -14,42 +14,45 @@ module StarkInfra
14
14
  #
15
15
  # ## Parameters (required):
16
16
  # - amount [integer]: amount in cents to be transferred. ex: 11234 (= R$ 112.34)
17
- # - external_id [string]: url safe string 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"
18
- # - sender_name [string]: sender full name. ex: "Anthony Edward Stark"
19
- # - sender_tax_id [string]: sender tax ID (CPF or CNPJ) with or without formatting. ex: "01234567890" or "20.018.183/0001-80"
20
- # - sender_branch_code [string]: sender bank account branch code. Use '-' in case there is a verifier digit. ex: "1357-9"
21
- # - sender_account_number [string]: sender bank account number. Use '-' before the verifier digit. ex: "876543-2"
22
- # - sender_account_type [string, default "checking"]: sender bank account type. ex: "checking", "savings", "salary" or "payment"
23
- # - receiver_name [string]: receiver full name. ex: "Anthony Edward Stark"
24
- # - receiver_tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex: "01234567890" or "20.018.183/0001-80"
25
- # - receiver_bank_code [string]: code of the receiver bank institution in Brazil. ex: "20018183" or "341"
26
- # - receiver_account_number [string]: receiver bank account number. Use '-' before the verifier digit. ex: "876543-2"
27
- # - receiver_branch_code [string]: receiver bank account branch code. Use '-' in case there is a verifier digit. ex: "1357-9"
28
- # - receiver_account_type [string]: receiver bank account type. ex: "checking", "savings", "salary" or "payment"
29
- # - end_to_end_id [string]: central bank's unique transaction ID. ex: "E79457883202101262140HHX553UPqeq"
17
+ # - external_id [string]: url safe string 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'
18
+ # - sender_name [string]: sender full name. ex: 'Anthony Edward Stark'
19
+ # - sender_tax_id [string]: sender tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
20
+ # - sender_branch_code [string]: sender bank account branch code. Use '-' in case there is a verifier digit. ex: '1357-9'
21
+ # - sender_account_number [string]: sender bank account number. Use '-' before the verifier digit. ex: '876543-2'
22
+ # - sender_account_type [string, default 'checking']: sender bank account type. ex: 'checking', 'savings', 'salary' or 'payment'
23
+ # - receiver_name [string]: receiver full name. ex: 'Anthony Edward Stark'
24
+ # - receiver_tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
25
+ # - receiver_bank_code [string]: code of the receiver bank institution in Brazil. ex: '20018183' or '341'
26
+ # - receiver_account_number [string]: receiver bank account number. Use '-' before the verifier digit. ex: '876543-2'
27
+ # - receiver_branch_code [string]: receiver bank account branch code. Use '-' in case there is a verifier digit. ex: '1357-9'
28
+ # - receiver_account_type [string]: receiver bank account type. ex: 'checking', 'savings', 'salary' or 'payment'
29
+ # - end_to_end_id [string]: central bank's unique transaction ID. ex: 'E79457883202101262140HHX553UPqeq'
30
30
  #
31
31
  # ## Parameters (optional):
32
32
  # - receiver_key_id [string, default nil]: Receiver's dict key. Example: tax id (CPF/CNPJ).
33
- # - description [string, default nil]: optional description to override default description to be shown in the bank statement. ex: "Payment for service #1234"
34
- # - reconciliation_id [string, default nil]: Reconciliation ID linked to this payment. ex: "b77f5236-7ab9-4487-9f95-66ee6eaf1781"
35
- # - initiator_tax_id [string, default nil]: Payment initiator's tax id (CPF/CNPJ). ex: "01234567890" or "20.018.183/0001-80"
33
+ # - description [string, default nil]: optional description to override default description to be shown in the bank statement. ex: 'Payment for service #1234'
34
+ # - reconciliation_id [string, default nil]: Reconciliation ID linked to this payment. ex: 'b77f5236-7ab9-4487-9f95-66ee6eaf1781'
35
+ # - initiator_tax_id [string, default nil]: Payment initiator's tax id (CPF/CNPJ). ex: '01234567890' or '20.018.183/0001-80'
36
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"
37
+ # - cashier_bank_code [string, default nil]: Cashier's bank code. ex: '00000000'
38
38
  # - cashier_type [string, default nil]: Cashier's type. ex: [merchant, other, participant]
39
- # - tags [list of strings, default nil]: list of strings for reference when searching for PixRequests. ex: ["employees", "monthly"]
40
- # - method [string]: execution method of creation of the PIX. ex: "manual", "payerQrcode", "dynamicQrcode".
39
+ # - tags [list of strings, default nil]: list of strings for reference when searching for PixRequests. ex: ['employees', 'monthly']
40
+ # - method [string, default nil]: execution method of creation of the PIX. ex: 'manual', 'payerQrcode', 'dynamicQrcode'.
41
41
  #
42
42
  # ## Attributes (return-only):
43
- # - id [string, default nil]: unique id returned when the PixRequest is created. ex: "5656565656565656"
44
- # - fee [integer, default nil]: fee charged when PixRequest is paid. ex: 200 (= R$ 2.00)
45
- # - status [string]: current PixRequest status. ex: "registered" or "paid"
46
- # - flow [string]: direction of money flow. ex: "in" or "out"
47
- # - sender_bank_code [string]: code of the sender bank institution in Brazil. If an ISPB (8 digits) is informed. ex: "20018183" or "341"
48
- # - created [Datetime, default nil]: creation datetime for the PixRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
49
- # - updated [Datetime, default nil]: latest update datetime for the PixRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
50
-
43
+ # - id [string]: unique id returned when the PixRequest is created. ex: '5656565656565656'
44
+ # - fee [integer]: fee charged when PixRequest is paid. ex: 200 (= R$ 2.00)
45
+ # - status [string]: current PixRequest status. ex: 'registered' or 'paid'
46
+ # - flow [string]: direction of money flow. ex: 'in' or 'out'
47
+ # - sender_bank_code [string]: code of the sender bank institution in Brazil. ex: '20018183'
48
+ # - created [DateTime]: creation datetime for the PixRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
49
+ # - updated [DateTime]: latest update datetime for the PixRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
51
50
  class PixRequest < StarkInfra::Utils::Resource
52
- attr_reader :amount, :external_id, :sender_name, :sender_tax_id, :sender_branch_code, :sender_account_number, :sender_account_type, :receiver_name, :receiver_tax_id, :receiver_bank_code, :receiver_account_number, :receiver_branch_code, :receiver_account_type, :end_to_end_id, :receiver_key_id, :sender_bank_code, :status, :reconciliation_id, :description, :flow, :initiator_tax_id, :cash_amount, :cashier_bank_code, :cashier_type, :tags, :created, :updated, :fee, :id
51
+ attr_reader :amount, :external_id, :sender_name, :sender_tax_id, :sender_branch_code, :sender_account_number,
52
+ :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, :receiver_key_id, :sender_bank_code,
54
+ :status, :reconciliation_id, :description, :flow, :initiator_tax_id, :cash_amount, :cashier_bank_code,
55
+ :cashier_type, :tags, :created, :updated, :fee, :id
53
56
  def initialize(
54
57
  amount:, external_id:, sender_name:, sender_tax_id:, sender_branch_code:, sender_account_number:,
55
58
  sender_account_type:, receiver_name:, receiver_tax_id:, receiver_bank_code:, receiver_account_number:,
@@ -97,7 +100,7 @@ module StarkInfra
97
100
  # - requests [list of PixRequest objects]: list of PixRequest objects to be created in the API
98
101
  #
99
102
  # ## Parameters (optional):
100
- # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
103
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
101
104
  #
102
105
  # ## Return:
103
106
  # - list of PixRequest objects with updated attributes
@@ -113,7 +116,7 @@ module StarkInfra
113
116
  # - id [string]: object unique id. ex: '5656565656565656'
114
117
  #
115
118
  # ## Parameters (optional):
116
- # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
119
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
117
120
  #
118
121
  # ## Return:
119
122
  # - PixRequest object with updated attributes
@@ -127,23 +130,21 @@ module StarkInfra
127
130
  #
128
131
  # ## Parameters (optional):
129
132
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
130
- # - fields [list of strings, default None]: parameters to be retrieved from PixRequest objects. ex: ["amount", "id"]
131
- # - 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)
132
- # - 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)
133
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
134
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
133
135
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
134
136
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
135
137
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
136
- # - end_to_end_ids [list of strings, default None]: central bank's unique transaction IDs. ex: ["E79457883202101262140HHX553UPqeq", "E79457883202101262140HHX553UPxzx"]
137
- # - external_ids [list of strings, default None]: 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"]
138
- # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
138
+ # - end_to_end_ids [list of strings, default nil]: central bank's unique transaction IDs. ex: ['E79457883202101262140HHX553UPqeq', 'E79457883202101262140HHX553UPxzx']
139
+ # - 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']
140
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
139
141
  #
140
142
  # ## Return:
141
143
  # - generator of PixRequest objects with updated attributes
142
- def self.query(fields: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, end_to_end_ids: nil, external_ids: nil, user: nil)
144
+ def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, end_to_end_ids: nil, external_ids: nil, user: nil)
143
145
  after = StarkInfra::Utils::Checks.check_date(after)
144
146
  before = StarkInfra::Utils::Checks.check_date(before)
145
147
  StarkInfra::Utils::Rest.get_stream(
146
- fields: fields,
147
148
  limit: limit,
148
149
  after: after,
149
150
  before: before,
@@ -164,26 +165,24 @@ module StarkInfra
164
165
  #
165
166
  # ## Parameters (optional):
166
167
  # - cursor [string, default nil]: cursor returned on the previous page function call
167
- # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
168
- # - fields [list of strings, default None]: parameters to be retrieved from PixRequest objects. ex: ["amount", "id"]
169
- # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
170
- # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
168
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
169
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
170
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
171
171
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
172
172
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
173
173
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
174
- # - end_to_end_ids [list of strings, default None]: central bank's unique transaction IDs. ex: ["E79457883202101262140HHX553UPqeq", "E79457883202101262140HHX553UPxzx"]
175
- # - external_ids [list of strings, default None]: 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"]
176
- # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
174
+ # - end_to_end_ids [list of strings, default nil]: central bank's unique transaction IDs. ex: ['E79457883202101262140HHX553UPqeq', 'E79457883202101262140HHX553UPxzx']
175
+ # - 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']
176
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
177
177
  #
178
178
  # ## Return:
179
179
  # - list of PixRequest objects with updated attributes
180
- # - Cursor to retrieve the next page of PixRequest objects
181
- def self.page(cursor: nil, fields: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, end_to_end_ids: nil, external_ids: nil, user: nil)
180
+ # - cursor to retrieve the next page of PixRequest objects
181
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, end_to_end_ids: nil, external_ids: nil, user: nil)
182
182
  after = StarkInfra::Utils::Checks.check_date(after)
183
183
  before = StarkInfra::Utils::Checks.check_date(before)
184
- return StarkInfra::Utils::Rest.get_page(
184
+ StarkInfra::Utils::Rest.get_page(
185
185
  cursor: cursor,
186
- fields: fields,
187
186
  limit: limit,
188
187
  after: after,
189
188
  before: before,
@@ -197,24 +196,24 @@ module StarkInfra
197
196
  )
198
197
  end
199
198
 
199
+ # # Create single verified PixRequest object from a content string
200
+ #
201
+ # Create a single PixRequest object from a content string received from a handler listening at a subscribed user endpoint.
202
+ # If the provided digital signature does not check out with the StarkInfra public key, a
203
+ # StarkInfra.Error.InvalidSignatureError will be raised.
204
+ #
205
+ # ## Parameters (required):
206
+ # - content [string]: response content from request received at user endpoint (not parsed)
207
+ # - signature [string]: base-64 digital signature received at response header 'Digital-Signature'
208
+ #
209
+ # ## Parameters (optional):
210
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
211
+ #
212
+ # ## Return:
213
+ # - Parsed PixRequest object
200
214
  def self.parse(content:, signature:, user: nil)
201
- # # Create single verified PixRequest object from a content string
202
- #
203
- # Create a single PixRequest object from a content string received from a handler listening at a subscribed user endpoint.
204
- # If the provided digital signature does not check out with the StarkInfra public key, a
205
- # starkinfra.exception.InvalidSignatureException will be raised.
206
- #
207
- # ## Parameters (required):
208
- # - content [string]: response content from request received at user endpoint (not parsed)
209
- # - signature [string]: base-64 digital signature received at response header "Digital-Signature"
210
- #
211
- # ## Parameters (optional):
212
- # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
213
- #
214
- # ## Return:
215
- # - Parsed PixRequest object
216
- return StarkInfra::Utils::Parse.parse_and_verify(content: content, signature: signature, user: user, resource: resource)
217
- end
215
+ StarkInfra::Utils::Parse.parse_and_verify(content: content, signature: signature, user: user, resource: resource)
216
+ end
218
217
 
219
218
  def self.resource
220
219
  {
@@ -250,7 +249,7 @@ module StarkInfra
250
249
  method: json['method'],
251
250
  sender_bank_code: json['sender_bank_code'],
252
251
  created: json['created'],
253
- updated: json['updated'],
252
+ updated: json['updated']
254
253
  )
255
254
  }
256
255
  }
@@ -37,7 +37,7 @@ module StarkInfra
37
37
  # - id [string]: object unique id. ex: '5656565656565656'
38
38
  #
39
39
  # ## Parameters (optional):
40
- # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
40
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
41
41
  #
42
42
  # ## Return:
43
43
  # - Log object with updated attributes
@@ -51,14 +51,14 @@ module StarkInfra
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
- # - 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)
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
  # - reversal_ids [list of strings, default nil]: list of PixReversal 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
- # - list of Log objects with updated attributes
61
+ # - generator of Log objects with updated attributes
62
62
  def self.query(limit: nil, after: nil, before: nil, types: nil, reversal_ids: nil, user: nil)
63
63
  after = StarkInfra::Utils::Checks.check_date(after)
64
64
  before = StarkInfra::Utils::Checks.check_date(before)
@@ -76,23 +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 requests.
79
+ # Use this function instead of query if you want to manually page your reversals.
80
80
  #
81
81
  # ## Parameters (optional):
82
82
  # - cursor [string, default nil]: cursor returned on the previous page function call
83
- # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
84
- # - after [Date, DateTime, Time or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
85
- # - before [Date, DateTime, Time or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
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
  # - reversal_ids [list of strings, default nil]: list of PixReversal 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
- # - list of Log objects with updated attributes and cursor to retrieve the next page of Log objects
91
+ # - list of Log objects with updated attributes
92
+ # - cursor to retrieve the next page of Log objects
92
93
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, reversal_ids: nil, user: nil)
93
94
  after = StarkInfra::Utils::Checks.check_date(after)
94
95
  before = StarkInfra::Utils::Checks.check_date(before)
95
- return StarkInfra::Utils::Rest.get_page(
96
+ StarkInfra::Utils::Rest.get_page(
96
97
  cursor: cursor,
97
98
  limit: limit,
98
99
  after: after,