starkinfra 0.5.2 → 0.7.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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcode_preview/brcode_preview.rb +25 -4
  3. data/lib/brcode_preview/subscription.rb +102 -0
  4. data/lib/business_account_request/business_account_request.rb +276 -0
  5. data/lib/business_account_request/log.rb +124 -0
  6. data/lib/business_attachment/business_attachment.rb +189 -0
  7. data/lib/{individual_document → business_attachment}/log.rb +35 -32
  8. data/lib/business_identity/business_identity.rb +228 -0
  9. data/lib/business_identity/log.rb +127 -0
  10. data/lib/credit_holmes/credit_holmes.rb +2 -1
  11. data/lib/credit_holmes/log.rb +125 -0
  12. data/lib/credit_note/credit_note.rb +51 -8
  13. data/lib/credit_note/rule.rb +55 -0
  14. data/lib/credit_note/transfer.rb +1 -1
  15. data/lib/credit_preview/credit_note_preview.rb +10 -2
  16. data/lib/credit_preview/credit_preview.rb +2 -1
  17. data/lib/credit_signer/credit_signer.rb +27 -2
  18. data/lib/dynamic_brcode/dynamic_brcode.rb +5 -2
  19. data/lib/event/event.rb +10 -2
  20. data/lib/individual_account_attachment/individual_account_attachment.rb +178 -0
  21. data/lib/individual_account_attachment/log.rb +124 -0
  22. data/lib/individual_account_request/individual_account_request.rb +271 -0
  23. data/lib/individual_account_request/log.rb +124 -0
  24. data/lib/individual_identity/individual_identity.rb +4 -7
  25. data/lib/issuing_balance/issuing_balance.rb +8 -2
  26. data/lib/issuing_billing_invoice/issuing_billing_invoice.rb +155 -0
  27. data/lib/issuing_billing_transaction/issuing_billing_transaction.rb +142 -0
  28. data/lib/issuing_card/issuing_card.rb +10 -6
  29. data/lib/issuing_design/issuing_design.rb +9 -0
  30. data/lib/issuing_embossing_request/issuing_embossing_request.rb +3 -2
  31. data/lib/issuing_holder/issuing_holder.rb +6 -5
  32. data/lib/issuing_product/issuing_product.rb +6 -3
  33. data/lib/issuing_purchase/issuing_purchase.rb +41 -8
  34. data/lib/issuing_restock/issuing_restock.rb +3 -2
  35. data/lib/issuing_rule/issuing_rule.rb +45 -3
  36. data/lib/issuing_stock/issuing_stock.rb +5 -2
  37. data/lib/issuing_stock_rule/issuing_stock_rule.rb +214 -0
  38. data/lib/issuing_token/issuing_token.rb +309 -0
  39. data/lib/issuing_token/log.rb +127 -0
  40. data/lib/issuing_token_activation/issuing_token_activation.rb +62 -0
  41. data/lib/issuing_token_design/issuing_token_design.rb +118 -0
  42. data/lib/issuing_token_request/issuing_token_request.rb +63 -0
  43. data/lib/issuing_withdrawal/issuing_withdrawal.rb +2 -2
  44. data/lib/ledger/ledger.rb +175 -0
  45. data/lib/ledger/log.rb +122 -0
  46. data/lib/ledger/rule.rb +55 -0
  47. data/lib/ledger_transaction/ledger_transaction.rb +179 -0
  48. data/lib/merchant_category/merchant_category.rb +6 -3
  49. data/lib/pix_balance/pix_balance.rb +1 -1
  50. data/lib/pix_chargeback/pix_chargeback.rb +34 -7
  51. data/lib/pix_claim/pix_claim.rb +14 -6
  52. data/lib/pix_director/pix_director.rb +1 -1
  53. data/lib/pix_dispute/log.rb +127 -0
  54. data/lib/pix_dispute/pix_dispute.rb +210 -0
  55. data/lib/pix_dispute/transaction.rb +91 -0
  56. data/lib/pix_fraud/log.rb +128 -0
  57. data/lib/pix_fraud/pix_fraud.rb +180 -0
  58. data/lib/pix_infraction/pix_infraction.rb +37 -7
  59. data/lib/pix_internal_transaction_report/log.rb +129 -0
  60. data/lib/pix_internal_transaction_report/pix_internal_transaction_report.rb +200 -0
  61. data/lib/pix_key/pix_key.rb +1 -1
  62. data/lib/pix_key_holmes/log.rb +129 -0
  63. data/lib/{individual_document/individual_document.rb → pix_key_holmes/pix_key_holmes.rb} +48 -56
  64. data/lib/pix_pull_request/log.rb +127 -0
  65. data/lib/pix_pull_request/pix_pull_request.rb +268 -0
  66. data/lib/pix_pull_subscription/log.rb +127 -0
  67. data/lib/pix_pull_subscription/pix_pull_subscription.rb +307 -0
  68. data/lib/pix_request/pix_request.rb +19 -6
  69. data/lib/pix_reversal/pix_reversal.rb +14 -8
  70. data/lib/pix_statement/pix_statement.rb +11 -5
  71. data/lib/pix_user/pix_user.rb +52 -0
  72. data/lib/pix_user/statistics.rb +64 -0
  73. data/lib/starkinfra.rb +45 -4
  74. data/lib/static_brcode/static_brcode.rb +8 -4
  75. data/lib/utils/bacen_id.rb +27 -0
  76. data/lib/utils/end_to_end_id.rb +20 -0
  77. data/lib/utils/pix_subscription_bacen_id.rb +21 -0
  78. data/lib/utils/return_id.rb +21 -0
  79. data/lib/webhook/webhook.rb +3 -3
  80. metadata +48 -11
@@ -0,0 +1,309 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+ require_relative('../utils/parse')
6
+
7
+ module StarkInfra
8
+ # # IssuingToken object
9
+ #
10
+ # The IssuingToken object displays the information of the tokens created in your Workspace.
11
+ #
12
+ # ## Attributes (return-only):
13
+ # - id [string]: unique id returned when IssuingToken is created. ex: '5656565656565656'
14
+ # - card_id [string]: card ID which the token is bounded to. ex: '5656565656565656'
15
+ # - wallet_id [string]: wallet provider which the token is bounded to. ex: 'google'
16
+ # - wallet_name [string]: wallet name. ex: 'GOOGLE'
17
+ # - merchant_id [string]: merchant unique id. ex: '5656565656565656'
18
+ # - status [string]: current IssuingToken status. Options: 'active', 'blocked', 'canceled', 'frozen', 'pending', 'denied'.
19
+ # - wallet_device_score [number]: Device score informed by the digital wallet.
20
+ # - wallet_account_score [number]: Account score informed by the digital wallet
21
+ # - updated [DateTime]: latest update datetime for the IssuingToken. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
22
+ # - created [DateTime]: creation datetime for the IssuingToken. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
23
+ #
24
+ # ## Attributes (authorization request only):
25
+ # - external_id [string]: a unique string among all your IssuingTokens, used to avoid resource duplication. ex: 'DSHRMC00002626944b0e3b539d4d459281bdba90c2588791'
26
+ # - tags [list of strings]: list of strings for reference when searching for IssuingToken. ex: ['employees', 'monthly']
27
+ # - activation_code [string]: activation code received through the bank app or sms. ex: '481632'
28
+ # - method_code [string]: provisioning method. Options: 'app', 'token', 'manual', 'server' or 'browser'
29
+ # - device_type [string]: device type used for tokenization. ex: 'Phone'
30
+ # - device_name [string]: device name used for tokenization. ex: 'My phone'
31
+ # - device_serial_number [string]: device serial number used for tokenization. ex: '2F6D63'
32
+ # - device_os_name [string]: device operational system name used for tokenization. ex: 'Android'
33
+ # - device_os_version [string]: device operational system version used for tokenization. ex: '4.4.4'
34
+ # - device_imei [string]: device imei used for tokenization. ex: '352099001761481'
35
+ # - wallet_instance_id [string]: unique id refered to the wallet app in the current device. ex: '71583be4777eb89aaf0345eebeb82594f096615ed17862d0'
36
+ class IssuingToken < StarkCore::Utils::Resource
37
+ attr_reader :card_id, :wallet_id, :wallet_name, :merchant_id, :status, :external_id, :tags, :activation_code,
38
+ :method_code, :device_type, :device_name, :device_serial_number, :device_os_name, :device_os_version,
39
+ :device_imei, :wallet_instance_id, :wallet_device_score, :wallet_account_score, :id, :updated, :created
40
+ def initialize(
41
+ card_id: nil, wallet_id: nil, wallet_name: nil, merchant_id: nil, status: nil, external_id: nil,
42
+ tags: nil, activation_code: nil, method_code: nil, device_type: nil, device_name: nil,
43
+ device_serial_number: nil, device_os_name: nil, device_os_version: nil, device_imei: nil,
44
+ wallet_instance_id: nil, wallet_device_score: nil, wallet_account_score: nil, id: nil, updated: nil, created: nil
45
+ )
46
+ super(id)
47
+ @card_id = card_id
48
+ @wallet_id = wallet_id
49
+ @wallet_name = wallet_name
50
+ @merchant_id = merchant_id
51
+ @status = status
52
+ @external_id = external_id
53
+ @tags = tags
54
+ @activation_code = activation_code
55
+ @method_code = method_code
56
+ @device_type = device_type
57
+ @device_name = device_name
58
+ @device_serial_number = device_serial_number
59
+ @device_os_name = device_os_name
60
+ @device_os_version = device_os_version
61
+ @device_imei = device_imei
62
+ @wallet_instance_id = wallet_instance_id
63
+ @wallet_device_score = wallet_device_score
64
+ @wallet_account_score = wallet_account_score
65
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
66
+ @created = StarkCore::Utils::Checks.check_datetime(created)
67
+ end
68
+
69
+ # # Retrieve a specific IssuingToken
70
+ #
71
+ # Receive a single IssuingToken object previously created in the Stark Infra API by its id
72
+ #
73
+ # ## Parameters (required):
74
+ # - id [string]: object unique id. ex: '5656565656565656'
75
+ #
76
+ # ## Parameters (optional):
77
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
78
+ #
79
+ # ## Return:
80
+ # - IssuingToken object with updated attributes
81
+ def self.get(id, user: nil)
82
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
83
+ end
84
+
85
+ # # Retrieve IssuingTokens
86
+ #
87
+ # Receive a generator of IssuingToken objects previously created in the Stark Infra API
88
+ #
89
+ # ## Parameters (optional):
90
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
91
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
92
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
93
+ # - status [string, default nil]: current IssuingToken status. ex: 'active', 'blocked', 'canceled', 'frozen' or 'pending'
94
+ # - card_ids [list of strings, default nil]: list of card_ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
95
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
96
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
97
+ # - external_ids [list of strings, default nil]: external IDs. ex: ['DSHRMC00002626944b0e3b539d4d459281bdba90c2588791', 'DSHRMC00002626941c531164a0b14c66ad9602ee716f1e85']
98
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
99
+ #
100
+ # ## Return:
101
+ # - generator of IssuingToken objects with updated attributes
102
+ def self.query(limit: nil, after: nil, before: nil, status: nil, card_ids: nil, tags: nil, ids: nil, external_ids: nil, user: nil)
103
+ after = StarkCore::Utils::Checks.check_date(after)
104
+ before = StarkCore::Utils::Checks.check_date(before)
105
+ StarkInfra::Utils::Rest.get_stream(
106
+ limit: limit,
107
+ after: after,
108
+ before: before,
109
+ status: status,
110
+ card_ids: card_ids,
111
+ tags: tags,
112
+ ids: ids,
113
+ external_ids: external_ids,
114
+ user: user,
115
+ **resource
116
+ )
117
+ end
118
+
119
+ # # Retrieve paged IssuingTokens
120
+ #
121
+ # Receive a list of up to 100 IssuingToken objects previously created in the Stark Infra API and the cursor to the next page.
122
+ # Use this function instead of query if you want to manually page your requests.
123
+ #
124
+ # ## Parameters (optional):
125
+ # - cursor [string, default nil]: cursor returned on the previous page function call
126
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
127
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
128
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
129
+ # - status [string, default nil]: current IssuingToken status. ex: 'active', 'blocked', 'canceled', 'frozen' or 'pending'
130
+ # - card_ids [list of strings, default nil]: list of card_ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
131
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
132
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
133
+ # - external_ids [list of strings, default nil]: external IDs. ex: ['DSHRMC00002626944b0e3b539d4d459281bdba90c2588791', 'DSHRMC00002626941c531164a0b14c66ad9602ee716f1e85']
134
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
135
+ #
136
+ # ## Return:
137
+ # - list of IssuingToken objects with updated attributes
138
+ # - cursor to retrieve the next page of IssuingToken objects
139
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, card_ids: nil, tags: nil, ids: nil, external_ids: nil, user: nil)
140
+ after = StarkCore::Utils::Checks.check_date(after)
141
+ before = StarkCore::Utils::Checks.check_date(before)
142
+ StarkInfra::Utils::Rest.get_page(
143
+ cursor: cursor,
144
+ limit: limit,
145
+ after: after,
146
+ before: before,
147
+ status: status,
148
+ card_ids: card_ids,
149
+ tags: tags,
150
+ ids: ids,
151
+ external_ids: external_ids,
152
+ user: user,
153
+ **resource
154
+ )
155
+ end
156
+
157
+ # # Update IssuingToken entity
158
+ #
159
+ # Update an IssuingToken by passing id.
160
+ #
161
+ # ## Parameters (required):
162
+ # - id [string]: IssuingToken id. ex: '5656565656565656'
163
+ #
164
+ # ## Parameters (optional):
165
+ # - status [string, default nil]: You may block the IssuingToken by passing 'blocked' or activate by passing 'active' in the status. ex: 'active', 'blocked'
166
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
167
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
168
+ #
169
+ # ## Return:
170
+ # - target IssuingToken with updated attributes
171
+ def self.update(id, status: nil, tags: nil, user: nil)
172
+ StarkInfra::Utils::Rest.patch_id(
173
+ id: id,
174
+ status: status,
175
+ tags: tags,
176
+ user: user,
177
+ **resource
178
+ )
179
+ end
180
+
181
+ # # Cancel an IssuingToken entity
182
+ #
183
+ # Cancel an IssuingToken entity previously created in the Stark Infra API by its id. This action is irreversible.
184
+ #
185
+ # ## Parameters (required):
186
+ # - id [string]: IssuingToken unique id. ex: '5656565656565656'
187
+ #
188
+ # ## Parameters (optional):
189
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
190
+ #
191
+ # ## Return:
192
+ # - canceled IssuingToken object
193
+ def self.cancel(id, user: nil)
194
+ StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
195
+ end
196
+
197
+ # # Create a single verified IssuingToken request from a content string
198
+ #
199
+ # Use this method to parse and verify the authenticity of the request received at the informed endpoint.
200
+ # Token requests are posted to your registered endpoint whenever IssuingTokens are received.
201
+ # If the provided digital signature does not check out with the StarkInfra public key, a
202
+ # StarkInfra::Error::InvalidSignatureError will be raised.
203
+ #
204
+ # ## Parameters (required):
205
+ # - content [string]: response content from request received at user endpoint (not parsed)
206
+ # - signature [string]: base-64 digital signature received at response header 'Digital-Signature'
207
+ #
208
+ # ## Parameters (optional):
209
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
210
+ #
211
+ # ## Return:
212
+ # - Parsed IssuingToken object
213
+ def self.parse(content:, signature:, user: nil)
214
+ StarkInfra::Utils::Parse.parse_and_verify(content: content, signature: signature, user: user, resource: resource, key: nil)
215
+ end
216
+
217
+ # # Helps you respond to an IssuingToken authorization request
218
+ #
219
+ # When a new tokenization is triggered by your user, a POST request will be made to your registered URL to get
220
+ # your decision to complete the tokenization.
221
+ # The POST request must be answered in the following format, within 2 seconds, and with an HTTP status code 200.
222
+ #
223
+ # ## Parameters (required):
224
+ # - status [string]: sub-issuer response to the authorization. ex: 'approved' or 'denied'
225
+ #
226
+ # ## Parameters (conditionally required):
227
+ # - reason [string, default nil]: denial reason. Options: 'other', 'bruteForce', 'subIssuerError', 'lostCard', 'invalidCard', 'invalidHolder', 'expiredCard', 'canceledCard', 'blockedCard', 'invalidExpiration', 'invalidSecurityCode', 'missingTokenAuthorizationUrl', 'maxCardTriesExceeded', 'maxWalletInstanceTriesExceeded'
228
+ # - activation_methods [list of hashes, default nil]: list of hashes with 'type' and 'value' string pairs
229
+ # - design_id [string, default nil]: design unique id. ex: '5656565656565656'
230
+ #
231
+ # ## Parameters (optional):
232
+ # - tags [list of strings, default nil]: tags to filter retrieved object. ex: ['tony', 'stark']
233
+ #
234
+ # ## Return:
235
+ # - Dumped JSON string that must be returned to us on the IssuingToken request
236
+ def self.response_authorization(status:, reason: nil, activation_methods: nil, design_id: nil, tags: nil)
237
+ params = {
238
+ 'authorization': {
239
+ 'status': status,
240
+ 'reason': reason.nil? ? '' : reason,
241
+ 'activationMethods': activation_methods,
242
+ 'designId': design_id,
243
+ 'tags': tags
244
+ }
245
+ }
246
+
247
+ params.to_json
248
+ end
249
+
250
+ # # Helps you respond to an IssuingToken activation request
251
+ #
252
+ # When a new token activation is triggered by your user, a POST request will be made to your registered URL for
253
+ # you to confirm the activation code you informed to them. You may identify this request through the present
254
+ # activation_code in the payload.
255
+ # The POST request must be answered in the following format, within 2 seconds, and with an HTTP status code 200.
256
+ #
257
+ # ## Parameters (required):
258
+ # - status [string]: sub-issuer response to the activation. ex: 'approved' or 'denied'
259
+ #
260
+ # ## Parameters (optional):
261
+ # - reason [string, default nil]: denial reason. Options: 'other', 'bruteForce', 'subIssuerError', 'lostCard', 'invalidCard', 'invalidHolder', 'expiredCard', 'canceledCard', 'blockedCard', 'invalidExpiration', 'invalidSecurityCode', 'missingTokenAuthorizationUrl', 'maxCardTriesExceeded', 'maxWalletInstanceTriesExceeded'
262
+ # - tags [list of strings, default nil]: tags to filter retrieved object. ex: ['tony', 'stark']
263
+ #
264
+ # ## Return:
265
+ # - Dumped JSON string that must be returned to us on the IssuingToken request
266
+ def self.response_activation(status:, reason: nil, tags: nil)
267
+ params = {
268
+ 'authorization': {
269
+ 'status': status,
270
+ 'reason': reason.nil? ? '' : reason,
271
+ 'tags': tags
272
+ }
273
+ }
274
+
275
+ params.to_json
276
+ end
277
+
278
+ def self.resource
279
+ {
280
+ resource_name: 'IssuingToken',
281
+ resource_maker: proc { |json|
282
+ IssuingToken.new(
283
+ id: json['id'],
284
+ card_id: json['card_id'],
285
+ wallet_id: json['wallet_id'],
286
+ wallet_name: json['wallet_name'],
287
+ merchant_id: json['merchant_id'],
288
+ status: json['status'],
289
+ external_id: json['external_id'],
290
+ tags: json['tags'],
291
+ activation_code: json['activation_code'],
292
+ method_code: json['method_code'],
293
+ device_type: json['device_type'],
294
+ device_name: json['device_name'],
295
+ device_serial_number: json['device_serial_number'],
296
+ device_os_name: json['device_os_name'],
297
+ device_os_version: json['device_os_version'],
298
+ device_imei: json['device_imei'],
299
+ wallet_instance_id: json['wallet_instance_id'],
300
+ wallet_device_score: json['wallet_device_score'],
301
+ wallet_account_score: json['wallet_account_score'],
302
+ updated: json['updated'],
303
+ created: json['created']
304
+ )
305
+ }
306
+ }
307
+ end
308
+ end
309
+ end
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+ require_relative('issuing_token')
6
+
7
+ module StarkInfra
8
+ class IssuingToken
9
+ # # IssuingToken::Log object
10
+ #
11
+ # Every time an IssuingToken entity is modified, a corresponding IssuingToken::Log
12
+ # is generated for the entity. This log is never generated by the user.
13
+ #
14
+ # ## Attributes (return-only):
15
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
16
+ # - token [IssuingToken]: IssuingToken entity to which the log refers to.
17
+ # - errors [list of hashes]: list of errors linked to this IssuingToken event, each with 'code' and 'message' keys.
18
+ # - type [string]: type of the IssuingToken event which triggered the log creation. ex: 'active', 'blocked', 'canceled', 'frozen' or 'pending'
19
+ # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
20
+ class Log < StarkCore::Utils::Resource
21
+ attr_reader :id, :created, :type, :errors, :token
22
+ def initialize(id:, created:, type:, errors:, token:)
23
+ super(id)
24
+ @token = token
25
+ @errors = errors
26
+ @type = type
27
+ @created = StarkCore::Utils::Checks.check_datetime(created)
28
+ end
29
+
30
+ # # Retrieve a specific IssuingToken::Log
31
+ #
32
+ # Receive a single IssuingToken::Log object previously created by the Stark Infra API by its id
33
+ #
34
+ # ## Parameters (required):
35
+ # - id [string]: object unique id. ex: '5656565656565656'
36
+ #
37
+ # ## Parameters (optional):
38
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
39
+ #
40
+ # ## Return:
41
+ # - IssuingToken::Log object with updated attributes
42
+ def self.get(id, user: nil)
43
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
44
+ end
45
+
46
+ # # Retrieve IssuingToken::Logs
47
+ #
48
+ # Receive a generator of IssuingToken::Log objects previously created in the Stark Infra API
49
+ #
50
+ # ## Parameters (optional):
51
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
52
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
53
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
54
+ # - types [list of strings, default nil]: filter for log event types. ex: ['active', 'blocked', 'canceled', 'frozen', 'pending']
55
+ # - token_ids [list of strings, default nil]: list of IssuingToken ids to filter logs. ex: ['5656565656565656', '4545454545454545']
56
+ # - ids [list of strings, default nil]: list of ids to filter logs. ex: ['5656565656565656', '4545454545454545']
57
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
58
+ #
59
+ # ## Return:
60
+ # - generator of IssuingToken::Log objects with updated attributes
61
+ def self.query(limit: nil, after: nil, before: nil, types: nil, token_ids: nil, ids: nil, user: nil)
62
+ after = StarkCore::Utils::Checks.check_date(after)
63
+ before = StarkCore::Utils::Checks.check_date(before)
64
+ StarkInfra::Utils::Rest.get_stream(
65
+ limit: limit,
66
+ after: after,
67
+ before: before,
68
+ types: types,
69
+ token_ids: token_ids,
70
+ ids: ids,
71
+ user: user,
72
+ **resource
73
+ )
74
+ end
75
+
76
+ # # Retrieve paged IssuingToken::Logs
77
+ #
78
+ # Receive a list of up to 100 IssuingToken::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.
80
+ #
81
+ # ## Parameters (optional):
82
+ # - cursor [string, default nil]: cursor returned on the previous page function call
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
+ # - types [list of strings, default nil]: filter for log event types. ex: ['active', 'blocked', 'canceled', 'frozen', 'pending']
87
+ # - token_ids [list of strings, default nil]: list of IssuingToken ids to filter logs. ex: ['5656565656565656', '4545454545454545']
88
+ # - ids [list of strings, default nil]: list of ids to filter logs. ex: ['5656565656565656', '4545454545454545']
89
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
90
+ #
91
+ # ## Return:
92
+ # - list of IssuingToken::Log objects with updated attributes
93
+ # - cursor to retrieve the next page of IssuingToken::Log objects
94
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, token_ids: nil, ids: nil, user: nil)
95
+ after = StarkCore::Utils::Checks.check_date(after)
96
+ before = StarkCore::Utils::Checks.check_date(before)
97
+ StarkInfra::Utils::Rest.get_page(
98
+ cursor: cursor,
99
+ limit: limit,
100
+ after: after,
101
+ before: before,
102
+ types: types,
103
+ token_ids: token_ids,
104
+ ids: ids,
105
+ user: user,
106
+ **resource
107
+ )
108
+ end
109
+
110
+ def self.resource
111
+ token_maker = StarkInfra::IssuingToken.resource[:resource_maker]
112
+ {
113
+ resource_name: 'IssuingTokenLog',
114
+ resource_maker: proc { |json|
115
+ Log.new(
116
+ id: json['id'],
117
+ token: StarkCore::Utils::API.from_api_json(token_maker, json['token']),
118
+ errors: json['errors'],
119
+ type: json['type'],
120
+ created: json['created']
121
+ )
122
+ }
123
+ }
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/parse')
5
+
6
+ module StarkInfra
7
+ # # IssuingTokenActivation object
8
+ #
9
+ # The IssuingTokenActivation object displays the necessary information to proceed with the card tokenization.
10
+ # You will receive this object at your registered URL to notify you which method your user want to receive the activation code.
11
+ # The POST request must be answered with no content, within 2 seconds, and with an HTTP status code 200.
12
+ # After that, you may generate the activation code and send it to the cardholder.
13
+ #
14
+ # ## Attributes (return-only):
15
+ # - card_id [string]: card ID which the token is bounded to. ex: '5656565656565656'
16
+ # - token_id [string]: token unique id. ex: '5656565656565656'
17
+ # - tags [list of strings]: tags to filter retrieved object. ex: ['tony', 'stark']
18
+ # - activation_method [dictionary]: dictionary object with 'type':string and 'value':string pairs
19
+ class IssuingTokenActivation < StarkCore::Utils::SubResource
20
+ attr_reader :card_id, :token_id, :tags, :activation_method
21
+ def initialize(card_id: nil, token_id: nil, tags: nil, activation_method: nil)
22
+ @card_id = card_id
23
+ @token_id = token_id
24
+ @tags = tags
25
+ @activation_method = activation_method
26
+ end
27
+
28
+ # # Create a single verified IssuingTokenActivation request from a content string
29
+ #
30
+ # Use this method to parse and verify the authenticity of the request received at the informed endpoint.
31
+ # Activation requests are posted to your registered endpoint whenever IssuingTokenActivations are received.
32
+ # If the provided digital signature does not check out with the StarkInfra public key, a
33
+ # StarkInfra::Error::InvalidSignatureError will be raised.
34
+ #
35
+ # ## Parameters (required):
36
+ # - content [string]: response content from request received at user endpoint (not parsed)
37
+ # - signature [string]: base-64 digital signature received at response header 'Digital-Signature'
38
+ #
39
+ # ## Parameters (optional):
40
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
41
+ #
42
+ # ## Return:
43
+ # - Parsed IssuingTokenActivation object
44
+ def self.parse(content:, signature:, user: nil)
45
+ StarkInfra::Utils::Parse.parse_and_verify(content: content, signature: signature, user: user, resource: resource, key: nil)
46
+ end
47
+
48
+ def self.resource
49
+ {
50
+ resource_name: 'IssuingTokenActivation',
51
+ resource_maker: proc { |json|
52
+ IssuingTokenActivation.new(
53
+ card_id: json['card_id'],
54
+ token_id: json['token_id'],
55
+ tags: json['tags'],
56
+ activation_method: json['activation_method']
57
+ )
58
+ }
59
+ }
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+
6
+ module StarkInfra
7
+ # # IssuingTokenDesign object
8
+ #
9
+ # The IssuingTokenDesign object displays the information of the token designs created in your Workspace.
10
+ # This resource represents the existent designs for the cards which will be tokenized.
11
+ #
12
+ # ## Attributes (return-only):
13
+ # - id [string]: unique id returned when IssuingTokenDesign is created. ex: '5656565656565656'
14
+ # - name [string]: Design name. ex: 'Stark Bank - White Metal'
15
+ # - created [DateTime]: creation datetime for the IssuingTokenDesign. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
16
+ # - updated [DateTime]: latest update datetime for the IssuingTokenDesign. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
17
+ class IssuingTokenDesign < StarkCore::Utils::Resource
18
+ attr_reader :id, :name, :created, :updated
19
+ def initialize(
20
+ id: nil, name: nil, created: nil, updated: nil
21
+ )
22
+ super(id)
23
+ @name = name
24
+ @created = StarkCore::Utils::Checks.check_datetime(created)
25
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
26
+ end
27
+
28
+ # # Retrieve a specific IssuingTokenDesign
29
+ #
30
+ # Receive a single IssuingTokenDesign object previously created in the Stark Infra API by its id
31
+ #
32
+ # ## Parameters (required):
33
+ # - id [string]: object unique id. ex: '5656565656565656'
34
+ #
35
+ # ## Parameters (optional):
36
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
37
+ #
38
+ # ## Return:
39
+ # - IssuingTokenDesign object with updated attributes
40
+ def self.get(id, user: nil)
41
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
42
+ end
43
+
44
+ # # Retrieve IssuingTokenDesigns
45
+ #
46
+ # Receive a generator of IssuingTokenDesign objects previously created in the Stark Infra API
47
+ #
48
+ # ## Parameters (optional):
49
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
50
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
51
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
52
+ #
53
+ # ## Return:
54
+ # - generator of IssuingTokenDesign objects with updated attributes
55
+ def self.query(limit: nil, ids: nil, user: nil)
56
+ StarkInfra::Utils::Rest.get_stream(
57
+ limit: limit,
58
+ ids: ids,
59
+ user: user,
60
+ **resource
61
+ )
62
+ end
63
+
64
+ # # Retrieve paged IssuingTokenDesigns
65
+ #
66
+ # Receive a list of up to 100 IssuingTokenDesign objects previously created in the Stark Infra API and the cursor to the next page.
67
+ # Use this function instead of query if you want to manually page your requests.
68
+ #
69
+ # ## Parameters (optional):
70
+ # - cursor [string, default nil]: cursor returned on the previous page function call.
71
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
72
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
73
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
74
+ #
75
+ # ## Return:
76
+ # - list of IssuingTokenDesign objects with updated attributes
77
+ # - cursor to retrieve the next page of IssuingTokenDesign objects
78
+ def self.page(cursor: nil, limit: nil, ids: nil, user: nil)
79
+ StarkInfra::Utils::Rest.get_page(
80
+ cursor: cursor,
81
+ limit: limit,
82
+ ids: ids,
83
+ user: user,
84
+ **resource
85
+ )
86
+ end
87
+
88
+ # # Retrieve a specific IssuingTokenDesign pdf file
89
+ #
90
+ # Receive a single IssuingTokenDesign pdf file generated in the Stark Infra API by its id.
91
+ #
92
+ # ## Parameters (required):
93
+ # - id [string]: object unique id. ex: '5656565656565656'
94
+ #
95
+ # ## Parameters (optional):
96
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
97
+ #
98
+ # ## Return:
99
+ # - IssuingTokenDesign pdf file
100
+ def self.pdf(id, user: nil)
101
+ StarkInfra::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'pdf', **resource)
102
+ end
103
+
104
+ def self.resource
105
+ {
106
+ resource_name: 'IssuingTokenDesign',
107
+ resource_maker: proc { |json|
108
+ IssuingTokenDesign.new(
109
+ id: json['id'],
110
+ name: json['name'],
111
+ created: json['created'],
112
+ updated: json['updated']
113
+ )
114
+ }
115
+ }
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+
6
+ module StarkInfra
7
+ # # IssuingTokenRequest object
8
+ #
9
+ # The IssuingTokenRequest object displays the necessary information to proceed with the card tokenization.
10
+ #
11
+ # ## Parameters (required):
12
+ # - card_id [string]: card id to be tokenized. ex: '5734340247945216'
13
+ # - wallet_id [string]: desired wallet to be integrated. Options: 'apple', 'google', 'merchant'.
14
+ # - method_code [string]: method code. ex: 'app' or 'manual'
15
+ #
16
+ # ## Attributes (return-only):
17
+ # - content [string]: token request content. ex: 'eyJwdWJsaWNLZXlGaW5nZXJwcmludCI6ICJlNTNiZThjZTRhYWQxNWU2OWNmMjExOTA5Mjk4YzJkOTE0O...'
18
+ # - signature [string]: token request signature. ex: 'eyJwdWJsaWNLZXlGaW5nZXJwcmludCI6ICJlNTNiZThjZTRhYWQxNWU2OWNmMjExOTA5Mjk4YzJkOTE0O...'
19
+ # - metadata [hash]: hash object used to store additional information about the IssuingTokenRequest object.
20
+ class IssuingTokenRequest < StarkCore::Utils::SubResource
21
+ attr_reader :card_id, :wallet_id, :method_code, :content, :signature, :metadata
22
+ def initialize(card_id:, wallet_id:, method_code:, content: nil, signature: nil, metadata: nil)
23
+ @card_id = card_id
24
+ @wallet_id = wallet_id
25
+ @method_code = method_code
26
+ @content = content
27
+ @signature = signature
28
+ @metadata = metadata
29
+ end
30
+
31
+ # # Create an IssuingTokenRequest object
32
+ #
33
+ # Send an IssuingTokenRequest object to Stark Infra API to create the payload to proceed with the card tokenization
34
+ #
35
+ # ## Parameters (required):
36
+ # - request [IssuingTokenRequest object]: IssuingTokenRequest object to the API to generate the payload
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
+ # - IssuingTokenRequest object with updated attributes
43
+ def self.create(request, user: nil)
44
+ StarkInfra::Utils::Rest.post_single(entity: request, user: user, **resource)
45
+ end
46
+
47
+ def self.resource
48
+ {
49
+ resource_name: 'IssuingTokenRequest',
50
+ resource_maker: proc { |json|
51
+ IssuingTokenRequest.new(
52
+ card_id: json['card_id'],
53
+ wallet_id: json['wallet_id'],
54
+ method_code: json['method_code'],
55
+ content: json['content'],
56
+ signature: json['signature'],
57
+ metadata: json['metadata']
58
+ )
59
+ }
60
+ }
61
+ end
62
+ end
63
+ end