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.
- checksums.yaml +4 -4
- data/lib/brcode_preview/brcode_preview.rb +25 -4
- data/lib/brcode_preview/subscription.rb +102 -0
- data/lib/business_account_request/business_account_request.rb +276 -0
- data/lib/business_account_request/log.rb +124 -0
- data/lib/business_attachment/business_attachment.rb +189 -0
- data/lib/{individual_document → business_attachment}/log.rb +35 -32
- data/lib/business_identity/business_identity.rb +228 -0
- data/lib/business_identity/log.rb +127 -0
- data/lib/credit_holmes/credit_holmes.rb +2 -1
- data/lib/credit_holmes/log.rb +125 -0
- data/lib/credit_note/credit_note.rb +51 -8
- data/lib/credit_note/rule.rb +55 -0
- data/lib/credit_note/transfer.rb +1 -1
- data/lib/credit_preview/credit_note_preview.rb +10 -2
- data/lib/credit_preview/credit_preview.rb +2 -1
- data/lib/credit_signer/credit_signer.rb +27 -2
- data/lib/dynamic_brcode/dynamic_brcode.rb +5 -2
- data/lib/event/event.rb +10 -2
- data/lib/individual_account_attachment/individual_account_attachment.rb +178 -0
- data/lib/individual_account_attachment/log.rb +124 -0
- data/lib/individual_account_request/individual_account_request.rb +271 -0
- data/lib/individual_account_request/log.rb +124 -0
- data/lib/individual_identity/individual_identity.rb +4 -7
- data/lib/issuing_balance/issuing_balance.rb +8 -2
- data/lib/issuing_billing_invoice/issuing_billing_invoice.rb +155 -0
- data/lib/issuing_billing_transaction/issuing_billing_transaction.rb +142 -0
- data/lib/issuing_card/issuing_card.rb +10 -6
- data/lib/issuing_design/issuing_design.rb +9 -0
- data/lib/issuing_embossing_request/issuing_embossing_request.rb +3 -2
- data/lib/issuing_holder/issuing_holder.rb +6 -5
- data/lib/issuing_product/issuing_product.rb +6 -3
- data/lib/issuing_purchase/issuing_purchase.rb +41 -8
- data/lib/issuing_restock/issuing_restock.rb +3 -2
- data/lib/issuing_rule/issuing_rule.rb +45 -3
- data/lib/issuing_stock/issuing_stock.rb +5 -2
- data/lib/issuing_stock_rule/issuing_stock_rule.rb +214 -0
- data/lib/issuing_token/issuing_token.rb +309 -0
- data/lib/issuing_token/log.rb +127 -0
- data/lib/issuing_token_activation/issuing_token_activation.rb +62 -0
- data/lib/issuing_token_design/issuing_token_design.rb +118 -0
- data/lib/issuing_token_request/issuing_token_request.rb +63 -0
- data/lib/issuing_withdrawal/issuing_withdrawal.rb +2 -2
- data/lib/ledger/ledger.rb +175 -0
- data/lib/ledger/log.rb +122 -0
- data/lib/ledger/rule.rb +55 -0
- data/lib/ledger_transaction/ledger_transaction.rb +179 -0
- data/lib/merchant_category/merchant_category.rb +6 -3
- data/lib/pix_balance/pix_balance.rb +1 -1
- data/lib/pix_chargeback/pix_chargeback.rb +34 -7
- data/lib/pix_claim/pix_claim.rb +14 -6
- data/lib/pix_director/pix_director.rb +1 -1
- data/lib/pix_dispute/log.rb +127 -0
- data/lib/pix_dispute/pix_dispute.rb +210 -0
- data/lib/pix_dispute/transaction.rb +91 -0
- data/lib/pix_fraud/log.rb +128 -0
- data/lib/pix_fraud/pix_fraud.rb +180 -0
- data/lib/pix_infraction/pix_infraction.rb +37 -7
- data/lib/pix_internal_transaction_report/log.rb +129 -0
- data/lib/pix_internal_transaction_report/pix_internal_transaction_report.rb +200 -0
- data/lib/pix_key/pix_key.rb +1 -1
- data/lib/pix_key_holmes/log.rb +129 -0
- data/lib/{individual_document/individual_document.rb → pix_key_holmes/pix_key_holmes.rb} +48 -56
- data/lib/pix_pull_request/log.rb +127 -0
- data/lib/pix_pull_request/pix_pull_request.rb +268 -0
- data/lib/pix_pull_subscription/log.rb +127 -0
- data/lib/pix_pull_subscription/pix_pull_subscription.rb +307 -0
- data/lib/pix_request/pix_request.rb +19 -6
- data/lib/pix_reversal/pix_reversal.rb +14 -8
- data/lib/pix_statement/pix_statement.rb +11 -5
- data/lib/pix_user/pix_user.rb +52 -0
- data/lib/pix_user/statistics.rb +64 -0
- data/lib/starkinfra.rb +45 -4
- data/lib/static_brcode/static_brcode.rb +8 -4
- data/lib/utils/bacen_id.rb +27 -0
- data/lib/utils/end_to_end_id.rb +20 -0
- data/lib/utils/pix_subscription_bacen_id.rb +21 -0
- data/lib/utils/return_id.rb +21 -0
- data/lib/webhook/webhook.rb +3 -3
- metadata +48 -11
|
@@ -12,18 +12,20 @@ module StarkInfra
|
|
|
12
12
|
# ## Attributes (return-only):
|
|
13
13
|
# - id [string]: unique card product number (BIN) registered within the card network. ex: '53810200'
|
|
14
14
|
# - network [string]: card network flag. ex: 'mastercard'
|
|
15
|
-
# - funding_type [string]: type of funding used for payment.
|
|
15
|
+
# - funding_type [string]: type of funding used for payment. Options: 'prepaid', 'credit'.
|
|
16
16
|
# - holder_type [string]: holder type. ex: 'business', 'individual'
|
|
17
17
|
# - code [string]: internal code from card flag informing the product. ex: 'MRW', 'MCO', 'MWB', 'MCS'
|
|
18
|
+
# - customer_type [string]: same as holder_type. Kept for backward compatibility.
|
|
18
19
|
# - created [DateTime]: creation datetime for the IssuingProduct. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
19
20
|
class IssuingProduct < StarkCore::Utils::Resource
|
|
20
|
-
attr_reader :id, :network, :funding_type, :holder_type, :code, :created
|
|
21
|
-
def initialize(id: nil, network: nil, funding_type: nil, holder_type: nil, code: nil, created: nil)
|
|
21
|
+
attr_reader :id, :network, :funding_type, :holder_type, :code, :customer_type, :created
|
|
22
|
+
def initialize(id: nil, network: nil, funding_type: nil, holder_type: nil, code: nil, customer_type: nil, created: nil)
|
|
22
23
|
super(id)
|
|
23
24
|
@network = network
|
|
24
25
|
@funding_type = funding_type
|
|
25
26
|
@holder_type = holder_type
|
|
26
27
|
@code = code
|
|
28
|
+
@customer_type = customer_type
|
|
27
29
|
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
28
30
|
end
|
|
29
31
|
|
|
@@ -76,6 +78,7 @@ module StarkInfra
|
|
|
76
78
|
funding_type: json['funding_type'],
|
|
77
79
|
holder_type: json['holder_type'],
|
|
78
80
|
code: json['code'],
|
|
81
|
+
customer_type: json['customer_type'],
|
|
79
82
|
created: json['created']
|
|
80
83
|
)
|
|
81
84
|
}
|
|
@@ -13,7 +13,8 @@ module StarkInfra
|
|
|
13
13
|
# - product_id [string]: unique card product number (BIN) registered within the card network. ex: "53810200"
|
|
14
14
|
# - card_id [string]: unique id returned when IssuingCard is created. ex: '5656565656565656'
|
|
15
15
|
# - card_ending [string]: last 4 digits of the card number. ex: '1234'
|
|
16
|
-
# - purpose [string]: purchase purpose.
|
|
16
|
+
# - purpose [string]: purchase purpose. Options: 'purchase', 'withdrawal', 'verification', 'purchaseRefund', 'cashbackPurchase', 'paymentTransaction'.
|
|
17
|
+
# - installment_count [integer]: quantity of installments to be confirmed. Minimum = 1. ex: 12
|
|
17
18
|
# - amount [integer]: IssuingPurchase value in cents. Minimum = 0. ex: 1234 (= R$ 12.34)
|
|
18
19
|
# - tax [integer]: IOF amount taxed for international purchases. ex: 1234 (= R$ 12.34)
|
|
19
20
|
# - issuer_amount [integer]: issuer amount. ex: 1234 (= R$ 12.34)
|
|
@@ -24,6 +25,7 @@ module StarkInfra
|
|
|
24
25
|
# - merchant_category_type [string]: merchant category type. ex 'food'
|
|
25
26
|
# - merchant_currency_symbol [string]: merchant currency symbol. ex: '$'
|
|
26
27
|
# - merchant_category_code [string]: merchant category code. ex: 'fastFoodRestaurants'
|
|
28
|
+
# - merchant_category_number [integer]: MCC number of the merchant category. ex: 5814
|
|
27
29
|
# - merchant_country_code [string]: merchant country code. ex: 'USA'
|
|
28
30
|
# - acquirer_id [string]: acquirer ID. ex: '5656565656565656'
|
|
29
31
|
# - merchant_id [string]: merchant ID. ex: '5656565656565656'
|
|
@@ -39,6 +41,7 @@ module StarkInfra
|
|
|
39
41
|
# - id [string]: unique id returned when IssuingPurchase is created. ex: '5656565656565656'
|
|
40
42
|
# - issuing_transaction_ids [string]: ledger transaction ids linked to this Purchase
|
|
41
43
|
# - status [string]: current IssuingCard status. Options: 'approved', 'canceled', 'denied', 'confirmed', 'voided'
|
|
44
|
+
# - confirmed [DateTime]: Confirmation datetime. Null until the purchase is confirmed. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
42
45
|
# - description [string]: IssuingPurchase description. ex: 'Office Supplies'
|
|
43
46
|
# - metadata [dictionary object]: dictionary object used to store additional information about the IssuingPurchase object. ex: { authorizationId: 'OjZAqj' }
|
|
44
47
|
# - zip_code [string]: zip code of the merchant location. ex: '02101234'
|
|
@@ -51,18 +54,18 @@ module StarkInfra
|
|
|
51
54
|
# - holder_id [string]: card holder ID. ex: '5656565656565656'
|
|
52
55
|
# - holder_tags [list of strings]: tags of the IssuingHolder responsible for this purchase. ex: ['technology', 'john snow']
|
|
53
56
|
class IssuingPurchase < StarkCore::Utils::Resource
|
|
54
|
-
attr_reader :id, :holder_name, :product_id, :card_id, :card_ending, :purpose, :amount, :tax, :issuer_amount, :issuer_currency_code,
|
|
57
|
+
attr_reader :id, :holder_name, :product_id, :card_id, :card_ending, :purpose, :installment_count, :amount, :tax, :issuer_amount, :issuer_currency_code,
|
|
55
58
|
:issuer_currency_symbol, :merchant_amount, :merchant_currency_code, :merchant_currency_symbol,
|
|
56
|
-
:merchant_category_code, :merchant_category_type, :merchant_country_code, :acquirer_id, :merchant_id, :merchant_name,
|
|
59
|
+
:merchant_category_code, :merchant_category_number, :merchant_category_type, :merchant_country_code, :acquirer_id, :merchant_id, :merchant_name,
|
|
57
60
|
:merchant_fee, :wallet_id, :method_code, :score, :end_to_end_id, :tags,
|
|
58
|
-
:issuing_transaction_ids, :status, :description, :metadata, :zip_code, :updated, :created, :is_partial_allowed, :card_tags, :holder_id, :holder_tags
|
|
61
|
+
:issuing_transaction_ids, :status, :confirmed, :description, :metadata, :zip_code, :updated, :created, :is_partial_allowed, :card_tags, :holder_id, :holder_tags
|
|
59
62
|
|
|
60
63
|
def initialize(
|
|
61
|
-
id: nil, holder_name: nil, product_id: nil, card_id: nil, card_ending: nil, purpose: nil, amount: nil, tax: nil, issuer_amount: nil,
|
|
64
|
+
id: nil, holder_name: nil, product_id: nil, card_id: nil, card_ending: nil, purpose: nil, installment_count: nil, amount: nil, tax: nil, issuer_amount: nil,
|
|
62
65
|
issuer_currency_code: nil, issuer_currency_symbol: nil, merchant_amount: nil, merchant_currency_code: nil,
|
|
63
|
-
merchant_currency_symbol: nil, merchant_category_code: nil, merchant_category_type: nil, merchant_country_code: nil, acquirer_id: nil,
|
|
66
|
+
merchant_currency_symbol: nil, merchant_category_code: nil, merchant_category_number: nil, merchant_category_type: nil, merchant_country_code: nil, acquirer_id: nil,
|
|
64
67
|
merchant_id: nil, merchant_name: nil, merchant_fee: nil, wallet_id: nil, method_code: nil, score: nil,
|
|
65
|
-
end_to_end_id: nil, tags: nil, issuing_transaction_ids: nil, status: nil, description: nil, metadata: nil, zip_code: nil, updated: nil, created: nil,
|
|
68
|
+
end_to_end_id: nil, tags: nil, issuing_transaction_ids: nil, status: nil, confirmed: nil, description: nil, metadata: nil, zip_code: nil, updated: nil, created: nil,
|
|
66
69
|
is_partial_allowed: nil, card_tags:nil, holder_id: nil, holder_tags:nil
|
|
67
70
|
)
|
|
68
71
|
super(id)
|
|
@@ -71,6 +74,7 @@ module StarkInfra
|
|
|
71
74
|
@card_id = card_id
|
|
72
75
|
@card_ending = card_ending
|
|
73
76
|
@purpose = purpose
|
|
77
|
+
@installment_count = installment_count
|
|
74
78
|
@amount = amount
|
|
75
79
|
@tax = tax
|
|
76
80
|
@issuer_amount = issuer_amount
|
|
@@ -80,6 +84,7 @@ module StarkInfra
|
|
|
80
84
|
@merchant_currency_code = merchant_currency_code
|
|
81
85
|
@merchant_currency_symbol = merchant_currency_symbol
|
|
82
86
|
@merchant_category_code = merchant_category_code
|
|
87
|
+
@merchant_category_number = merchant_category_number
|
|
83
88
|
@merchant_category_type = merchant_category_type
|
|
84
89
|
@merchant_country_code = merchant_country_code
|
|
85
90
|
@acquirer_id = acquirer_id
|
|
@@ -93,6 +98,7 @@ module StarkInfra
|
|
|
93
98
|
@tags = tags
|
|
94
99
|
@issuing_transaction_ids = issuing_transaction_ids
|
|
95
100
|
@status = status
|
|
101
|
+
@confirmed = StarkCore::Utils::Checks.check_datetime(confirmed)
|
|
96
102
|
@description = description
|
|
97
103
|
@metadata = metadata
|
|
98
104
|
@zip_code = zip_code
|
|
@@ -195,6 +201,30 @@ module StarkInfra
|
|
|
195
201
|
)
|
|
196
202
|
end
|
|
197
203
|
|
|
204
|
+
# # Update IssuingPurchase entity
|
|
205
|
+
#
|
|
206
|
+
# Update an IssuingPurchase by passing id.
|
|
207
|
+
#
|
|
208
|
+
# ## Parameters (required):
|
|
209
|
+
# - id [string]: IssuingPurchase id. ex: '5656565656565656'
|
|
210
|
+
#
|
|
211
|
+
# ## Parameters (optional):
|
|
212
|
+
# - tags [list of strings, default nil]: list of strings for tagging. ex: ['tony', 'stark']
|
|
213
|
+
# - description [string, default nil]: new IssuingPurchase description. Max of 140 characters. ex: 'Office Supplies'
|
|
214
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
|
215
|
+
#
|
|
216
|
+
# ## Return:
|
|
217
|
+
# - target IssuingPurchase with updated attributes
|
|
218
|
+
def self.update(id, description: nil, tags: nil, user: nil)
|
|
219
|
+
StarkInfra::Utils::Rest.patch_id(
|
|
220
|
+
id: id,
|
|
221
|
+
description: description,
|
|
222
|
+
tags: tags,
|
|
223
|
+
user: user,
|
|
224
|
+
**resource
|
|
225
|
+
)
|
|
226
|
+
end
|
|
227
|
+
|
|
198
228
|
# # Create a single verified IssuingPurchase authorization request from a content string
|
|
199
229
|
#
|
|
200
230
|
# Use this method to parse and verify the authenticity of the authorization request received at the informed endpoint.
|
|
@@ -238,7 +268,7 @@ module StarkInfra
|
|
|
238
268
|
# ## Return:
|
|
239
269
|
# - Dumped JSON string that must be returned to us on the IssuingPurchase request
|
|
240
270
|
def self.response(
|
|
241
|
-
status:, reason
|
|
271
|
+
status:, reason: nil, amount: nil, tags: nil
|
|
242
272
|
)
|
|
243
273
|
params = {
|
|
244
274
|
'status': status,
|
|
@@ -261,6 +291,7 @@ module StarkInfra
|
|
|
261
291
|
card_id: json['card_id'],
|
|
262
292
|
card_ending: json['card_ending'],
|
|
263
293
|
purpose: json['purpose'],
|
|
294
|
+
installment_count: json['installment_count'],
|
|
264
295
|
amount: json['amount'],
|
|
265
296
|
tax: json['tax'],
|
|
266
297
|
issuer_amount: json['issuer_amount'],
|
|
@@ -270,6 +301,7 @@ module StarkInfra
|
|
|
270
301
|
merchant_currency_code: json['merchant_currency_code'],
|
|
271
302
|
merchant_currency_symbol: json['merchant_currency_symbol'],
|
|
272
303
|
merchant_category_code: json['merchant_category_code'],
|
|
304
|
+
merchant_category_number: json['merchant_category_number'],
|
|
273
305
|
merchant_category_type: json['merchant_category_type'],
|
|
274
306
|
merchant_country_code: json['merchant_country_code'],
|
|
275
307
|
acquirer_id: json['acquirer_id'],
|
|
@@ -283,6 +315,7 @@ module StarkInfra
|
|
|
283
315
|
tags: json['tags'],
|
|
284
316
|
issuing_transaction_ids: json['issuing_transaction_ids'],
|
|
285
317
|
status: json['status'],
|
|
318
|
+
confirmed: json['confirmed'],
|
|
286
319
|
description: json['description'],
|
|
287
320
|
metadata: json['metadata'],
|
|
288
321
|
zip_code: json['zip_code'],
|
|
@@ -18,7 +18,7 @@ module StarkInfra
|
|
|
18
18
|
#
|
|
19
19
|
# ## Attributes (return-only):
|
|
20
20
|
# - id [string]: unique id returned when IssuingRestock is created. ex: '5656565656565656'
|
|
21
|
-
# - status [string]: current IssuingRestock status.
|
|
21
|
+
# - status [string]: current IssuingRestock status. Options: 'created', 'processing', 'confirmed', 'canceled'.
|
|
22
22
|
# - updated [DateTime]: latest update datetime for the IssuingRestock. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
23
23
|
# - created [DateTime]: creation datetime for the IssuingRestock. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
24
24
|
class IssuingRestock < StarkCore::Utils::Resource
|
|
@@ -37,7 +37,8 @@ module StarkInfra
|
|
|
37
37
|
|
|
38
38
|
# # Create IssuingRestocks
|
|
39
39
|
#
|
|
40
|
-
# Send a list of IssuingRestock objects for creation in the Stark Infra API
|
|
40
|
+
# Send a list of IssuingRestock objects for creation in the Stark Infra API. Use this method to create up
|
|
41
|
+
# to 100 new IssuingRestocks at a time.
|
|
41
42
|
#
|
|
42
43
|
# ## Parameters (required):
|
|
43
44
|
# - restocks [list of IssuingRestock objects]: list of IssuingRestock objects to be created in the API
|
|
@@ -24,12 +24,14 @@ module StarkInfra
|
|
|
24
24
|
# - counter_amount [integer]: current rule spent amount. ex: 1000
|
|
25
25
|
# - currency_symbol [string]: currency symbol. ex: 'R$'
|
|
26
26
|
# - currency_name [string]: currency name. ex: 'Brazilian Real'
|
|
27
|
+
# - schedule [string]: Optional schedule dictating when the rule can be used. Some examples: 'everyday from 09:00 to 18:00 in America/Sao_Paulo' - every day, 09:00-18:00 Sao Paulo time; 'every monday, wednesday, friday from 08:00 to 12:00 in America/Sao_Paulo' - only those weekdays, mornings; 'every saturday, sunday' - weekends, all day, in UTC
|
|
28
|
+
# - purposes [list of strings]: Optional list of transaction purposes the rule applies to. Options: 'purchase', 'withdrawal', 'verification'. The rule then limits only purchases of those purposes; omit it to allow any purposes. Example: ['purchase', 'verification'] if you want us to automatically deny withdrawal.
|
|
27
29
|
class IssuingRule < StarkCore::Utils::Resource
|
|
28
30
|
attr_reader :name, :interval, :amount, :currency_code, :counter_amount, :currency_name, :currency_symbol,
|
|
29
|
-
:categories, :countries, :methods
|
|
31
|
+
:categories, :countries, :methods, :schedule, :purposes
|
|
30
32
|
def initialize(
|
|
31
33
|
name:, amount:, id: nil, interval: nil, currency_code: nil, categories: nil, countries: nil, methods: nil,
|
|
32
|
-
counter_amount: nil, currency_symbol: nil, currency_name: nil
|
|
34
|
+
counter_amount: nil, currency_symbol: nil, currency_name: nil, schedule: nil, purposes: nil
|
|
33
35
|
)
|
|
34
36
|
super(id)
|
|
35
37
|
@name = name
|
|
@@ -42,8 +44,19 @@ module StarkInfra
|
|
|
42
44
|
@counter_amount = counter_amount
|
|
43
45
|
@currency_symbol = currency_symbol
|
|
44
46
|
@currency_name = currency_name
|
|
47
|
+
@schedule = schedule
|
|
48
|
+
@purposes = purposes
|
|
45
49
|
end
|
|
46
50
|
|
|
51
|
+
# # Parse MerchantCategories
|
|
52
|
+
#
|
|
53
|
+
# Converts a list of hashes into a list of MerchantCategory objects.
|
|
54
|
+
#
|
|
55
|
+
# ## Parameters (required):
|
|
56
|
+
# - categories [list of hashes]: list to be parsed.
|
|
57
|
+
#
|
|
58
|
+
# ## Return:
|
|
59
|
+
# - list of parsed MerchantCategory objects
|
|
47
60
|
def self.parse_categories(categories)
|
|
48
61
|
resource_maker = StarkInfra::MerchantCategory.resource[:resource_maker]
|
|
49
62
|
return categories if categories.nil?
|
|
@@ -58,6 +71,15 @@ module StarkInfra
|
|
|
58
71
|
parsed_categories
|
|
59
72
|
end
|
|
60
73
|
|
|
74
|
+
# # Parse MerchantCountries
|
|
75
|
+
#
|
|
76
|
+
# Converts a list of hashes into a list of MerchantCountry objects.
|
|
77
|
+
#
|
|
78
|
+
# ## Parameters (required):
|
|
79
|
+
# - countries [list of hashes]: list to be parsed.
|
|
80
|
+
#
|
|
81
|
+
# ## Return:
|
|
82
|
+
# - list of parsed MerchantCountry objects
|
|
61
83
|
def self.parse_countries(countries)
|
|
62
84
|
resource_maker = StarkInfra::MerchantCountry.resource[:resource_maker]
|
|
63
85
|
return countries if countries.nil?
|
|
@@ -72,6 +94,15 @@ module StarkInfra
|
|
|
72
94
|
parsed_countries
|
|
73
95
|
end
|
|
74
96
|
|
|
97
|
+
# # Parse CardMethods
|
|
98
|
+
#
|
|
99
|
+
# Converts a list of hashes into a list of CardMethod objects.
|
|
100
|
+
#
|
|
101
|
+
# ## Parameters (required):
|
|
102
|
+
# - methods [list of hashes]: list to be parsed.
|
|
103
|
+
#
|
|
104
|
+
# ## Return:
|
|
105
|
+
# - list of parsed CardMethod objects
|
|
75
106
|
def self.parse_methods(methods)
|
|
76
107
|
resource_maker = StarkInfra::CardMethod.resource[:resource_maker]
|
|
77
108
|
return methods if methods.nil?
|
|
@@ -86,6 +117,15 @@ module StarkInfra
|
|
|
86
117
|
parsed_methods
|
|
87
118
|
end
|
|
88
119
|
|
|
120
|
+
# # Parse IssuingRules
|
|
121
|
+
#
|
|
122
|
+
# Converts a list of hashes into a list of IssuingRule objects.
|
|
123
|
+
#
|
|
124
|
+
# ## Parameters (required):
|
|
125
|
+
# - rules [list of hashes]: list to be parsed.
|
|
126
|
+
#
|
|
127
|
+
# ## Return:
|
|
128
|
+
# - list of parsed IssuingRule objects
|
|
89
129
|
def self.parse_rules(rules)
|
|
90
130
|
rule_maker = StarkInfra::IssuingRule.resource[:resource_maker]
|
|
91
131
|
return rules if rules.nil?
|
|
@@ -114,7 +154,9 @@ module StarkInfra
|
|
|
114
154
|
methods: json['methods'],
|
|
115
155
|
counter_amount: json['counter_amount'],
|
|
116
156
|
currency_symbol: json['currency_symbol'],
|
|
117
|
-
currency_name: json['currency_name']
|
|
157
|
+
currency_name: json['currency_name'],
|
|
158
|
+
schedule: json['schedule'],
|
|
159
|
+
purposes: json['purposes']
|
|
118
160
|
)
|
|
119
161
|
}
|
|
120
162
|
}
|
|
@@ -13,17 +13,19 @@ module StarkInfra
|
|
|
13
13
|
# - balance [integer]: [EXPANDABLE] current stock balance. ex: 1000
|
|
14
14
|
# - design_id [string]: IssuingDesign unique id. ex: "5656565656565656"
|
|
15
15
|
# - embosser_id [string]: Embosser unique id. ex: "5656565656565656"
|
|
16
|
+
# - embosser_name [string]: Name of the embosser that holds this stock
|
|
16
17
|
# - updated [DateTime]: latest update datetime for the IssuingStock. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
17
18
|
# - created [DateTime]: creation datetime for the IssuingStock. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
18
19
|
class IssuingStock < StarkCore::Utils::Resource
|
|
19
|
-
attr_reader :id, :balance, :design_id, :embosser_id, :updated, :created
|
|
20
|
+
attr_reader :id, :balance, :design_id, :embosser_id, :embosser_name, :updated, :created
|
|
20
21
|
def initialize(
|
|
21
|
-
id: nil, balance: nil, design_id: nil, embosser_id: nil, updated: nil, created: nil
|
|
22
|
+
id: nil, balance: nil, design_id: nil, embosser_id: nil, embosser_name: nil, updated: nil, created: nil
|
|
22
23
|
)
|
|
23
24
|
super(id)
|
|
24
25
|
@balance = balance
|
|
25
26
|
@design_id = design_id
|
|
26
27
|
@embosser_id = embosser_id
|
|
28
|
+
@embosser_name = embosser_name
|
|
27
29
|
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
|
28
30
|
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
29
31
|
end
|
|
@@ -127,6 +129,7 @@ module StarkInfra
|
|
|
127
129
|
balance: json['balance'],
|
|
128
130
|
design_id: json['design_id'],
|
|
129
131
|
embosser_id: json['embosser_id'],
|
|
132
|
+
embosser_name: json['embosser_name'],
|
|
130
133
|
updated: json['updated'],
|
|
131
134
|
created: json['created']
|
|
132
135
|
)
|
|
@@ -0,0 +1,214 @@
|
|
|
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. Each IssuingStock can have only one active IssuingStockRule at a time.
|
|
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 up to 10 strings, default nil]: emails notified when the stock reaches the minimum balance. ex: ['john.doe@enterprise.com']
|
|
20
|
+
# - phones [list of up to 10 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. At least one of emails or
|
|
47
|
+
# phones must be informed per rule.
|
|
48
|
+
#
|
|
49
|
+
# ## Parameters (required):
|
|
50
|
+
# - rules [list of IssuingStockRule objects]: list of IssuingStockRule objects to be created in the API
|
|
51
|
+
#
|
|
52
|
+
# ## Parameters (optional):
|
|
53
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
54
|
+
#
|
|
55
|
+
# ## Return:
|
|
56
|
+
# - list of IssuingStockRule objects with updated attributes
|
|
57
|
+
def self.create(rules:, user: nil)
|
|
58
|
+
StarkInfra::Utils::Rest.post(entities: rules, user: user, **resource)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# # Retrieve a specific IssuingStockRule
|
|
62
|
+
#
|
|
63
|
+
# Receive a single IssuingStockRule object previously created in the Stark Infra API by its id
|
|
64
|
+
#
|
|
65
|
+
# ## Parameters (required):
|
|
66
|
+
# - id [string]: object unique id. ex: '5664445921492992'
|
|
67
|
+
#
|
|
68
|
+
# ## Parameters (optional):
|
|
69
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
70
|
+
#
|
|
71
|
+
# ## Return:
|
|
72
|
+
# - IssuingStockRule object with updated attributes
|
|
73
|
+
def self.get(id, user: nil)
|
|
74
|
+
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# # Retrieve IssuingStockRules
|
|
78
|
+
#
|
|
79
|
+
# Receive a generator of IssuingStockRule objects previously created in the Stark Infra API
|
|
80
|
+
#
|
|
81
|
+
# ## Parameters (optional):
|
|
82
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
|
83
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
84
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
85
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['active', 'canceled']
|
|
86
|
+
# - stock_ids [list of strings, default nil]: list of stock_ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
87
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
88
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['card', 'corporate']
|
|
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
|
+
# - generator of IssuingStockRule objects with updated attributes
|
|
93
|
+
def self.query(
|
|
94
|
+
limit: nil, after: nil, before: nil, status: nil, stock_ids: nil,
|
|
95
|
+
ids: nil, tags: nil, user: nil
|
|
96
|
+
)
|
|
97
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
98
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
99
|
+
StarkInfra::Utils::Rest.get_stream(
|
|
100
|
+
limit: limit,
|
|
101
|
+
after: after,
|
|
102
|
+
before: before,
|
|
103
|
+
status: status,
|
|
104
|
+
stock_ids: stock_ids,
|
|
105
|
+
ids: ids,
|
|
106
|
+
tags: tags,
|
|
107
|
+
user: user,
|
|
108
|
+
**resource
|
|
109
|
+
)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# # Retrieve paged IssuingStockRules
|
|
113
|
+
#
|
|
114
|
+
# Receive a list of up to 100 IssuingStockRule objects previously created in the Stark Infra API and the cursor to the next page.
|
|
115
|
+
# Use this function instead of query if you want to manually page your requests.
|
|
116
|
+
#
|
|
117
|
+
# ## Parameters (optional):
|
|
118
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call.
|
|
119
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
|
120
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
121
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
122
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['active', 'canceled']
|
|
123
|
+
# - stock_ids [list of strings, default nil]: list of stock_ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
124
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
|
125
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['card', 'corporate']
|
|
126
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
127
|
+
#
|
|
128
|
+
# ## Return:
|
|
129
|
+
# - list of IssuingStockRule objects with updated attributes
|
|
130
|
+
# - cursor to retrieve the next page of IssuingStockRule objects
|
|
131
|
+
def self.page(
|
|
132
|
+
cursor: nil, limit: nil, after: nil, before: nil, status: nil, stock_ids: nil,
|
|
133
|
+
ids: nil, tags: nil, user: nil
|
|
134
|
+
)
|
|
135
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
136
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
137
|
+
StarkInfra::Utils::Rest.get_page(
|
|
138
|
+
cursor: cursor,
|
|
139
|
+
limit: limit,
|
|
140
|
+
after: after,
|
|
141
|
+
before: before,
|
|
142
|
+
status: status,
|
|
143
|
+
stock_ids: stock_ids,
|
|
144
|
+
ids: ids,
|
|
145
|
+
tags: tags,
|
|
146
|
+
user: user,
|
|
147
|
+
**resource
|
|
148
|
+
)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# # Update IssuingStockRule entity
|
|
152
|
+
#
|
|
153
|
+
# Update an IssuingStockRule by passing id.
|
|
154
|
+
#
|
|
155
|
+
# ## Parameters (required):
|
|
156
|
+
# - id [string]: IssuingStockRule unique id. ex: '5664445921492992'
|
|
157
|
+
#
|
|
158
|
+
# ## Parameters (optional):
|
|
159
|
+
# - minimum_balance [integer, default nil]: new stock balance threshold that triggers a notification. ex: 20000
|
|
160
|
+
# - tags [list of strings, default nil]: new list of strings for tagging. ex: ['card', 'corporate']
|
|
161
|
+
# - emails [list of strings, default nil]: new list of emails notified when the stock reaches the minimum balance. ex: ['john.doe@enterprise.com']
|
|
162
|
+
# - phones [list of strings, default nil]: new list of phones notified when the stock reaches the minimum balance. ex: ['+5511912345678']
|
|
163
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
164
|
+
#
|
|
165
|
+
# ## Return:
|
|
166
|
+
# - target IssuingStockRule with updated attributes
|
|
167
|
+
def self.update(id, minimum_balance: nil, tags: nil, emails: nil, phones: nil, user: nil)
|
|
168
|
+
StarkInfra::Utils::Rest.patch_id(
|
|
169
|
+
id: id,
|
|
170
|
+
minimum_balance: minimum_balance,
|
|
171
|
+
tags: tags,
|
|
172
|
+
emails: emails,
|
|
173
|
+
phones: phones,
|
|
174
|
+
user: user,
|
|
175
|
+
**resource
|
|
176
|
+
)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# # Cancel an IssuingStockRule entity
|
|
180
|
+
#
|
|
181
|
+
# Cancel an IssuingStockRule entity previously created in the Stark Infra API. This action is irreversible.
|
|
182
|
+
#
|
|
183
|
+
# ## Parameters (required):
|
|
184
|
+
# - id [string]: IssuingStockRule unique id. ex: '5664445921492992'
|
|
185
|
+
#
|
|
186
|
+
# ## Parameters (optional):
|
|
187
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
188
|
+
#
|
|
189
|
+
# ## Return:
|
|
190
|
+
# - canceled IssuingStockRule object
|
|
191
|
+
def self.cancel(id, user: nil)
|
|
192
|
+
StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def self.resource
|
|
196
|
+
{
|
|
197
|
+
resource_name: 'IssuingStockRule',
|
|
198
|
+
resource_maker: proc { |json|
|
|
199
|
+
IssuingStockRule.new(
|
|
200
|
+
minimum_balance: json['minimum_balance'],
|
|
201
|
+
stock_id: json['stock_id'],
|
|
202
|
+
tags: json['tags'],
|
|
203
|
+
emails: json['emails'],
|
|
204
|
+
phones: json['phones'],
|
|
205
|
+
id: json['id'],
|
|
206
|
+
status: json['status'],
|
|
207
|
+
created: json['created'],
|
|
208
|
+
updated: json['updated']
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end
|