starkinfra 0.5.0 → 0.6.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 (89) hide show
  1. checksums.yaml +4 -4
  2. data/lib/{brcodepreview/brcodepreview.rb → brcode_preview/brcode_preview.rb} +5 -2
  3. data/lib/brcode_preview/subscription.rb +102 -0
  4. data/lib/business_attachment/business_attachment.rb +186 -0
  5. data/lib/business_attachment/log.rb +127 -0
  6. data/lib/business_identity/business_identity.rb +225 -0
  7. data/lib/business_identity/log.rb +127 -0
  8. data/lib/{creditnote/creditnote.rb → credit_note/credit_note.rb} +11 -5
  9. data/lib/{creditnote → credit_note}/log.rb +1 -1
  10. data/lib/credit_note/rule.rb +46 -0
  11. data/lib/event/event.rb +10 -2
  12. data/lib/{individualdocument → individual_document}/log.rb +1 -1
  13. data/lib/{individualidentity → individual_identity}/log.rb +1 -1
  14. data/lib/{issuingbalance/issuingbalance.rb → issuing_balance/issuing_balance.rb} +8 -2
  15. data/lib/issuing_billing_invoice/issuing_billing_invoice.rb +155 -0
  16. data/lib/issuing_billing_transaction/issuing_billing_transaction.rb +142 -0
  17. data/lib/{issuingcard/issuingcard.rb → issuing_card/issuing_card.rb} +5 -2
  18. data/lib/{issuingcard → issuing_card}/log.rb +1 -1
  19. data/lib/{issuingembossingrequest → issuing_embossing_request}/log.rb +1 -1
  20. data/lib/{issuingholder → issuing_holder}/log.rb +1 -1
  21. data/lib/{issuinginvoice → issuing_invoice}/log.rb +1 -1
  22. data/lib/{issuingproduct/issuingproduct.rb → issuing_product/issuing_product.rb} +5 -2
  23. data/lib/{issuingpurchase/issuingpurchase.rb → issuing_purchase/issuing_purchase.rb} +18 -9
  24. data/lib/{issuingpurchase → issuing_purchase}/log.rb +1 -1
  25. data/lib/{issuingrestock → issuing_restock}/log.rb +1 -1
  26. data/lib/{issuingrule/issuingrule.rb → issuing_rule/issuing_rule.rb} +9 -3
  27. data/lib/{issuingstock/issuingstock.rb → issuing_stock/issuing_stock.rb} +5 -2
  28. data/lib/{issuingstock → issuing_stock}/log.rb +1 -1
  29. data/lib/issuing_stock_rule/issuing_stock_rule.rb +213 -0
  30. data/lib/issuing_token/issuing_token.rb +309 -0
  31. data/lib/issuing_token_design/issuing_token_design.rb +118 -0
  32. data/lib/issuing_token_request/issuing_token_request.rb +63 -0
  33. data/lib/{merchantcategory/merchantcategory.rb → merchant_category/merchant_category.rb} +6 -3
  34. data/lib/{pixchargeback → pix_chargeback}/log.rb +1 -1
  35. data/lib/{pixchargeback/pixchargeback.rb → pix_chargeback/pix_chargeback.rb} +26 -2
  36. data/lib/{pixclaim → pix_claim}/log.rb +1 -1
  37. data/lib/pix_dispute/log.rb +127 -0
  38. data/lib/pix_dispute/pix_dispute.rb +210 -0
  39. data/lib/pix_dispute/transaction.rb +91 -0
  40. data/lib/pix_fraud/log.rb +128 -0
  41. data/lib/pix_fraud/pix_fraud.rb +180 -0
  42. data/lib/{pixinfraction → pix_infraction}/log.rb +1 -1
  43. data/lib/{pixinfraction/pixinfraction.rb → pix_infraction/pix_infraction.rb} +18 -4
  44. data/lib/pix_internal_transaction_report/log.rb +129 -0
  45. data/lib/pix_internal_transaction_report/pix_internal_transaction_report.rb +200 -0
  46. data/lib/{pixkey → pix_key}/log.rb +1 -1
  47. data/lib/pix_key_holmes/pix_key_holmes.rb +139 -0
  48. data/lib/pix_pull_request/log.rb +127 -0
  49. data/lib/pix_pull_request/pix_pull_request.rb +265 -0
  50. data/lib/pix_pull_subscription/log.rb +127 -0
  51. data/lib/pix_pull_subscription/pix_pull_subscription.rb +281 -0
  52. data/lib/{pixrequest → pix_request}/log.rb +1 -1
  53. data/lib/{pixrequest/pixrequest.rb → pix_request/pix_request.rb} +9 -2
  54. data/lib/{pixreversal → pix_reversal}/log.rb +1 -1
  55. data/lib/starkinfra.rb +83 -59
  56. data/lib/utils/parse.rb +2 -2
  57. data/lib/utils/return_id.rb +24 -0
  58. data/lib/webhook/webhook.rb +2 -2
  59. metadata +87 -67
  60. /data/lib/{cardmethod/cardmethod.rb → card_method/card_method.rb} +0 -0
  61. /data/lib/{creditholmes/creditholmes.rb → credit_holmes/credit_holmes.rb} +0 -0
  62. /data/lib/{creditnote → credit_note}/invoice/description.rb +0 -0
  63. /data/lib/{creditnote → credit_note}/invoice/discount.rb +0 -0
  64. /data/lib/{creditnote → credit_note}/invoice/invoice.rb +0 -0
  65. /data/lib/{creditnote → credit_note}/transfer.rb +0 -0
  66. /data/lib/{creditpreview/creditnotepreview.rb → credit_preview/credit_note_preview.rb} +0 -0
  67. /data/lib/{creditpreview/creditpreview.rb → credit_preview/credit_preview.rb} +0 -0
  68. /data/lib/{creditsigner/creditsigner.rb → credit_signer/credit_signer.rb} +0 -0
  69. /data/lib/{dynamicbrcode/dynamicbrcode.rb → dynamic_brcode/dynamic_brcode.rb} +0 -0
  70. /data/lib/{individualdocument/individualdocument.rb → individual_document/individual_document.rb} +0 -0
  71. /data/lib/{individualidentity/individualidentity.rb → individual_identity/individual_identity.rb} +0 -0
  72. /data/lib/{issuingdesign/issuingdesign.rb → issuing_design/issuing_design.rb} +0 -0
  73. /data/lib/{issuingembossingkit/issuingembossingkit.rb → issuing_embossing_kit/issuing_embossing_kit.rb} +0 -0
  74. /data/lib/{issuingembossingrequest/issuingembossingrequest.rb → issuing_embossing_request/issuing_embossing_request.rb} +0 -0
  75. /data/lib/{issuingholder/issuingholder.rb → issuing_holder/issuing_holder.rb} +0 -0
  76. /data/lib/{issuinginvoice/issuinginvoice.rb → issuing_invoice/issuing_invoice.rb} +0 -0
  77. /data/lib/{issuingrestock/issuingrestock.rb → issuing_restock/issuing_restock.rb} +0 -0
  78. /data/lib/{issuingtransaction/issuingtransaction.rb → issuing_transaction/issuing_transaction.rb} +0 -0
  79. /data/lib/{issuingwithdrawal/issuingwithdrawal.rb → issuing_withdrawal/issuing_withdrawal.rb} +0 -0
  80. /data/lib/{merchantcountry/merchantcountry.rb → merchant_country/merchant_country.rb} +0 -0
  81. /data/lib/{pixbalance/pixbalance.rb → pix_balance/pix_balance.rb} +0 -0
  82. /data/lib/{pixclaim/pixclaim.rb → pix_claim/pix_claim.rb} +0 -0
  83. /data/lib/{pixdirector/pixdirector.rb → pix_director/pix_director.rb} +0 -0
  84. /data/lib/{pixdomain → pix_domain}/certificate.rb +0 -0
  85. /data/lib/{pixdomain/pixdomain.rb → pix_domain/pix_domain.rb} +0 -0
  86. /data/lib/{pixkey/pixkey.rb → pix_key/pix_key.rb} +0 -0
  87. /data/lib/{pixreversal/pixreversal.rb → pix_reversal/pix_reversal.rb} +0 -0
  88. /data/lib/{pixstatement/pixstatement.rb → pix_statement/pix_statement.rb} +0 -0
  89. /data/lib/{staticbrcode/staticbrcode.rb → static_brcode/static_brcode.rb} +0 -0
@@ -0,0 +1,213 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+
6
+ module StarkInfra
7
+ # # IssuingStockRule object
8
+ #
9
+ # The IssuingStockRule object displays the notification rules attached to an IssuingStock.
10
+ # When the linked stock balance reaches the minimum_balance, the recipients listed in
11
+ # emails and phones are notified.
12
+ #
13
+ # ## Parameters (required):
14
+ # - minimum_balance [integer]: stock balance threshold that triggers a notification. ex: 10000
15
+ # - stock_id [string]: IssuingStock unique id the rule is linked to. ex: '5136459887542272'
16
+ #
17
+ # ## Parameters (optional):
18
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ['card', 'corporate']
19
+ # - emails [list of strings, default nil]: emails notified when the stock reaches the minimum balance. ex: ['john.doe@enterprise.com']
20
+ # - phones [list of strings, default nil]: phones notified when the stock reaches the minimum balance. ex: ['+5511912345678']
21
+ #
22
+ # ## Attributes (return-only):
23
+ # - id [string]: unique id returned when IssuingStockRule is created. ex: '5664445921492992'
24
+ # - status [string]: current IssuingStockRule status. ex: 'active', 'canceled'
25
+ # - created [DateTime]: creation datetime for the IssuingStockRule. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
26
+ # - updated [DateTime]: latest update datetime for the IssuingStockRule. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
27
+ class IssuingStockRule < StarkCore::Utils::Resource
28
+ attr_reader :minimum_balance, :stock_id, :tags, :emails, :phones, :id, :status, :created, :updated
29
+ def initialize(
30
+ minimum_balance:, stock_id:, tags: nil, emails: nil, phones: nil,
31
+ id: nil, status: nil, created: nil, updated: nil
32
+ )
33
+ super(id)
34
+ @minimum_balance = minimum_balance
35
+ @stock_id = stock_id
36
+ @tags = tags
37
+ @emails = emails
38
+ @phones = phones
39
+ @status = status
40
+ @created = StarkCore::Utils::Checks.check_datetime(created)
41
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
42
+ end
43
+
44
+ # # Create IssuingStockRules
45
+ #
46
+ # Send a list of IssuingStockRule objects for creation in the Stark Infra API
47
+ #
48
+ # ## Parameters (required):
49
+ # - rules [list of IssuingStockRule objects]: list of IssuingStockRule objects to be created in the API
50
+ #
51
+ # ## Parameters (optional):
52
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
53
+ #
54
+ # ## Return:
55
+ # - list of IssuingStockRule objects with updated attributes
56
+ def self.create(rules:, user: nil)
57
+ StarkInfra::Utils::Rest.post(entities: rules, user: user, **resource)
58
+ end
59
+
60
+ # # Retrieve a specific IssuingStockRule
61
+ #
62
+ # Receive a single IssuingStockRule object previously created in the Stark Infra API by its id
63
+ #
64
+ # ## Parameters (required):
65
+ # - id [string]: object unique id. ex: '5664445921492992'
66
+ #
67
+ # ## Parameters (optional):
68
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
69
+ #
70
+ # ## Return:
71
+ # - IssuingStockRule object with updated attributes
72
+ def self.get(id, user: nil)
73
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
74
+ end
75
+
76
+ # # Retrieve IssuingStockRules
77
+ #
78
+ # Receive a generator of IssuingStockRule objects previously created in the Stark Infra API
79
+ #
80
+ # ## Parameters (optional):
81
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
82
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
83
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
84
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['active', 'canceled']
85
+ # - stock_ids [list of strings, default nil]: list of stock_ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
86
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
87
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['card', 'corporate']
88
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
89
+ #
90
+ # ## Return:
91
+ # - generator of IssuingStockRule objects with updated attributes
92
+ def self.query(
93
+ limit: nil, after: nil, before: nil, status: nil, stock_ids: nil,
94
+ ids: nil, tags: nil, user: nil
95
+ )
96
+ after = StarkCore::Utils::Checks.check_date(after)
97
+ before = StarkCore::Utils::Checks.check_date(before)
98
+ StarkInfra::Utils::Rest.get_stream(
99
+ limit: limit,
100
+ after: after,
101
+ before: before,
102
+ status: status,
103
+ stock_ids: stock_ids,
104
+ ids: ids,
105
+ tags: tags,
106
+ user: user,
107
+ **resource
108
+ )
109
+ end
110
+
111
+ # # Retrieve paged IssuingStockRules
112
+ #
113
+ # Receive a list of up to 100 IssuingStockRule objects previously created in the Stark Infra API and the cursor to the next page.
114
+ # Use this function instead of query if you want to manually page your requests.
115
+ #
116
+ # ## Parameters (optional):
117
+ # - cursor [string, default nil]: cursor returned on the previous page function call.
118
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
119
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
120
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
121
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['active', 'canceled']
122
+ # - stock_ids [list of strings, default nil]: list of stock_ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
123
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
124
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['card', 'corporate']
125
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
126
+ #
127
+ # ## Return:
128
+ # - list of IssuingStockRule objects with updated attributes
129
+ # - cursor to retrieve the next page of IssuingStockRule objects
130
+ def self.page(
131
+ cursor: nil, limit: nil, after: nil, before: nil, status: nil, stock_ids: nil,
132
+ ids: nil, tags: nil, user: nil
133
+ )
134
+ after = StarkCore::Utils::Checks.check_date(after)
135
+ before = StarkCore::Utils::Checks.check_date(before)
136
+ StarkInfra::Utils::Rest.get_page(
137
+ cursor: cursor,
138
+ limit: limit,
139
+ after: after,
140
+ before: before,
141
+ status: status,
142
+ stock_ids: stock_ids,
143
+ ids: ids,
144
+ tags: tags,
145
+ user: user,
146
+ **resource
147
+ )
148
+ end
149
+
150
+ # # Update IssuingStockRule entity
151
+ #
152
+ # Update an IssuingStockRule by passing id.
153
+ #
154
+ # ## Parameters (required):
155
+ # - id [string]: IssuingStockRule unique id. ex: '5664445921492992'
156
+ #
157
+ # ## Parameters (optional):
158
+ # - minimum_balance [integer, default nil]: new stock balance threshold that triggers a notification. ex: 20000
159
+ # - tags [list of strings, default nil]: new list of strings for tagging. ex: ['card', 'corporate']
160
+ # - emails [list of strings, default nil]: new list of emails notified when the stock reaches the minimum balance. ex: ['john.doe@enterprise.com']
161
+ # - phones [list of strings, default nil]: new list of phones notified when the stock reaches the minimum balance. ex: ['+5511912345678']
162
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
163
+ #
164
+ # ## Return:
165
+ # - target IssuingStockRule with updated attributes
166
+ def self.update(id, minimum_balance: nil, tags: nil, emails: nil, phones: nil, user: nil)
167
+ StarkInfra::Utils::Rest.patch_id(
168
+ id: id,
169
+ minimum_balance: minimum_balance,
170
+ tags: tags,
171
+ emails: emails,
172
+ phones: phones,
173
+ user: user,
174
+ **resource
175
+ )
176
+ end
177
+
178
+ # # Cancel an IssuingStockRule entity
179
+ #
180
+ # Cancel an IssuingStockRule entity previously created in the Stark Infra API
181
+ #
182
+ # ## Parameters (required):
183
+ # - id [string]: IssuingStockRule unique id. ex: '5664445921492992'
184
+ #
185
+ # ## Parameters (optional):
186
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
187
+ #
188
+ # ## Return:
189
+ # - canceled IssuingStockRule object
190
+ def self.cancel(id, user: nil)
191
+ StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
192
+ end
193
+
194
+ def self.resource
195
+ {
196
+ resource_name: 'IssuingStockRule',
197
+ resource_maker: proc { |json|
198
+ IssuingStockRule.new(
199
+ minimum_balance: json['minimum_balance'],
200
+ stock_id: json['stock_id'],
201
+ tags: json['tags'],
202
+ emails: json['emails'],
203
+ phones: json['phones'],
204
+ id: json['id'],
205
+ status: json['status'],
206
+ created: json['created'],
207
+ updated: json['updated']
208
+ )
209
+ }
210
+ }
211
+ end
212
+ end
213
+ end
@@ -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. ex: 'active', 'blocked', 'canceled', 'frozen' or 'pending'
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
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,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