starkinfra 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcodepreview/brcodepreview.rb +2 -5
  3. data/lib/cardmethod/cardmethod.rb +2 -2
  4. data/lib/creditholmes/creditholmes.rb +8 -11
  5. data/lib/creditnote/creditnote.rb +10 -11
  6. data/lib/creditnote/invoice/description.rb +3 -5
  7. data/lib/creditnote/invoice/discount.rb +3 -4
  8. data/lib/creditnote/invoice/invoice.rb +5 -6
  9. data/lib/creditnote/log.rb +8 -9
  10. data/lib/creditnote/transfer.rb +4 -5
  11. data/lib/creditpreview/creditnotepreview.rb +2 -3
  12. data/lib/creditpreview/creditpreview.rb +3 -4
  13. data/lib/creditsigner/creditsigner.rb +3 -6
  14. data/lib/dynamicbrcode/dynamicbrcode.rb +17 -19
  15. data/lib/error.rb +7 -40
  16. data/lib/event/attempt.rb +7 -8
  17. data/lib/event/event.rb +8 -11
  18. data/lib/individualdocument/individualdocument.rb +7 -8
  19. data/lib/individualdocument/log.rb +8 -9
  20. data/lib/individualidentity/individualidentity.rb +7 -8
  21. data/lib/individualidentity/log.rb +8 -9
  22. data/lib/issuingbalance/issuingbalance.rb +2 -3
  23. data/lib/issuingcard/issuingcard.rb +9 -10
  24. data/lib/issuingcard/log.rb +8 -9
  25. data/lib/issuingdesign/issuingdesign.rb +5 -6
  26. data/lib/issuingembossingkit/issuingembossingkit.rb +4 -5
  27. data/lib/issuingembossingrequest/issuingembossingrequest.rb +8 -9
  28. data/lib/issuingembossingrequest/log.rb +8 -9
  29. data/lib/issuingholder/issuingholder.rb +9 -10
  30. data/lib/issuingholder/log.rb +8 -9
  31. data/lib/issuinginvoice/issuinginvoice.rb +8 -9
  32. data/lib/issuinginvoice/log.rb +8 -9
  33. data/lib/issuingproduct/issuingproduct.rb +3 -4
  34. data/lib/issuingpurchase/issuingpurchase.rb +33 -22
  35. data/lib/issuingpurchase/log.rb +8 -9
  36. data/lib/issuingrestock/issuingrestock.rb +8 -9
  37. data/lib/issuingrestock/log.rb +8 -9
  38. data/lib/issuingrule/issuingrule.rb +6 -7
  39. data/lib/issuingstock/issuingstock.rb +8 -9
  40. data/lib/issuingstock/log.rb +8 -9
  41. data/lib/issuingtransaction/issuingtransaction.rb +7 -8
  42. data/lib/issuingwithdrawal/issuingwithdrawal.rb +8 -9
  43. data/lib/merchantcategory/merchantcategory.rb +2 -2
  44. data/lib/merchantcountry/merchantcountry.rb +2 -2
  45. data/lib/pixbalance/pixbalance.rb +2 -3
  46. data/lib/pixchargeback/log.rb +8 -9
  47. data/lib/pixchargeback/pixchargeback.rb +8 -9
  48. data/lib/pixclaim/log.rb +8 -9
  49. data/lib/pixclaim/pixclaim.rb +8 -9
  50. data/lib/pixdirector/pixdirector.rb +2 -2
  51. data/lib/pixdomain/certificate.rb +2 -2
  52. data/lib/pixdomain/pixdomain.rb +3 -3
  53. data/lib/pixinfraction/log.rb +8 -9
  54. data/lib/pixinfraction/pixinfraction.rb +8 -9
  55. data/lib/pixkey/log.rb +8 -9
  56. data/lib/pixkey/pixkey.rb +8 -9
  57. data/lib/pixrequest/log.rb +8 -9
  58. data/lib/pixrequest/pixrequest.rb +9 -10
  59. data/lib/pixreversal/log.rb +7 -9
  60. data/lib/pixreversal/pixreversal.rb +9 -10
  61. data/lib/pixstatement/pixstatement.rb +6 -7
  62. data/lib/request/request.rb +152 -0
  63. data/lib/starkinfra.rb +14 -6
  64. data/lib/staticbrcode/staticbrcode.rb +8 -9
  65. data/lib/utils/parse.rb +23 -42
  66. data/lib/utils/rest.rb +211 -110
  67. data/lib/webhook/webhook.rb +2 -3
  68. metadata +6 -21
  69. data/lib/key.rb +0 -33
  70. data/lib/user/organization.rb +0 -54
  71. data/lib/user/project.rb +0 -37
  72. data/lib/user/user.rb +0 -20
  73. data/lib/utils/api.rb +0 -89
  74. data/lib/utils/bacenid.rb +0 -19
  75. data/lib/utils/cache.rb +0 -10
  76. data/lib/utils/case.rb +0 -21
  77. data/lib/utils/checks.rb +0 -100
  78. data/lib/utils/endtoendid.rb +0 -11
  79. data/lib/utils/environment.rb +0 -14
  80. data/lib/utils/request.rb +0 -79
  81. data/lib/utils/resource.rb +0 -13
  82. data/lib/utils/returnid.rb +0 -11
  83. data/lib/utils/sub_resource.rb +0 -27
  84. data/lib/utils/url.rb +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84494554057a87004d3c53122b4212049553964d4aae5a06b7045c104debbe61
4
- data.tar.gz: 227df256622a80f1e2e827c8aef4b7363a0307abb2f727b9ee82876dc942cef1
3
+ metadata.gz: 4c35da5e6496d5271ac8467f26b02a3776d21dec476d4eb526d7a8e503f8bbc9
4
+ data.tar.gz: 0115cfd4453a7fcf939a3601611e6e1b96ff78e00f310c7c5d25df4ef42dbcb5
5
5
  SHA512:
6
- metadata.gz: 7f077615c40b5066952932e8b771838665c203d6d4d238486abd4e2d07eba832da4a69b9610e086f525d7c38f499e1613275bdc7944d9d340d7d489fa2472637
7
- data.tar.gz: 0e646b2ec34f440339c48dd368e761d30e26a1edea765ee034b89816888135465e11d49b66bb812cb458520117d67af57356f41cfd33f2f0dbc50d8a2b2be8a7
6
+ metadata.gz: 95db214920f662bab0fcfaa10353e971a75bf32822402c44d071e1c15bde66e3a607b90f887a6b709d3b97faca5ed3496c1d757534f819e684493da145cf1069
7
+ data.tar.gz: 94eae035e2920bf65d23074dad0179c9d90b72b78f0b5d8c66a8fadc310c9c110f33ef02a6d1ee2ab80ec9329fd75be5b037165afe656a9173a939daa2fec6b5
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
-
2
+ require('starkcore')
3
3
  require_relative('../utils/rest')
4
- require_relative('../utils/parse')
5
- require_relative('../utils/checks')
6
- require_relative('../utils/resource')
7
4
 
8
5
  module StarkInfra
9
6
  # # BrcodePreview object
@@ -38,7 +35,7 @@ module StarkInfra
38
35
  # - scheduled [DateTime]: date of payment execution. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0).
39
36
  # - status [string]: Payment status. ex: 'active', 'paid', 'canceled' or 'unknown'
40
37
  # - tax_id [string]: Payment receiver tax ID. ex: '012.345.678-90'
41
- class BrcodePreview < StarkInfra::Utils::Resource
38
+ class BrcodePreview < StarkCore::Utils::Resource
42
39
  attr_reader :id, :payer_id, :end_to_end_id, :account_number, :account_type, :amount, :amount_type, :bank_code, :branch_code, :cash_amount,
43
40
  :cashier_bank_code, :cashier_type, :discount_amount, :fine_amount, :key_id, :interest_amount, :name,
44
41
  :nominal_amount, :reconciliation_id, :reduction_amount, :scheduled, :status, :tax_id
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative('../utils/rest')
4
- require_relative('../utils/sub_resource')
4
+ require('starkcore')
5
5
 
6
6
  module StarkInfra
7
7
  # # CardMethod object
@@ -14,7 +14,7 @@ module StarkInfra
14
14
  # Attributes (return-only):
15
15
  # - name [string]: method's name. ex: 'token'
16
16
  # - number [string]: method's number. ex: '81'
17
- class CardMethod < StarkInfra::Utils::SubResource
17
+ class CardMethod < StarkCore::Utils::SubResource
18
18
  attr_reader :code, :name, :number
19
19
  def initialize(code:, name: nil, number: nil)
20
20
  @code = code
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
-
2
+ require('starkcore')
3
3
  require_relative('../utils/rest')
4
- require_relative('../utils/parse')
5
- require_relative('../utils/checks')
6
- require_relative('../utils/resource')
7
4
 
8
5
  module StarkInfra
9
6
  # # CreditHolmes object
@@ -29,7 +26,7 @@ module StarkInfra
29
26
  # - status [string]: current status of the CreditHolmes. ex: "created", "failed", "success"
30
27
  # - created [DateTime]: creation datetime for the CreditHolmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
31
28
  # - updated [DateTime]: latest update datetime for the CreditHolmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
32
- class CreditHolmes < StarkInfra::Utils::Resource
29
+ class CreditHolmes < StarkCore::Utils::Resource
33
30
  attr_reader :tax_id, :competence, :tags, :id, :result, :status, :updated, :created
34
31
  def initialize(tax_id:, competence: nil, tags: nil, id: nil, result: nil, status: nil, updated: nil, created: nil)
35
32
  super(id)
@@ -39,8 +36,8 @@ module StarkInfra
39
36
  @id = id
40
37
  @result = result
41
38
  @status = status
42
- @created = StarkInfra::Utils::Checks.check_datetime(created)
43
- @updated = StarkInfra::Utils::Checks.check_datetime(updated)
39
+ @created = StarkCore::Utils::Checks.check_datetime(created)
40
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
44
41
  end
45
42
 
46
43
  # # Create CreditHolmes
@@ -91,8 +88,8 @@ module StarkInfra
91
88
  # ## Return:
92
89
  # - generator of CreditHolmes objects with updated attributes
93
90
  def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
94
- after = StarkInfra::Utils::Checks.check_date(after)
95
- before = StarkInfra::Utils::Checks.check_date(before)
91
+ after = StarkCore::Utils::Checks.check_date(after)
92
+ before = StarkCore::Utils::Checks.check_date(before)
96
93
  StarkInfra::Utils::Rest.get_stream(
97
94
  limit: limit,
98
95
  after: after,
@@ -124,8 +121,8 @@ module StarkInfra
124
121
  # - list of CreditHolmes objects with updated attributes
125
122
  # - cursor to retrieve the next page of CreditHolmes objects
126
123
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
127
- after = StarkInfra::Utils::Checks.check_date(after)
128
- before = StarkInfra::Utils::Checks.check_date(before)
124
+ after = StarkCore::Utils::Checks.check_date(after)
125
+ before = StarkCore::Utils::Checks.check_date(before)
129
126
  StarkInfra::Utils::Rest.get_page(
130
127
  cursor: cursor,
131
128
  limit: limit,
@@ -1,14 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative('../utils/rest')
4
- require_relative('../utils/parse')
5
- require_relative('../utils/checks')
6
4
  require_relative('invoice/invoice')
7
5
  require_relative('invoice/discount')
8
- require_relative('../utils/resource')
9
6
  require_relative('invoice/description')
10
7
  require_relative('../creditnote/transfer')
11
8
 
9
+ require('starkcore')
10
+
12
11
  module StarkInfra
13
12
  # # CreditNote object
14
13
  #
@@ -55,7 +54,7 @@ module StarkInfra
55
54
  # - interest [float]: yearly effective interest rate of the credit note, in percentage. ex: 12.5
56
55
  # - created [DateTime]: creation datetime for the CreditNote. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
57
56
  # - updated [DateTime]: latest update datetime for the CreditNote. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
58
- class CreditNote < StarkInfra::Utils::Resource
57
+ class CreditNote < StarkCore::Utils::Resource
59
58
  attr_reader :template_id, :name, :tax_id, :scheduled, :invoices, :payment, :signers, :external_id,
60
59
  :street_line_1, :street_line_2, :district, :city, :state_code, :zip_code, :payment_type,
61
60
  :nominal_amount, :amount, :rebate_amount, :tags, :expiration, :id, :document_id, :status,
@@ -93,8 +92,8 @@ module StarkInfra
93
92
  @tax_amount = tax_amount
94
93
  @nominal_interest = nominal_interest
95
94
  @interest = interest
96
- @created = StarkInfra::Utils::Checks.check_datetime(created)
97
- @updated = StarkInfra::Utils::Checks.check_datetime(updated)
95
+ @created = StarkCore::Utils::Checks.check_datetime(created)
96
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
98
97
 
99
98
  payment_info = CreditNote.parse_payment(payment, payment_type)
100
99
  @payment = payment_info['payment']
@@ -149,8 +148,8 @@ module StarkInfra
149
148
  # ## Return:
150
149
  # - generator of CreditNote objects with updated attributes
151
150
  def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
152
- after = StarkInfra::Utils::Checks.check_date(after)
153
- before = StarkInfra::Utils::Checks.check_date(before)
151
+ after = StarkCore::Utils::Checks.check_date(after)
152
+ before = StarkCore::Utils::Checks.check_date(before)
154
153
  StarkInfra::Utils::Rest.get_stream(
155
154
  limit: limit,
156
155
  after: after,
@@ -182,8 +181,8 @@ module StarkInfra
182
181
  # - list of CreditNote objects with updated attributes
183
182
  # - cursor to retrieve the next page of CreditNote objects
184
183
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
185
- after = StarkInfra::Utils::Checks.check_date(after)
186
- before = StarkInfra::Utils::Checks.check_date(before)
184
+ after = StarkCore::Utils::Checks.check_date(after)
185
+ before = StarkCore::Utils::Checks.check_date(before)
187
186
  StarkInfra::Utils::Rest.get_page(
188
187
  cursor: cursor,
189
188
  limit: limit,
@@ -217,7 +216,7 @@ module StarkInfra
217
216
  resource_maker = { 'transfer' => Transfer.resource[:resource_maker] }
218
217
  if payment.is_a?(Hash)
219
218
  begin
220
- parsed_payment = StarkInfra::Utils::API.from_api_json(resource_maker[payment_type], payment)
219
+ parsed_payment = StarkCore::Utils::API.from_api_json(resource_maker[payment_type], payment)
221
220
  return { 'payment' => parsed_payment, 'payment_type' => payment_type }
222
221
 
223
222
  rescue StandardError
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
-
3
- require_relative('../../utils/api')
2
+ require('starkcore')
4
3
  require_relative('../../utils/rest')
5
- require_relative('../../utils/sub_resource')
6
4
 
7
5
  module StarkInfra
8
6
 
@@ -15,7 +13,7 @@ module StarkInfra
15
13
  #
16
14
  # ## Parameters (optional):
17
15
  # - value [string, default nil]: amount related to the described key. ex: 'R$100,00'
18
- class Description < StarkInfra::Utils::SubResource
16
+ class Description < StarkCore::Utils::SubResource
19
17
  attr_reader :percentage, :due
20
18
  def initialize(key:, value: nil)
21
19
  @key = key
@@ -29,7 +27,7 @@ module StarkInfra
29
27
  parsed_descriptions = []
30
28
  descriptions.each do |description|
31
29
  unless description.is_a? Description
32
- description = StarkInfra::Utils::API.from_api_json(resource_maker, description)
30
+ description = StarkCore::Utils::API.from_api_json(resource_maker, description)
33
31
  end
34
32
  parsed_descriptions << description
35
33
  end
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../../utils/api')
3
+ require('starkcore')
4
4
  require_relative('../../utils/rest')
5
- require_relative('../../utils/sub_resource')
6
5
 
7
6
  module StarkInfra
8
7
 
@@ -13,7 +12,7 @@ module StarkInfra
13
12
  # ## Parameters (required):
14
13
  # - percentage [float]: percentage of discount applied until specified due date.
15
14
  # - due [DateTime or string]: due datetime for the discount. ex: '2020-03-10T10:30:00.000000+00:00' or DateTime.new(2020, 3, 10, 10, 30, 0, 0).
16
- class Discount < StarkInfra::Utils::SubResource
15
+ class Discount < StarkCore::Utils::SubResource
17
16
  attr_reader :percentage, :due
18
17
  def initialize(percentage:, due:)
19
18
  @percentage = percentage
@@ -27,7 +26,7 @@ module StarkInfra
27
26
  parsed_discounts = []
28
27
  discounts.each do |discount|
29
28
  unless discount.is_a? Discount
30
- discount = StarkInfra::Utils::API.from_api_json(resource_maker, discount)
29
+ discount = StarkCore::Utils::API.from_api_json(resource_maker, discount)
31
30
  end
32
31
  parsed_discounts << discount
33
32
  end
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../../utils/api')
3
+ require('starkcore')
4
4
  require_relative('../../utils/rest')
5
- require_relative('../../utils/sub_resource')
6
5
 
7
6
  module StarkInfra
8
7
 
@@ -38,7 +37,7 @@ module StarkInfra
38
37
  # - transaction_ids [list of strings]: ledger transaction ids linked to this Invoice (if there are more than one, all but the first are reversals or failed reversal chargebacks). ex: ['19827356981273']
39
38
  # - created [DateTime]: creation datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
40
39
  # - updated [DateTime]: latest update datetime for the Invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
41
- class Invoice < StarkInfra::Utils::Resource
40
+ class Invoice < StarkCore::Utils::Resource
42
41
  attr_reader :amount, :id, :due, :expiration, :tags, :descriptions, :name, :tax_id, :pdf, :link, :fine, :interest,
43
42
  :nominal_amount, :fine_amount, :interest_amount, :discount_amount, :discounts, :brcode, :status, :fee,
44
43
  :transaction_ids, :created, :updated
@@ -70,8 +69,8 @@ module StarkInfra
70
69
  @status = status
71
70
  @fee = fee
72
71
  @transaction_ids = transaction_ids
73
- @created = StarkInfra::Utils::Checks.check_datetime(created)
74
- @updated = StarkInfra::Utils::Checks.check_datetime(updated)
72
+ @created = StarkCore::Utils::Checks.check_datetime(created)
73
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
75
74
  end
76
75
 
77
76
  def self.parse_invoices(invoices)
@@ -81,7 +80,7 @@ module StarkInfra
81
80
  parsed_invoices = []
82
81
  invoices.each do |invoice|
83
82
  unless invoice.is_a? Invoice
84
- invoice = StarkInfra::Utils::API.from_api_json(resource_maker, invoice)
83
+ invoice = StarkCore::Utils::API.from_api_json(resource_maker, invoice)
85
84
  end
86
85
  parsed_invoices << invoice
87
86
  end
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require('starkcore')
3
4
  require_relative('creditnote')
4
5
  require_relative('../utils/rest')
5
- require_relative('../utils/checks')
6
- require_relative('../utils/resource')
7
6
 
8
7
  module StarkInfra
9
8
  class CreditNote
@@ -19,14 +18,14 @@ module StarkInfra
19
18
  # - errors [list of strings]: list of errors linked to this CreditNote event.
20
19
  # - type [string]: type of the CreditNote event which triggered the log creation. Options: 'canceled', 'created', 'expired', 'failed', 'refunded', 'registered', 'sending', 'sent', 'signed', 'success'
21
20
  # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
22
- class Log < StarkInfra::Utils::Resource
21
+ class Log < StarkCore::Utils::Resource
23
22
  attr_reader :id, :created, :type, :errors, :note
24
23
  def initialize(id:, created:, type:, errors:, note:)
25
24
  super(id)
26
25
  @note = note
27
26
  @errors = errors
28
27
  @type = type
29
- @created = StarkInfra::Utils::Checks.check_datetime(created)
28
+ @created = StarkCore::Utils::Checks.check_datetime(created)
30
29
  end
31
30
 
32
31
  # # Retrieve a specific CreditNote::Log
@@ -60,8 +59,8 @@ module StarkInfra
60
59
  # ## Return:
61
60
  # - list of Log objects with updated attributes
62
61
  def self.query(limit: nil, after: nil, before: nil, types: nil, note_ids: nil, user: nil)
63
- after = StarkInfra::Utils::Checks.check_date(after)
64
- before = StarkInfra::Utils::Checks.check_date(before)
62
+ after = StarkCore::Utils::Checks.check_date(after)
63
+ before = StarkCore::Utils::Checks.check_date(before)
65
64
  StarkInfra::Utils::Rest.get_stream(
66
65
  limit: limit,
67
66
  after: after,
@@ -91,8 +90,8 @@ module StarkInfra
91
90
  # - list of Log objects with updated attributes
92
91
  # - Cursor to retrieve the next page of Log objects
93
92
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, note_ids: nil, user: nil)
94
- after = StarkInfra::Utils::Checks.check_date(after)
95
- before = StarkInfra::Utils::Checks.check_date(before)
93
+ after = StarkCore::Utils::Checks.check_date(after)
94
+ before = StarkCore::Utils::Checks.check_date(before)
96
95
  StarkInfra::Utils::Rest.get_page(
97
96
  cursor: cursor,
98
97
  limit: limit,
@@ -112,7 +111,7 @@ module StarkInfra
112
111
  resource_maker: proc { |json|
113
112
  Log.new(
114
113
  id: json['id'],
115
- note: StarkInfra::Utils::API.from_api_json(note_maker, json['note']),
114
+ note: StarkCore::Utils::API.from_api_json(note_maker, json['note']),
116
115
  errors: json['errors'],
117
116
  type: json['type'],
118
117
  created: json['created']
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/api')
3
+ require('starkcore')
4
4
  require_relative('../utils/rest')
5
- require_relative('../utils/sub_resource')
6
5
 
7
6
  module StarkInfra
8
7
 
@@ -32,7 +31,7 @@ module StarkInfra
32
31
  # - transaction_ids [list of strings]: ledger Transaction IDs linked to this Transfer (if there are two, the second is the chargeback). ex: ['19827356981273']
33
32
  # - created [DateTime]: creation datetime for the transfer. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
34
33
  # - updated [DateTime]: latest update datetime for the transfer. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
35
- class Transfer < StarkInfra::Utils::Resource
34
+ class Transfer < StarkCore::Utils::Resource
36
35
  attr_reader :id, :name, :tax_id, :bank_code, :branch_code, :account_number, :account_type, :tags, :amount, :external_id,
37
36
  :scheduled, :description, :fee, :status, :created, :updated, :transaction_ids
38
37
  def initialize(
@@ -56,8 +55,8 @@ module StarkInfra
56
55
  @fee = fee
57
56
  @status = status
58
57
  @transaction_ids = transaction_ids
59
- @created = StarkInfra::Utils::Checks.check_datetime(created)
60
- @updated = StarkInfra::Utils::Checks.check_datetime(updated)
58
+ @created = StarkCore::Utils::Checks.check_datetime(created)
59
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
61
60
  end
62
61
 
63
62
  def self.resource
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/api')
3
+ require('starkcore')
4
4
  require_relative('../utils/rest')
5
- require_relative('../utils/sub_resource')
6
5
 
7
6
  module StarkInfra
8
7
  # # CreditNotePreview object
@@ -34,7 +33,7 @@ module StarkInfra
34
33
  # - amount [integer]: credit note value in cents. ex: 1234 (= R$ 12.34)
35
34
  # - interest [float]: yearly effective interest rate of the credit note, in percentage. ex: 12.5
36
35
  # - tax_amount [integer]: tax amount included in the credit note. ex: 100
37
- class CreditNotePreview < StarkInfra::Utils::SubResource
36
+ class CreditNotePreview < StarkCore::Utils::SubResource
38
37
  attr_reader :type, :nominal_amount, :scheduled, :tax_id, :invoices, :nominal_interest, :initial_due, :count,
39
38
  :initial_amount, :interval, :rebate_amount, :amount, :interest, :tax_amount
40
39
  def initialize(
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/api')
3
+ require('starkcore')
4
4
  require_relative('../utils/rest')
5
- require_relative('../utils/sub_resource')
6
5
 
7
6
  module StarkInfra
8
7
  # # CreditPreview object
@@ -13,7 +12,7 @@ module StarkInfra
13
12
  # ## Parameters (required):
14
13
  # - credit [CreditNotePreview object]: Information preview of the informed credit.
15
14
  # - type [string]: Credit type. ex: "credit-note"
16
- class CreditPreview < StarkInfra::Utils::SubResource
15
+ class CreditPreview < StarkCore::Utils::SubResource
17
16
  attr_reader :credit, :type
18
17
  def initialize(credit:, type: nil)
19
18
  credit_info = CreditPreview.parse_credit(credit, type)
@@ -42,7 +41,7 @@ module StarkInfra
42
41
  resource_maker = { 'credit-note' => StarkInfra::CreditNotePreview.resource[:resource_maker] }
43
42
  if credit.is_a?(Hash)
44
43
  begin
45
- parsed_credit = StarkInfra::Utils::API.from_api_json(resource_maker[type], credit)
44
+ parsed_credit = StarkCore::Utils::API.from_api_json(resource_maker[type], credit)
46
45
  return { 'credit' => parsed_credit, 'type' => type }
47
46
 
48
47
  rescue StandardError
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
-
2
+ require('starkcore')
3
3
  require_relative('../utils/rest')
4
- require_relative('../utils/parse')
5
- require_relative('../utils/checks')
6
- require_relative('../utils/resource')
7
4
 
8
5
  module StarkInfra
9
6
  # # CreditSigner object
@@ -17,7 +14,7 @@ module StarkInfra
17
14
  #
18
15
  # ## Attributes (return-only):
19
16
  # - id [string]: unique id returned when the CreditSigner is created. ex: '5656565656565656'
20
- class CreditSigner < StarkInfra::Utils::Resource
17
+ class CreditSigner < StarkCore::Utils::Resource
21
18
  attr_reader :name, :contact, :method, :id
22
19
  def initialize(name:, contact:, method:, id: nil)
23
20
  super(id)
@@ -33,7 +30,7 @@ module StarkInfra
33
30
  parsed_signers = []
34
31
  signers.each do |signer|
35
32
  unless signer.is_a? CreditSigner
36
- signer = StarkInfra::Utils::API.from_api_json(resource_maker, signer)
33
+ signer = StarkCore::Utils::API.from_api_json(resource_maker, signer)
37
34
  end
38
35
  parsed_signers << signer
39
36
  end
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require('starkcore')
3
4
  require_relative('../utils/rest')
4
- require_relative('../utils/parse')
5
- require_relative('../utils/checks')
6
- require_relative('../utils/resource')
7
5
 
8
6
  module StarkInfra
9
7
  # # DynamicBrcode object
@@ -35,7 +33,7 @@ module StarkInfra
35
33
  # - url [string]: url link to the BR Code image. ex: 'https://brcode-h.development.starkinfra.com/dynamic-qrcode/901e71f2447c43c886f58366a5432c4b.png'
36
34
  # - created [DateTime]: creation datetime for the DynamicBrcode. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
37
35
  # - updated [DateTime]: latest update datetime for the DynamicBrcode. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
38
- class DynamicBrcode < StarkInfra::Utils::Resource
36
+ class DynamicBrcode < StarkCore::Utils::Resource
39
37
  attr_reader :name, :city, :external_id, :type, :tags, :id, :uuid, :url, :updated, :created
40
38
  def initialize(name:, city:, external_id:, type: nil, tags: nil, id: nil, uuid: nil, url: nil, updated: nil, created: nil)
41
39
  super(id)
@@ -46,8 +44,8 @@ module StarkInfra
46
44
  @tags = tags
47
45
  @uuid = uuid
48
46
  @url = url
49
- @created = StarkInfra::Utils::Checks.check_datetime(created)
50
- @updated = StarkInfra::Utils::Checks.check_datetime(updated)
47
+ @created = StarkCore::Utils::Checks.check_datetime(created)
48
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
51
49
  end
52
50
 
53
51
  # # Create DynamicBrcodes
@@ -98,8 +96,8 @@ module StarkInfra
98
96
  # ## Return:
99
97
  # - generator of DynamicBrcode objects with updated attributes
100
98
  def self.query(limit: nil, after: nil, before: nil, external_ids: nil, uuids: nil, tags: nil, user: nil)
101
- after = StarkInfra::Utils::Checks.check_date(after)
102
- before = StarkInfra::Utils::Checks.check_date(before)
99
+ after = StarkCore::Utils::Checks.check_date(after)
100
+ before = StarkCore::Utils::Checks.check_date(before)
103
101
  StarkInfra::Utils::Rest.get_stream(
104
102
  limit: limit,
105
103
  after: after,
@@ -130,8 +128,8 @@ module StarkInfra
130
128
  # - list of DynamicBrcode objects with updated attributes
131
129
  # - cursor to retrieve the next page of DynamicBrcode objects
132
130
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, tags: nil, uuids: nil, external_ids: nil, user: nil)
133
- after = StarkInfra::Utils::Checks.check_date(after)
134
- before = StarkInfra::Utils::Checks.check_date(before)
131
+ after = StarkCore::Utils::Checks.check_date(after)
132
+ before = StarkCore::Utils::Checks.check_date(before)
135
133
  StarkInfra::Utils::Rest.get_page(
136
134
  cursor: cursor,
137
135
  limit: limit,
@@ -162,7 +160,9 @@ module StarkInfra
162
160
  # - reconciliation_id [string]: id to be used for conciliation of the resulting Pix transaction. This id must have from to 26 to 35 alphanumeric characters' ex: "cd65c78aeb6543eaaa0170f68bd741ee"
163
161
  # - nominal_amount [integer]: positive integer that represents the amount in cents of the resulting Pix transaction. ex: 1234 (= R$ 12.34)
164
162
  # - sender_name [string]: sender's full name. ex: "Anthony Edward Stark"
163
+ # - sender_tax_id [string]: sender's CPF (11 digits formatted or unformatted) or CNPJ (14 digits formatted or unformatted). ex: '01.001.001/0001-01'
165
164
  # - receiver_name [string]: receiver's full name. ex: "Jamie Lannister"
165
+ # - receiver_tax_id [string]: receiver's CPF (11 digits formatted or unformatted) or CNPJ (14 digits formatted or unformatted). ex: '012.345.678-90'
166
166
  # - receiver_street_line [string]: receiver's main address. ex: "Av. Paulista, 200"
167
167
  # - receiver_city [string]: receiver's address city name. ex: "Sao Paulo"
168
168
  # - receiver_state_code [string]: receiver's address state code. ex: "SP"
@@ -170,8 +170,6 @@ module StarkInfra
170
170
  #
171
171
  # ## Parameters (optional):
172
172
  # - expiration [integer]: time in seconds counted from the creation datetime until the DynamicBrcode expires. After expiration, the BR Code cannot be paid anymore.
173
- # - sender_tax_id [string, default nil]: sender's CPF (11 digits formatted or unformatted) or CNPJ (14 digits formatted or unformatted). ex: '01.001.001/0001-01'
174
- # - receiver_tax_id [string, default nil]: receiver's CPF (11 digits formatted or unformatted) or CNPJ (14 digits formatted or unformatted). ex: '012.345.678-90'
175
173
  # - fine [float, default 2.0]: Percentage charged if the sender pays after the due datetime. ex. 2.0
176
174
  # - interest [float, default 1.0]: Interest percentage charged if the sender pays after the due datetime. ex: 1.5
177
175
  # - discounts [list of dictionaries, default nil]: discount amount applied if the sender pays at a specific datetime before the due datetime.
@@ -181,8 +179,8 @@ module StarkInfra
181
179
  # - Dumped JSON string that must be returned to us
182
180
  def self.response_due(
183
181
  version: , created: , due: , key_id: , status: , reconciliation_id: , nominal_amount: ,
184
- sender_name: , receiver_name: , receiver_street_line: , receiver_city: , receiver_state_code: ,
185
- receiver_zip_code: , expiration: , sender_tax_id: , receiver_tax_id: , fine: , interest: ,
182
+ sender_name: , sender_tax_id: , receiver_name: , receiver_tax_id: , receiver_street_line: ,
183
+ receiver_city: , receiver_state_code: , receiver_zip_code: , expiration: , fine: , interest: ,
186
184
  discounts: , description:
187
185
  )
188
186
 
@@ -195,14 +193,14 @@ module StarkInfra
195
193
  'reconciliationId': reconciliation_id,
196
194
  'nominalAmount': nominal_amount,
197
195
  'senderName': sender_name,
196
+ 'senderTaxId': sender_tax_id,
198
197
  'receiverName': receiver_name,
198
+ 'receiverTaxId': receiver_tax_id,
199
199
  'receiverStreetLine': receiver_street_line,
200
200
  'receiverCity': receiver_city,
201
201
  'receiverStateCode': receiver_state_code,
202
202
  'receiverZipCode': receiver_zip_code,
203
203
  'expiration': expiration,
204
- 'senderTaxId': sender_tax_id,
205
- 'receiverTaxId': receiver_tax_id,
206
204
  'fine': fine,
207
205
  'interest': interest,
208
206
  'discounts': Discount.parse_discounts(discounts),
@@ -283,7 +281,7 @@ module StarkInfra
283
281
  # ## Return:
284
282
  # - verified Brcode's uuid.
285
283
  def self.verify(uuid:, signature:, user: nil)
286
- StarkInfra::Utils::Parse.verify(content: uuid, signature: signature, user: user)
284
+ StarkCore::Utils::Parse.verify(content: uuid, signature: signature, user: user)
287
285
  end
288
286
 
289
287
  def self.resource
@@ -313,7 +311,7 @@ module StarkInfra
313
311
  # ## Parameters (required):
314
312
  # - percentage [integer]: discount percentage that will be applied. ex: 2.5
315
313
  # - due [DateTime or string, default now + 2 days]: Date after when the discount will be overdue in UTC ISO format. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0) or "2020-03-10T10:30:00.000000+00:00"
316
- class Discount < StarkInfra::Utils::SubResource
314
+ class Discount < StarkCore::Utils::SubResource
317
315
  attr_reader :percentage, :due
318
316
  def initialize(percentage:, due:)
319
317
  @percentage = percentage
@@ -327,7 +325,7 @@ module StarkInfra
327
325
  discounts.each do |discount|
328
326
 
329
327
  if discount.is_a? DynamicBrcode::Discount
330
- discount = StarkInfra::Utils::API.api_json(discount)
328
+ discount = StarkCore::Utils::API.api_json(discount)
331
329
  end
332
330
  parsed_discounts << discount
333
331
  end
data/lib/error.rb CHANGED
@@ -1,52 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require('json')
3
+ require('starkcore')
4
4
 
5
5
  module StarkInfra
6
6
  module Error
7
- class StarkInfraError < StandardError
8
- attr_reader :message
9
- def initialize(message)
10
- @message = message
11
- super(message)
12
- end
13
- end
7
+ StarkInfraError = StarkCore::Error::StarkCoreError
14
8
 
15
- class Error < StarkInfraError
16
- attr_reader :code, :message
17
- def initialize(code, message)
18
- @code = code
19
- @message = message
20
- super("#{code}: #{message}")
21
- end
22
- end
9
+ Error = StarkCore::Error::Error
23
10
 
24
- class InputErrors < StarkInfraError
25
- attr_reader :errors
26
- def initialize(content)
27
- errors = []
28
- content.each do |error|
29
- errors << Error.new(error['code'], error['message'])
30
- end
31
- @errors = errors
11
+ InputErrors = StarkCore::Error::InputErrors
32
12
 
33
- super(content.to_json)
34
- end
35
- end
13
+ InternalServerError = StarkCore::Error::InternalServerError
36
14
 
37
- class InternalServerError < StarkInfraError
38
- def initialize(message = 'Houston, we have a problem.')
39
- super(message)
40
- end
41
- end
15
+ UnknownError = StarkCore::Error::UnknownError
42
16
 
43
- class UnknownError < StarkInfraError
44
- def initialize(message)
45
- super("Unknown exception encountered: #{message}")
46
- end
47
- end
48
-
49
- class InvalidSignatureError < StarkInfraError
50
- end
17
+ InvalidSignatureError = StarkCore::Error::InvalidSignatureError
51
18
  end
52
19
  end