starkinfra 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcodepreview/brcodepreview.rb +125 -0
  3. data/lib/cardmethod/cardmethod.rb +56 -0
  4. data/lib/creditholmes/creditholmes.rb +160 -0
  5. data/lib/creditnote/creditnote.rb +51 -355
  6. data/lib/creditnote/invoice/description.rb +51 -0
  7. data/lib/creditnote/invoice/discount.rb +49 -0
  8. data/lib/creditnote/invoice/invoice.rb +124 -0
  9. data/lib/creditnote/log.rb +18 -19
  10. data/lib/creditnote/transfer.rb +90 -0
  11. data/lib/creditpreview/creditnotepreview.rb +85 -0
  12. data/lib/creditpreview/creditpreview.rb +77 -0
  13. data/lib/creditsigner/creditsigner.rb +57 -0
  14. data/lib/dynamicbrcode/dynamicbrcode.rb +350 -0
  15. data/lib/event/attempt.rb +5 -4
  16. data/lib/event/event.rb +11 -11
  17. data/lib/individualdocument/individualdocument.rb +165 -0
  18. data/lib/individualdocument/log.rb +125 -0
  19. data/lib/individualidentity/individualidentity.rb +193 -0
  20. data/lib/individualidentity/log.rb +124 -0
  21. data/lib/issuingbalance/issuingbalance.rb +4 -4
  22. data/lib/issuingcard/issuingcard.rb +35 -33
  23. data/lib/issuingcard/log.rb +21 -21
  24. data/lib/issuingdesign/issuingdesign.rb +138 -0
  25. data/lib/issuingembossingkit/issuingembossingkit.rb +121 -0
  26. data/lib/issuingembossingrequest/issuingembossingrequest.rb +210 -0
  27. data/lib/issuingembossingrequest/log.rb +128 -0
  28. data/lib/issuingholder/issuingholder.rb +21 -15
  29. data/lib/issuingholder/log.rb +19 -19
  30. data/lib/issuinginvoice/issuinginvoice.rb +29 -14
  31. data/lib/issuinginvoice/log.rb +18 -18
  32. data/lib/{issuingbin/issuingbin.rb → issuingproduct/issuingproduct.rb} +27 -30
  33. data/lib/issuingpurchase/issuingpurchase.rb +111 -31
  34. data/lib/issuingpurchase/log.rb +16 -16
  35. data/lib/issuingrestock/issuingrestock.rb +162 -0
  36. data/lib/issuingrestock/log.rb +127 -0
  37. data/lib/issuingrule/issuingrule.rb +64 -18
  38. data/lib/issuingstock/issuingstock.rb +138 -0
  39. data/lib/issuingstock/log.rb +130 -0
  40. data/lib/issuingtransaction/issuingtransaction.rb +12 -13
  41. data/lib/issuingwithdrawal/issuingwithdrawal.rb +12 -11
  42. data/lib/merchantcategory/merchantcategory.rb +63 -0
  43. data/lib/merchantcountry/merchantcountry.rb +59 -0
  44. data/lib/pixbalance/pixbalance.rb +5 -5
  45. data/lib/pixchargeback/log.rb +15 -15
  46. data/lib/pixchargeback/pixchargeback.rb +32 -20
  47. data/lib/pixclaim/log.rb +21 -24
  48. data/lib/pixclaim/pixclaim.rb +44 -34
  49. data/lib/pixdirector/pixdirector.rb +9 -11
  50. data/lib/pixdomain/certificate.rb +1 -1
  51. data/lib/pixdomain/pixdomain.rb +5 -5
  52. data/lib/pixinfraction/log.rb +20 -20
  53. data/lib/pixinfraction/pixinfraction.rb +23 -15
  54. data/lib/pixkey/log.rb +23 -23
  55. data/lib/pixkey/pixkey.rb +14 -12
  56. data/lib/pixrequest/log.rb +24 -20
  57. data/lib/pixrequest/pixrequest.rb +54 -21
  58. data/lib/pixreversal/log.rb +3 -3
  59. data/lib/pixreversal/pixreversal.rb +48 -21
  60. data/lib/pixstatement/pixstatement.rb +13 -8
  61. data/lib/starkinfra.rb +40 -15
  62. data/lib/staticbrcode/staticbrcode.rb +170 -0
  63. data/lib/user/project.rb +1 -1
  64. data/lib/utils/api.rb +1 -0
  65. data/lib/utils/bacenid.rb +1 -1
  66. data/lib/utils/parse.rb +7 -3
  67. data/lib/utils/request.rb +1 -1
  68. data/lib/utils/resource.rb +1 -1
  69. data/lib/utils/sub_resource.rb +21 -22
  70. data/lib/webhook/webhook.rb +11 -11
  71. metadata +29 -4
  72. data/lib/issuingauthorization/issuingauthorization.rb +0 -141
@@ -1,45 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
4
3
  require_relative('../utils/rest')
5
4
  require_relative('../utils/checks')
5
+ require_relative('../utils/resource')
6
6
 
7
7
  module StarkInfra
8
- # # IssuingBin object
8
+ # # IssuingProduct object
9
9
  #
10
- # The IssuingBin object displays information of BINs registered to your Workspace.
11
- # They represent a group of cards that begin with the same numbers (BIN) and offer the same product to end customers.
10
+ # The IssuingProduct object displays information of registered card products to your Workspace.
11
+ # They represent a group of cards that begin with the same numbers (id) and offer the same product to end customers.
12
12
  #
13
13
  # ## Attributes (return-only):
14
- # - id [string]: unique BIN number registered within the card network. ex: '53810200'
14
+ # - id [string]: unique card product number (BIN) registered within the card network. ex: '53810200'
15
15
  # - network [string]: card network flag. ex: 'mastercard'
16
- # - settlement [string]: settlement type. ex: 'credit'
17
- # - category [string]: purchase category. ex: 'prepaid'
18
- # - client [string]: client type. ex: 'business'
19
- # - created [DateTime]: creation datetime for the IssuingBin. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
20
- # - updated [DateTime]: latest update datetime for the IssuingBin. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
21
- class IssuingBin < StarkInfra::Utils::Resource
22
- attr_reader :id, :network, :settlement, :category, :client, :updated, :created
23
- def initialize(id: nil, network: nil, settlement: nil, category: nil, client: nil, updated: nil, created: nil)
16
+ # - funding_type [string]: type of funding used for payment. ex: 'credit', 'debit'
17
+ # - holder_type [string]: holder type. ex: 'business', 'individual'
18
+ # - code [string]: internal code from card flag informing the product. ex: 'MRW', 'MCO', 'MWB', 'MCS'
19
+ # - created [DateTime]: creation datetime for the IssuingProduct. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
20
+ class IssuingProduct < StarkInfra::Utils::Resource
21
+ attr_reader :id, :network, :funding_type, :holder_type, :code, :created
22
+ def initialize(id: nil, network: nil, funding_type: nil, holder_type: nil, code: nil, created: nil)
24
23
  super(id)
25
24
  @network = network
26
- @settlement = settlement
27
- @category = category
28
- @client = client
29
- @updated = StarkInfra::Utils::Checks.check_datetime(updated)
25
+ @funding_type = funding_type
26
+ @holder_type = holder_type
27
+ @code = code
30
28
  @created = StarkInfra::Utils::Checks.check_datetime(created)
31
29
  end
32
30
 
33
- # # Retrieve the IssuingBin object
31
+ # # Retrieve IssuingProducts
34
32
  #
35
- # Receive a generator of IssuingBin objects previously registered in the Stark Infra API
33
+ # Receive a generator of IssuingProduct objects previously registered in the Stark Infra API
36
34
  #
37
35
  # ## Parameters (optional):
38
36
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
39
37
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
40
38
  #
41
39
  # ## Return:
42
- # - generator of IssuingBin objects with updated attributes
40
+ # - generator of IssuingProduct objects with updated attributes
43
41
  def self.query(limit: nil, user: nil)
44
42
  StarkInfra::Utils::Rest.get_stream(
45
43
  limit: limit,
@@ -48,9 +46,9 @@ module StarkInfra
48
46
  )
49
47
  end
50
48
 
51
- # # Retrieve paged IssuingBins
49
+ # # Retrieve paged IssuingProducts
52
50
  #
53
- # Receive a list of up to 100 IssuingBin objects previously registered in the Stark Infra API and the cursor to the next page.
51
+ # Receive a list of up to 100 IssuingProduct objects previously registered to your workspace and the cursor to the next page.
54
52
  #
55
53
  # ## Parameters (optional):
56
54
  # - cursor [string, default nil]: cursor returned on the previous page function call.
@@ -58,8 +56,8 @@ module StarkInfra
58
56
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
59
57
  #
60
58
  # ## Return:
61
- # - list of IssuingBin objects with updated attributes
62
- # - cursor to retrieve the next page of IssuingBin objects
59
+ # - list of IssuingProduct objects with updated attributes
60
+ # - cursor to retrieve the next page of IssuingProduct objects
63
61
  def self.page(cursor: nil, limit: nil, user: nil)
64
62
  StarkInfra::Utils::Rest.get_page(
65
63
  cursor: cursor,
@@ -71,15 +69,14 @@ module StarkInfra
71
69
 
72
70
  def self.resource
73
71
  {
74
- resource_name: 'IssuingBin',
72
+ resource_name: 'IssuingProduct',
75
73
  resource_maker: proc { |json|
76
- IssuingBin.new(
74
+ IssuingProduct.new(
77
75
  id: json['id'],
78
76
  network: json['network'],
79
- settlement: json['settlement'],
80
- category: json['category'],
81
- client: json['client'],
82
- updated: json['updated'],
77
+ funding_type: json['funding_type'],
78
+ holder_type: json['holder_type'],
79
+ code: json['code'],
83
80
  created: json['created']
84
81
  )
85
82
  }
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
4
3
  require_relative('../utils/rest')
5
4
  require_relative('../utils/checks')
5
+ require_relative('../utils/resource')
6
6
 
7
7
  module StarkInfra
8
8
  # # IssuingPurchase object
@@ -12,8 +12,10 @@ module StarkInfra
12
12
  # ## Attributes (return-only):
13
13
  # - id [string]: unique id returned when IssuingPurchase is created. ex: '5656565656565656'
14
14
  # - holder_name [string]: card holder name. ex: 'Tony Stark'
15
+ # - product_id [string]: unique card product number (BIN) registered within the card network. ex: "53810200"
15
16
  # - card_id [string]: unique id returned when IssuingCard is created. ex: '5656565656565656'
16
17
  # - card_ending [string]: last 4 digits of the card number. ex: '1234'
18
+ # - purpose [string]: purchase purpose. ex: 'purchase'
17
19
  # - amount [integer]: IssuingPurchase value in cents. Minimum = 0. ex: 1234 (= R$ 12.34)
18
20
  # - tax [integer]: IOF amount taxed for international purchases. ex: 1234 (= R$ 12.34)
19
21
  # - issuer_amount [integer]: issuer amount. ex: 1234 (= R$ 12.34)
@@ -29,32 +31,43 @@ module StarkInfra
29
31
  # - merchant_name [string]: merchant name. ex: 'Google Cloud Platform'
30
32
  # - merchant_fee [integer]: fee charged by the merchant to cover specific costs, such as ATM withdrawal logistics, etc. ex: 200 (= R$ 2.00)
31
33
  # - wallet_id [string]: virtual wallet ID. ex: '5656565656565656'
32
- # - method_code [string]: method code. ex: 'chip', 'token', 'server', 'manual', 'magstripe' or 'contactless'
34
+ # - method_code [string]: method code. Options: 'chip', 'token', 'server', 'manual', 'magstripe' or 'contactless'
33
35
  # - score [float]: internal score calculated for the authenticity of the purchase. nil in case of insufficient data. ex: 7.6
34
- # - issuing_transaction_ids [string]: ledger transaction ids linked to this Purchase
35
- # - end_to_end_id [string]: Unique id used to identify the transaction through all of its life cycle, even before the purchase is denied or accepted and gets its usual id. Example: endToEndId='679cd385-642b-49d0-96b7-89491e1249a5'
36
- # - status [string]: current IssuingCard status. ex: 'approved', 'canceled', 'denied', 'confirmed', 'voided'
36
+ # - end_to_end_id [string]: Unique id used to identify the transaction through all of its life cycle, even before the purchase is denied or approved and gets its usual id. ex: '679cd385-642b-49d0-96b7-89491e1249a5'
37
37
  # - tags [string]: list of strings for tagging returned by the sub-issuer during the authorization. ex: ['travel', 'food']
38
- # - created [DateTime]: creation datetime for the IssuingPurchase. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
38
+ # - zip_code [string]: zip code of the merchant location. ex: '02101234'
39
+ #
40
+ # ## Attributes (IssuingPurchase only):
41
+ # - issuing_transaction_ids [string]: ledger transaction ids linked to this Purchase
42
+ # - status [string]: current IssuingCard status. Options: 'approved', 'canceled', 'denied', 'confirmed', 'voided'
39
43
  # - updated [DateTime]: latest update datetime for the IssuingPurchase. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
44
+ # - created [DateTime]: creation datetime for the IssuingPurchase. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
45
+ #
46
+ # ## Attributes (authorization request only):
47
+ # - is_partial_allowed [bool]: true if the merchant allows partial purchases. ex: False
48
+ # - card_tags [list of strings]: tags of the IssuingCard responsible for this purchase. ex: ['travel', 'food']
49
+ # - holder_tags [list of strings]: tags of the IssuingHolder responsible for this purchase. ex: ['technology', 'john snow']
40
50
  class IssuingPurchase < StarkInfra::Utils::Resource
41
- attr_reader :id, :holder_name, :card_id, :card_ending, :amount, :tax, :issuer_amount, :issuer_currency_code,
51
+ attr_reader :id, :holder_name, :product_id, :card_id, :card_ending, :purpose, :amount, :tax, :issuer_amount, :issuer_currency_code,
42
52
  :issuer_currency_symbol, :merchant_amount, :merchant_currency_code, :merchant_currency_symbol,
43
53
  :merchant_category_code, :merchant_country_code, :acquirer_id, :merchant_id, :merchant_name,
44
- :merchant_fee, :wallet_id, :method_code, :score, :issuing_transaction_ids, :end_to_end_id, :status,
45
- :tags, :updated, :created
54
+ :merchant_fee, :wallet_id, :method_code, :score, :end_to_end_id, :tags, :zip_code,
55
+ :issuing_transaction_ids, :status, :updated, :created, :is_partial_allowed, :card_tags, :holder_tags
46
56
 
47
57
  def initialize(
48
- id: nil, holder_name: nil, card_id: nil, card_ending: nil, amount: nil, tax: nil, issuer_amount: nil,
58
+ id: nil, holder_name: nil, product_id: nil, card_id: nil, card_ending: nil, purpose: nil, amount: nil, tax: nil, issuer_amount: nil,
49
59
  issuer_currency_code: nil, issuer_currency_symbol: nil, merchant_amount: nil, merchant_currency_code: nil,
50
60
  merchant_currency_symbol: nil, merchant_category_code: nil, merchant_country_code: nil, acquirer_id: nil,
51
61
  merchant_id: nil, merchant_name: nil, merchant_fee: nil, wallet_id: nil, method_code: nil, score: nil,
52
- issuing_transaction_ids: nil, end_to_end_id: nil, status: nil, tags: nil, updated: nil, created: nil
62
+ end_to_end_id: nil, tags: nil, zip_code: nil, issuing_transaction_ids: nil, status: nil, updated: nil, created: nil,
63
+ is_partial_allowed: nil, card_tags:nil, holder_tags:nil
53
64
  )
54
65
  super(id)
55
66
  @holder_name = holder_name
67
+ @product_id = product_id
56
68
  @card_id = card_id
57
69
  @card_ending = card_ending
70
+ @purpose = purpose
58
71
  @amount = amount
59
72
  @tax = tax
60
73
  @issuer_amount = issuer_amount
@@ -72,12 +85,17 @@ module StarkInfra
72
85
  @wallet_id = wallet_id
73
86
  @method_code = method_code
74
87
  @score = score
75
- @issuing_transaction_ids = issuing_transaction_ids
76
88
  @end_to_end_id = end_to_end_id
77
- @status = status
78
89
  @tags = tags
79
- @created = StarkInfra::Utils::Checks.check_datetime(created)
90
+ @zip_code = zip_code
91
+ @issuing_transaction_ids = issuing_transaction_ids
92
+ @status = status
80
93
  @updated = StarkInfra::Utils::Checks.check_datetime(updated)
94
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
95
+ @is_partial_allowed = is_partial_allowed
96
+ @card_tags = card_tags
97
+ @holder_tags = holder_tags
98
+
81
99
  end
82
100
 
83
101
  # # Retrieve a specific IssuingPurchase
@@ -96,19 +114,19 @@ module StarkInfra
96
114
  StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
97
115
  end
98
116
 
99
- # # Retrieve IssuingPurchase
117
+ # # Retrieve IssuingPurchases
100
118
  #
101
119
  # Receive a generator of IssuingPurchases objects previously created in the Stark Infra API
102
120
  #
103
121
  # ## Parameters (optional):
104
- # - ids [list of strings, default nil]: purchase IDs. ex: ['5656565656565656', '4545454545454545']
105
122
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
106
- # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 09)
107
- # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
108
- # - end_to_end_ids [list of strings, default []]: central bank's unique transaction ID. ex: 'E79457883202101262140HHX553UPqeq'
109
- # - holder_ids [list of strings, default []]: card holder IDs. ex: ['5656565656565656', '4545454545454545']
110
- # - card_ids [list of strings, default []]: card IDs. ex: ['5656565656565656', '4545454545454545']
123
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 09)
124
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
125
+ # - end_to_end_ids [list of strings, default nil]: central bank's unique transaction ID. ex: 'E79457883202101262140HHX553UPqeq'
126
+ # - holder_ids [list of strings, default nil]: card holder IDs. ex: ['5656565656565656', '4545454545454545']
127
+ # - card_ids [list of strings, default nil]: card IDs. ex: ['5656565656565656', '4545454545454545']
111
128
  # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['approved', 'canceled', 'denied', 'confirmed', 'voided']
129
+ # - ids [list of strings, default nil]: purchase IDs. ex: ['5656565656565656', '4545454545454545']
112
130
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
113
131
  #
114
132
  # ## Return:
@@ -133,18 +151,19 @@ module StarkInfra
133
151
 
134
152
  # # Retrieve paged IssuingPurchases
135
153
  #
136
- # Receive a list of IssuingPurchase objects previously created in the Stark Infra API and the cursor to the next page.
154
+ # Receive a list of up to 100 IssuingPurchases objects previously created in the Stark Infra API and the cursor
155
+ # to the next page. Use this function instead of query if you want to manually page your invoices.
137
156
  #
138
157
  # ## Parameters (optional):
139
158
  # - cursor [string, default nil]: cursor returned on the previous page function call.
140
- # - ids [list of strings, default nil]: purchase IDs. ex: ['5656565656565656', '4545454545454545']
141
159
  # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
142
- # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
143
- # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
144
- # - end_to_end_ids [list of strings, default []]: central bank's unique transaction ID. ex: 'E79457883202101262140HHX553UPqeq'
145
- # - holder_ids [list of strings, default []]: card holder IDs. ex: ['5656565656565656', '4545454545454545']
146
- # - card_ids [list of strings, default []]: card IDs. ex: ['5656565656565656', '4545454545454545']
160
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
161
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
162
+ # - end_to_end_ids [list of strings, default nil]: central bank's unique transaction ID. ex: 'E79457883202101262140HHX553UPqeq'
163
+ # - holder_ids [list of strings, default nil]: card holder IDs. ex: ['5656565656565656', '4545454545454545']
164
+ # - card_ids [list of strings, default nil]: card IDs. ex: ['5656565656565656', '4545454545454545']
147
165
  # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['approved', 'canceled', 'denied', 'confirmed', 'voided']
166
+ # - ids [list of strings, default nil]: purchase IDs. ex: ['5656565656565656', '4545454545454545']
148
167
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
149
168
  #
150
169
  # ## Return:
@@ -169,6 +188,61 @@ module StarkInfra
169
188
  )
170
189
  end
171
190
 
191
+ # # Create a single verified IssuingPurchase authorization request from a content string
192
+ #
193
+ # Use this method to parse and verify the authenticity of the authorization request received at the informed endpoint.
194
+ # Authorization requests are posted to your registered endpoint whenever IssuingPurchases are received.
195
+ # They present IssuingPurchase data that must be analyzed and answered with approval or declination.
196
+ # If the provided digital signature does not check out with the StarkInfra public key, a stark.exception.InvalidSignatureException will be raised.
197
+ # If the authorization request is not answered within 2 seconds or is not answered with an HTTP status code 200 the
198
+ # IssuingPurchase will go through the pre-configured stand-in validation.
199
+ #
200
+ # ## Parameters (required):
201
+ # - content [string]: response content from request received at user endpoint (not parsed)
202
+ # - signature [string]: base-64 digital signature received at response header 'Digital-Signature'
203
+ #
204
+ # # ## Parameters (optional):
205
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
206
+ #
207
+ # ## Return:
208
+ # - Parsed IssuingPurchase object
209
+ def self.parse(content:, signature:, user: nil)
210
+ StarkInfra::Utils::Parse.parse_and_verify(
211
+ content: content,
212
+ signature: signature,
213
+ user: user,
214
+ key: nil,
215
+ **resource
216
+ )
217
+ end
218
+
219
+ # # Helps you respond IssuingPurchase request
220
+ #
221
+ # ## Parameters (required):
222
+ # - status [string]: sub-issuer response to the authorization. ex: 'approved' or 'denied'
223
+ #
224
+ # ## Parameters (conditionally required):
225
+ # - reason [string]: denial reason. Options: 'other', 'blocked', 'lostCard', 'stolenCard', 'invalidPin', 'invalidCard', 'cardExpired', 'issuerError', 'concurrency', 'standInDenial', 'subIssuerError', 'invalidPurpose', 'invalidZipCode', 'invalidWalletId', 'inconsistentCard', 'settlementFailed', 'cardRuleMismatch', 'invalidExpiration', 'prepaidInstallment', 'holderRuleMismatch', 'insufficientBalance', 'tooManyTransactions', 'invalidSecurityCode', 'invalidPaymentMethod', 'confirmationDeadline', 'withdrawalAmountLimit', 'insufficientCardLimit', 'insufficientHolderLimit'
226
+ #
227
+ # # ## Parameters (optional):
228
+ # - amount [integer, default nil]: amount in cents that was authorized. ex: 1234 (= R$ 12.34)
229
+ # - tags [list of strings, default nil]: tags to filter retrieved object. ex: ['tony', 'stark']
230
+ #
231
+ # ## Return:
232
+ # - Dumped JSON string that must be returned to us on the IssuingPurchase request
233
+ def self.response(
234
+ status:, reason:, amount:, tags:
235
+ )
236
+ params = {
237
+ 'status': status,
238
+ 'reason': reason,
239
+ 'amount': amount,
240
+ 'tags': tags
241
+ }
242
+
243
+ params.to_json
244
+ end
245
+
172
246
  def self.resource
173
247
  {
174
248
  resource_name: 'IssuingPurchase',
@@ -176,8 +250,10 @@ module StarkInfra
176
250
  IssuingPurchase.new(
177
251
  id: json['id'],
178
252
  holder_name: json['holder_name'],
253
+ product_id: json['product_id'],
179
254
  card_id: json['card_id'],
180
255
  card_ending: json['card_ending'],
256
+ purpose: json['purpose'],
181
257
  amount: json['amount'],
182
258
  tax: json['tax'],
183
259
  issuer_amount: json['issuer_amount'],
@@ -195,12 +271,16 @@ module StarkInfra
195
271
  wallet_id: json['wallet_id'],
196
272
  method_code: json['method_code'],
197
273
  score: json['score'],
198
- issuing_transaction_ids: json['issuing_transaction_ids'],
199
274
  end_to_end_id: json['end_to_end_id'],
200
- status: json['status'],
201
275
  tags: json['tags'],
276
+ zip_code: json['zip_code'],
277
+ issuing_transaction_ids: json['issuing_transaction_ids'],
278
+ status: json['status'],
202
279
  updated: json['updated'],
203
- created: json['created']
280
+ created: json['created'],
281
+ is_partial_allowed: json['is_partial_allowed'],
282
+ card_tags: json['card_tags'],
283
+ holder_tags: json['holder_tags']
204
284
  )
205
285
  }
206
286
  }
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
4
3
  require_relative('../utils/rest')
5
4
  require_relative('../utils/checks')
6
5
  require_relative('issuingpurchase')
6
+ require_relative('../utils/resource')
7
7
 
8
8
  module StarkInfra
9
9
  class IssuingPurchase
@@ -12,7 +12,7 @@ module StarkInfra
12
12
  # Every time an IssuingPurchase entity is updated, a corresponding IssuingInvoice::Log is generated for the entity.
13
13
  # This Log is never generated by the user, but it can be retrieved to check additional information on the IssuingPurchase.
14
14
  #
15
- # ## Attributes:
15
+ # ## Attributes (return-only):
16
16
  # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
17
17
  # - purchase [IssuingPurchase]: IssuingPurchase entity to which the log refers to.
18
18
  # - issuing_transaction_id [string]: transaction ID related to the IssuingCard.
@@ -30,9 +30,9 @@ module StarkInfra
30
30
  @created = StarkInfra::Utils::Checks.check_datetime(created)
31
31
  end
32
32
 
33
- # # Retrieve a specific Log
33
+ # # Retrieve a specific IssuingPurchase::Log
34
34
  #
35
- # Receive a single Log object previously created by the Stark Infra API by passing its id
35
+ # Receive a single IssuingPurchase::Log object previously created by the Stark Infra API by passing its id
36
36
  #
37
37
  # ## Parameters (required):
38
38
  # - id [string]: object unique id. ex: '5656565656565656'
@@ -41,26 +41,26 @@ module StarkInfra
41
41
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
42
42
  #
43
43
  # ## Return:
44
- # - Log object with updated attributes
44
+ # - IssuingPurchase::Log object with updated attributes
45
45
  def self.get(id, user: nil)
46
46
  StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
47
47
  end
48
48
 
49
- # # Retrieve Logs
49
+ # # Retrieve IssuingPurchase::Logs
50
50
  #
51
- # Receive a generator of Log objects previously created in the Stark Infra API
51
+ # Receive a generator of IssuingPurchase::Log objects previously created in the Stark Infra API
52
52
  #
53
53
  # ## Parameters (optional):
54
- # - ids [list of strings, default nil]: list of IssuingPurchase ids to filter logs. ex: ['5656565656565656', '4545454545454545']
55
54
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
56
- # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
57
- # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
55
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
56
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
58
57
  # - types [list of strings, default nil]: filter for log event types. ex: ['approved', 'canceled', 'confirmed', 'denied', 'reversed', 'voided']
59
58
  # - purchase_ids [list of strings, default nil]: list of Purchase ids to filter logs. ex: ['5656565656565656', '4545454545454545']
59
+ # - ids [list of strings, default nil]: list of IssuingPurchase ids to filter logs. ex: ['5656565656565656', '4545454545454545']
60
60
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
61
61
  #
62
62
  # ## Return:
63
- # - generator of Log objects with updated attributes
63
+ # - generator of IssuingPurchase::Log objects with updated attributes
64
64
  def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, purchase_ids: nil, user: nil)
65
65
  after = StarkInfra::Utils::Checks.check_date(after)
66
66
  before = StarkInfra::Utils::Checks.check_date(before)
@@ -76,23 +76,23 @@ module StarkInfra
76
76
  )
77
77
  end
78
78
 
79
- # # Retrieve paged Logs
79
+ # # Retrieve paged IssuingPurchase::Logs
80
80
  #
81
81
  # Receive a list of up to 100 Log objects previously created in the Stark Infra API and the cursor to the next page.
82
82
  # Use this function instead of query if you want to manually page your purchases.
83
83
  #
84
84
  # ## Parameters (optional):
85
85
  # - cursor [string, default nil]: cursor returned on the previous page function call
86
- # - ids [list of strings, default nil]: list of IssuingPurchase ids to filter logs. ex: ['5656565656565656', '4545454545454545']
87
86
  # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
88
- # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
89
- # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
87
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
88
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
90
89
  # - types [list of strings, default nil]: filter for log event types. ex: ['approved', 'canceled', 'confirmed', 'denied', 'reversed', 'voided']
91
90
  # - purchase_ids [list of strings, default nil]: list of Purchase ids to filter logs. ex: ['5656565656565656', '4545454545454545']
91
+ # - ids [list of strings, default nil]: list of IssuingPurchase ids to filter logs. ex: ['5656565656565656', '4545454545454545']
92
92
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
93
93
  #
94
94
  # ## Return:
95
- # - list of Log objects with updated attributes
95
+ # - list of IssuingPurchase::Log objects with updated attributes
96
96
  # - cursor to retrieve the next page of Log objects
97
97
  def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, purchase_ids: nil, user: nil)
98
98
  after = StarkInfra::Utils::Checks.check_date(after)
@@ -0,0 +1,162 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/rest')
4
+ require_relative('../utils/checks')
5
+ require_relative('../utils/resource')
6
+
7
+ module StarkInfra
8
+ # # IssuingRestock object
9
+ #
10
+ # The IssuingRestock object displays the information of the restock orders created in your Workspace.
11
+ # This resource place a restock order for a specific IssuingStock object.
12
+ #
13
+ # ## Parameters (required):
14
+ # - count [integer]: number of restocks to be restocked. ex: 100
15
+ # - stock_id [string]: IssuingStock unique id ex: "5136459887542272"
16
+ #
17
+ # ## Parameters (optional):
18
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ["card", "corporate"]
19
+ #
20
+ # ## Attributes (return-only):
21
+ # - id [string]: unique id returned when IssuingRestock is created. ex: '5656565656565656'
22
+ # - status [string]: current IssuingRestock status. ex: "created", "processing", "confirmed"
23
+ # - updated [DateTime]: latest update datetime for the IssuingRestock. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
24
+ # - created [DateTime]: creation datetime for the IssuingRestock. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
25
+ class IssuingRestock < StarkInfra::Utils::Resource
26
+ attr_reader :count, :stock_id, :tags, :id, :status, :updated, :created
27
+ def initialize(
28
+ count:, stock_id:, tags: nil, id: nil, status: nil, updated: nil, created: nil
29
+ )
30
+ super(id)
31
+ @count = count
32
+ @stock_id = stock_id
33
+ @tags = tags
34
+ @status = status
35
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
36
+ @updated = StarkInfra::Utils::Checks.check_datetime(updated)
37
+ end
38
+
39
+ # # Create IssuingRestocks
40
+ #
41
+ # Send a list of IssuingRestock objects for creation in the Stark Infra API
42
+ #
43
+ # ## Parameters (required):
44
+ # - restocks [list of IssuingRestock objects]: list of IssuingRestock objects to be created in the API
45
+ #
46
+ # ## Parameters (optional):
47
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
48
+ #
49
+ # ## Return:
50
+ # - list of IssuingRestock objects with updated attributes
51
+ def self.create(restocks:, user: nil)
52
+ StarkInfra::Utils::Rest.post(entities: restocks, user: user, **resource)
53
+ end
54
+
55
+ # # Retrieve a specific IssuingRestock
56
+ #
57
+ # Receive a single IssuingRestock object previously created in the Stark Infra API by its id
58
+ #
59
+ # ## Parameters (required):
60
+ # - id [string]: object unique id. ex: '5656565656565656'
61
+ #
62
+ # ## Parameters (optional):
63
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
64
+ #
65
+ # ## Return:
66
+ # - IssuingRestock object with updated attributes
67
+ def self.get(id, user: nil)
68
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
69
+ end
70
+
71
+ # # Retrieve IssuingRestocks
72
+ #
73
+ # Receive a generator of IssuingRestock objects previously created in the Stark Infra API
74
+ #
75
+ # ## Parameters (optional):
76
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
77
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
78
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
79
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ["created", "processing", "confirmed"]
80
+ # - stock_ids [list of string, default nil]: list of stock_ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
81
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
82
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ["card", "corporate"]
83
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
84
+ #
85
+ # ## Return:
86
+ # - generator of IssuingRestocks objects with updated attributes
87
+ def self.query(
88
+ limit: nil, after: nil, before: nil, status: nil, stock_ids: nil, ids: nil,
89
+ tags: nil, user: nil
90
+ )
91
+ after = StarkInfra::Utils::Checks.check_date(after)
92
+ before = StarkInfra::Utils::Checks.check_date(before)
93
+ StarkInfra::Utils::Rest.get_stream(
94
+ limit: limit,
95
+ after: after,
96
+ before: before,
97
+ status: status,
98
+ stock_ids: stock_ids,
99
+ ids: ids,
100
+ tags: tags,
101
+ user: user,
102
+ **resource
103
+ )
104
+ end
105
+
106
+ # # Retrieve paged IssuingRestocks
107
+ #
108
+ # Receive a list of up to 100 IssuingRestock objects previously created in the Stark Infra API and the cursor to the next page.
109
+ # Use this function instead of query if you want to manually page your requests.
110
+ #
111
+ # ## Parameters (optional):
112
+ # - cursor [string, default nil]: cursor returned on the previous page function call.
113
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
114
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
115
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
116
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ["created", "processing", "confirmed"]
117
+ # - stock_ids [list of string, default nil]: list of stock_ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
118
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
119
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ["card", "corporate"]
120
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
121
+ #
122
+ # ## Return:
123
+ # - list of IssuingRestocks objects with updated attributes
124
+ # - cursor to retrieve the next page of IssuingRestocks objects
125
+ def self.page(
126
+ cursor: nil, limit: nil, after: nil, before: nil, status: nil, stock_ids: nil,
127
+ ids: nil, tags: nil, user: nil
128
+ )
129
+ after = StarkInfra::Utils::Checks.check_date(after)
130
+ before = StarkInfra::Utils::Checks.check_date(before)
131
+ StarkInfra::Utils::Rest.get_page(
132
+ cursor: cursor,
133
+ limit: limit,
134
+ after: after,
135
+ before: before,
136
+ status: status,
137
+ stock_ids: stock_ids,
138
+ ids: ids,
139
+ tags: tags,
140
+ user: user,
141
+ **resource
142
+ )
143
+ end
144
+
145
+ def self.resource
146
+ {
147
+ resource_name: 'IssuingRestock',
148
+ resource_maker: proc { |json|
149
+ IssuingRestock.new(
150
+ count: json['count'],
151
+ stock_id: json['stock_id'],
152
+ tags: json['tags'],
153
+ id: json['id'],
154
+ status: json['status'],
155
+ updated: json['updated'],
156
+ created: json['created']
157
+ )
158
+ }
159
+ }
160
+ end
161
+ end
162
+ end