starkinfra 0.4.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 +32 -24
  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
data/lib/pixkey/log.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require('starkcore')
3
4
  require_relative('pixkey')
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 PixKey
@@ -18,14 +17,14 @@ module StarkInfra
18
17
  # - type [string]: type of the PixKey event which triggered the log creation. Options: 'created', 'registered', 'updated', 'failed', 'canceling', 'canceled'.
19
18
  # - errors [list of strings]: list of errors linked to this PixKey event.
20
19
  # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
21
- class Log < StarkInfra::Utils::Resource
20
+ class Log < StarkCore::Utils::Resource
22
21
  attr_reader :id, :created, :type, :errors, :key
23
22
  def initialize(id:, created:, type:, errors:, key:)
24
23
  super(id)
25
24
  @key = key
26
25
  @type = type
27
26
  @errors = errors
28
- @created = StarkInfra::Utils::Checks.check_datetime(created)
27
+ @created = StarkCore::Utils::Checks.check_datetime(created)
29
28
  end
30
29
 
31
30
  # # Retrieve a specific PixKey::Log
@@ -60,8 +59,8 @@ module StarkInfra
60
59
  # ## Return:
61
60
  # - generator of PixKey::Log objects with updated attributes
62
61
  def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, key_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
  ids: ids,
67
66
  limit: limit,
@@ -93,8 +92,8 @@ module StarkInfra
93
92
  # - list of PixKey::Log objects with updated attributes
94
93
  # - cursor to retrieve the next page of Log objects
95
94
  def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, key_ids: nil, user: nil)
96
- after = StarkInfra::Utils::Checks.check_date(after)
97
- before = StarkInfra::Utils::Checks.check_date(before)
95
+ after = StarkCore::Utils::Checks.check_date(after)
96
+ before = StarkCore::Utils::Checks.check_date(before)
98
97
  StarkInfra::Utils::Rest.get_page(
99
98
  cursor: cursor,
100
99
  ids: ids,
@@ -115,7 +114,7 @@ module StarkInfra
115
114
  resource_maker: proc { |json|
116
115
  Log.new(
117
116
  id: json['id'],
118
- key: StarkInfra::Utils::API.from_api_json(key_maker, json['key']),
117
+ key: StarkCore::Utils::API.from_api_json(key_maker, json['key']),
119
118
  type: json['type'],
120
119
  errors: json['errors'],
121
120
  created: json['created']
data/lib/pixkey/pixkey.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require('starkcore')
3
4
  require_relative('../utils/rest')
4
- require_relative('../utils/checks')
5
- require_relative('../utils/resource')
6
5
 
7
6
  module StarkInfra
8
7
  # # PixKey object
@@ -34,7 +33,7 @@ module StarkInfra
34
33
  # - bank_name [string]: name of the bank that holds the account linked to the PixKey. ex: 'StarkBank'
35
34
  # - type [string]: type of the PixKey. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp',
36
35
  # - created [DateTime]: creation datetime for the PixKey. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
37
- class PixKey < StarkInfra::Utils::Resource
36
+ class PixKey < StarkCore::Utils::Resource
38
37
  attr_reader :account_created, :account_number, :account_type, :branch_code, :name, :tax_id, :id,
39
38
  :tags, :owned, :owner_type, :status, :bank_code, :bank_name, :type, :created
40
39
  def initialize(
@@ -49,13 +48,13 @@ module StarkInfra
49
48
  @name = name
50
49
  @tax_id = tax_id
51
50
  @tags = tags
52
- @owned = StarkInfra::Utils::Checks.check_datetime(owned)
51
+ @owned = StarkCore::Utils::Checks.check_datetime(owned)
53
52
  @owner_type = owner_type
54
53
  @status = status
55
54
  @bank_code = bank_code
56
55
  @bank_name = bank_name
57
56
  @type = type
58
- @created = StarkInfra::Utils::Checks.check_datetime(created)
57
+ @created = StarkCore::Utils::Checks.check_datetime(created)
59
58
  end
60
59
 
61
60
  # # Create a PixKey
@@ -115,8 +114,8 @@ module StarkInfra
115
114
  # ## Return:
116
115
  # - generator of PixKey objects with updated attributes
117
116
  def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, type: nil, user: nil)
118
- after = StarkInfra::Utils::Checks.check_date(after)
119
- before = StarkInfra::Utils::Checks.check_date(before)
117
+ after = StarkCore::Utils::Checks.check_date(after)
118
+ before = StarkCore::Utils::Checks.check_date(before)
120
119
  StarkInfra::Utils::Rest.get_stream(
121
120
  limit: limit,
122
121
  after: after,
@@ -150,8 +149,8 @@ module StarkInfra
150
149
  # - list of PixKey objects with updated attributes
151
150
  # - cursor to retrieve the next page of PixKey objects
152
151
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, type: nil, user: nil)
153
- after = StarkInfra::Utils::Checks.check_date(after)
154
- before = StarkInfra::Utils::Checks.check_date(before)
152
+ after = StarkCore::Utils::Checks.check_date(after)
153
+ before = StarkCore::Utils::Checks.check_date(before)
155
154
  StarkInfra::Utils::Rest.get_page(
156
155
  cursor: cursor,
157
156
  limit: limit,
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require('starkcore')
3
4
  require_relative('pixrequest')
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 PixRequest
@@ -18,11 +17,11 @@ module StarkInfra
18
17
  # - type [string]: type of the PixRequest event which triggered the log creation. ex: "sent", "denied", "failed", "created", "success", "approved", "credited", "refunded", "processing"
19
18
  # - errors [list of strings]: list of errors linked to this PixRequest event.
20
19
  # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
21
- class Log < StarkInfra::Utils::Resource
20
+ class Log < StarkCore::Utils::Resource
22
21
  attr_reader :id, :created, :type, :errors, :request
23
22
  def initialize(id:, created:, type:, errors:, request:)
24
23
  super(id)
25
- @created = StarkInfra::Utils::Checks.check_datetime(created)
24
+ @created = StarkCore::Utils::Checks.check_datetime(created)
26
25
  @type = type
27
26
  @errors = errors
28
27
  @request = request
@@ -61,8 +60,8 @@ module StarkInfra
61
60
  # ## Return:
62
61
  # - generator of PixRequest::Log objects with updated attributes
63
62
  def self.query(limit: nil, after: nil, before: nil, types: nil, request_ids: nil, reconciliation_id: nil, user: nil)
64
- after = StarkInfra::Utils::Checks.check_date(after)
65
- before = StarkInfra::Utils::Checks.check_date(before)
63
+ after = StarkCore::Utils::Checks.check_date(after)
64
+ before = StarkCore::Utils::Checks.check_date(before)
66
65
  StarkInfra::Utils::Rest.get_stream(
67
66
  limit: limit,
68
67
  after: after,
@@ -94,8 +93,8 @@ module StarkInfra
94
93
  # - list of PixRequest::Log objects with updated attributes
95
94
  # - cursor to retrieve the next page of Log objects
96
95
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, request_ids: nil, reconciliation_id: nil, user: nil)
97
- after = StarkInfra::Utils::Checks.check_date(after)
98
- before = StarkInfra::Utils::Checks.check_date(before)
96
+ after = StarkCore::Utils::Checks.check_date(after)
97
+ before = StarkCore::Utils::Checks.check_date(before)
99
98
  StarkInfra::Utils::Rest.get_page(
100
99
  cursor: cursor,
101
100
  limit: limit,
@@ -116,7 +115,7 @@ module StarkInfra
116
115
  resource_maker: proc { |json|
117
116
  Log.new(
118
117
  id: json['id'],
119
- request: StarkInfra::Utils::API.from_api_json(request_maker, json['request']),
118
+ request: StarkCore::Utils::API.from_api_json(request_maker, json['request']),
120
119
  type: json['type'],
121
120
  errors: json['errors'],
122
121
  created: json['created']
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require('starkcore')
3
4
  require_relative('../utils/rest')
4
5
  require_relative('../utils/parse')
5
- require_relative('../utils/checks')
6
- require_relative('../utils/resource')
7
6
 
8
7
  module StarkInfra
9
8
  # # PixRequest object
@@ -52,7 +51,7 @@ module StarkInfra
52
51
  # - sender_bank_code [string]: code of the sender bank institution in Brazil. ex: '20018183'
53
52
  # - created [DateTime]: creation datetime for the PixRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
54
53
  # - updated [DateTime]: latest update datetime for the PixRequest. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
55
- class PixRequest < StarkInfra::Utils::Resource
54
+ class PixRequest < StarkCore::Utils::Resource
56
55
  attr_reader :amount, :external_id, :sender_name, :sender_tax_id, :sender_branch_code, :sender_account_number,
57
56
  :sender_account_type, :receiver_name, :receiver_tax_id, :receiver_bank_code, :receiver_account_number,
58
57
  :receiver_branch_code, :receiver_account_type, :end_to_end_id, :cashier_type,
@@ -93,8 +92,8 @@ module StarkInfra
93
92
  @status = status
94
93
  @flow = flow
95
94
  @sender_bank_code = sender_bank_code
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
  end
99
98
 
100
99
  # # Create PixRequests
@@ -147,8 +146,8 @@ module StarkInfra
147
146
  # ## Return:
148
147
  # - generator of PixRequest objects with updated attributes
149
148
  def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, end_to_end_ids: nil, external_ids: nil, user: nil)
150
- after = StarkInfra::Utils::Checks.check_date(after)
151
- before = StarkInfra::Utils::Checks.check_date(before)
149
+ after = StarkCore::Utils::Checks.check_date(after)
150
+ before = StarkCore::Utils::Checks.check_date(before)
152
151
  StarkInfra::Utils::Rest.get_stream(
153
152
  limit: limit,
154
153
  after: after,
@@ -184,8 +183,8 @@ module StarkInfra
184
183
  # - list of PixRequest objects with updated attributes
185
184
  # - cursor to retrieve the next page of PixRequest objects
186
185
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, end_to_end_ids: nil, external_ids: nil, user: nil)
187
- after = StarkInfra::Utils::Checks.check_date(after)
188
- before = StarkInfra::Utils::Checks.check_date(before)
186
+ after = StarkCore::Utils::Checks.check_date(after)
187
+ before = StarkCore::Utils::Checks.check_date(before)
189
188
  StarkInfra::Utils::Rest.get_page(
190
189
  cursor: cursor,
191
190
  limit: limit,
@@ -217,7 +216,7 @@ module StarkInfra
217
216
  # ## Return:
218
217
  # - Parsed PixRequest object
219
218
  def self.parse(content:, signature:, user: nil)
220
- request = StarkInfra::Utils::Parse.parse_and_verify(content: content, signature: signature, user: user, resource: resource)
219
+ request = StarkCore::Utils::Parse.parse_and_verify(content: content, signature: signature, user: user, resource: resource)
221
220
 
222
221
  !request.fee.nil? ? request.fee : 0
223
222
  !request.tags.nil? ? request.tags : []
@@ -2,8 +2,6 @@
2
2
 
3
3
  require_relative('pixreversal')
4
4
  require_relative('../utils/rest')
5
- require_relative('../utils/checks')
6
- require_relative('../utils/resource')
7
5
 
8
6
  module StarkInfra
9
7
  class PixReversal
@@ -19,14 +17,14 @@ module StarkInfra
19
17
  # - type [string]: type of the PixReversal event which triggered the log creation. ex: 'processing' or 'success'
20
18
  # - reversal [PixReversal]: PixReversal entity to which the log refers to.
21
19
  # - errors [list of strings]: list of errors linked to this PixReversal event.
22
- class Log < StarkInfra::Utils::Resource
20
+ class Log < StarkCore::Utils::Resource
23
21
  attr_reader :id, :created, :type, :errors, :reversal
24
22
  def initialize(id:, created:, type:, errors:, reversal:)
25
23
  super(id)
26
24
  @type = type
27
25
  @errors = errors
28
26
  @reversal = reversal
29
- @created = StarkInfra::Utils::Checks.check_datetime(created)
27
+ @created = StarkCore::Utils::Checks.check_datetime(created)
30
28
  end
31
29
 
32
30
  # # Retrieve a specific Log
@@ -60,8 +58,8 @@ module StarkInfra
60
58
  # ## Return:
61
59
  # - generator of Log objects with updated attributes
62
60
  def self.query(limit: nil, after: nil, before: nil, types: nil, reversal_ids: nil, user: nil)
63
- after = StarkInfra::Utils::Checks.check_date(after)
64
- before = StarkInfra::Utils::Checks.check_date(before)
61
+ after = StarkCore::Utils::Checks.check_date(after)
62
+ before = StarkCore::Utils::Checks.check_date(before)
65
63
  StarkInfra::Utils::Rest.get_stream(
66
64
  limit: limit,
67
65
  after: after,
@@ -91,8 +89,8 @@ module StarkInfra
91
89
  # - list of Log objects with updated attributes
92
90
  # - cursor to retrieve the next page of Log objects
93
91
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, reversal_ids: nil, user: nil)
94
- after = StarkInfra::Utils::Checks.check_date(after)
95
- before = StarkInfra::Utils::Checks.check_date(before)
92
+ after = StarkCore::Utils::Checks.check_date(after)
93
+ before = StarkCore::Utils::Checks.check_date(before)
96
94
  StarkInfra::Utils::Rest.get_page(
97
95
  cursor: cursor,
98
96
  limit: limit,
@@ -115,7 +113,7 @@ module StarkInfra
115
113
  created: json['created'],
116
114
  type: json['type'],
117
115
  errors: json['errors'],
118
- reversal: StarkInfra::Utils::API.from_api_json(reversal_maker, json['reversal'])
116
+ reversal: StarkCore::Utils::API.from_api_json(reversal_maker, json['reversal'])
119
117
  )
120
118
  }
121
119
  }
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require('starkcore')
3
4
  require_relative('../utils/rest')
4
5
  require_relative('../utils/parse')
5
- require_relative('../utils/checks')
6
- require_relative('../utils/resource')
7
6
 
8
7
  module StarkInfra
9
8
  # # PixReversal object
@@ -32,7 +31,7 @@ module StarkInfra
32
31
  # - flow [string]: direction of money flow. ex: 'in' or 'out'
33
32
  # - created [DateTime]: creation datetime for the PixReversal. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
34
33
  # - updated [DateTime]: latest update datetime for the PixReversal. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
35
- class PixReversal < StarkInfra::Utils::Resource
34
+ class PixReversal < StarkCore::Utils::Resource
36
35
  attr_reader :amount, :external_id, :end_to_end_id, :reason, :tags, :id, :return_id,
37
36
  :fee, :status, :flow, :created, :updated
38
37
  def initialize(
@@ -49,8 +48,8 @@ module StarkInfra
49
48
  @fee = fee
50
49
  @status = status
51
50
  @flow = flow
52
- @created = StarkInfra::Utils::Checks.check_datetime(created)
53
- @updated = StarkInfra::Utils::Checks.check_datetime(updated)
51
+ @created = StarkCore::Utils::Checks.check_datetime(created)
52
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
54
53
  end
55
54
 
56
55
  # # Create PixReversals
@@ -103,8 +102,8 @@ module StarkInfra
103
102
  # ## Return:
104
103
  # - generator of PixReversal objects with updated attributes
105
104
  def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, return_ids: nil, external_ids: nil, user: nil)
106
- after = StarkInfra::Utils::Checks.check_date(after)
107
- before = StarkInfra::Utils::Checks.check_date(before)
105
+ after = StarkCore::Utils::Checks.check_date(after)
106
+ before = StarkCore::Utils::Checks.check_date(before)
108
107
  StarkInfra::Utils::Rest.get_stream(
109
108
  limit: limit,
110
109
  after: after,
@@ -143,8 +142,8 @@ module StarkInfra
143
142
  StarkInfra::Utils::Rest.get_page(
144
143
  cursor: cursor,
145
144
  limit: limit,
146
- after: StarkInfra::Utils::Checks.check_date(after),
147
- before: StarkInfra::Utils::Checks.check_date(before),
145
+ after: StarkCore::Utils::Checks.check_date(after),
146
+ before: StarkCore::Utils::Checks.check_date(before),
148
147
  status: status,
149
148
  tags: tags,
150
149
  ids: ids,
@@ -171,7 +170,7 @@ module StarkInfra
171
170
  # ## Return:
172
171
  # - Parsed PixReversal object
173
172
  def self.parse(content:, signature:, user: nil)
174
- reversal = StarkInfra::Utils::Parse.parse_and_verify(
173
+ reversal = StarkCore::Utils::Parse.parse_and_verify(
175
174
  content: content,
176
175
  signature: signature,
177
176
  user: user,
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require('starkcore')
3
4
  require_relative('../utils/rest')
4
- require_relative('../utils/checks')
5
- require_relative('../utils/resource')
6
5
 
7
6
  module StarkInfra
8
7
  # # PixStatement object
@@ -27,17 +26,17 @@ module StarkInfra
27
26
  # - transaction_count [integer]: number of transactions that happened during the day that the PixStatement was requested. ex: 11
28
27
  # - created [DateTime]: creation datetime for the PixStatement. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
29
28
  # - updated [DateTime]: latest update datetime for the PixStatement. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
30
- class PixStatement < StarkInfra::Utils::Resource
29
+ class PixStatement < StarkCore::Utils::Resource
31
30
  attr_reader :after, :before, :type, :id, :status, :transaction_count, :created, :updated
32
31
  def initialize(after:, before:, type:, id: nil, status: nil, transaction_count: nil, created: nil, updated: nil)
33
32
  super(id)
34
- @after = StarkInfra::Utils::Checks.check_date(after)
35
- @before = StarkInfra::Utils::Checks.check_date(before)
33
+ @after = StarkCore::Utils::Checks.check_date(after)
34
+ @before = StarkCore::Utils::Checks.check_date(before)
36
35
  @type = type
37
36
  @status = status
38
37
  @transaction_count = transaction_count
39
- @created = StarkInfra::Utils::Checks.check_datetime(created)
40
- @updated = StarkInfra::Utils::Checks.check_datetime(updated)
38
+ @created = StarkCore::Utils::Checks.check_datetime(created)
39
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
41
40
  end
42
41
 
43
42
  # # Create a PixStatement object
@@ -0,0 +1,152 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+ require_relative('../utils/parse')
6
+
7
+ module StarkInfra
8
+
9
+ class Request
10
+
11
+ # # Retrieve any StarkInfra resource
12
+ #
13
+ # Receive a json of resources previously created in StarkInfra's API
14
+ #
15
+ # Parameters (required):
16
+ #
17
+ # - path [string]: StarkInfra resource's route. ex: "/pix-request/"
18
+ # - query [dict, default None]: Query parameters. ex: {"limit": 1, "status": paid}
19
+ #
20
+ # Parameters (optional):
21
+ #
22
+ # - user [Organization/Project object, default None]: Organization or Project object. Not necessary if StarkInfra.user
23
+ # was set before function call
24
+ #
25
+ # Return:
26
+ # - dict of StarkInfra objects with updated attributes
27
+
28
+ def self.get(path:, user: nil, query: nil)
29
+ content = StarkInfra::Utils::Rest.get_raw(
30
+ path: path,
31
+ user: user,
32
+ prefix: "Joker",
33
+ raiseException: false,
34
+ query: query
35
+ )
36
+ end
37
+
38
+ # # Create any StarkInfra resource
39
+ #
40
+ # Send a json to create StarkBank resources
41
+ #
42
+ # Parameters (required):
43
+ #
44
+ # - path [string]: StarkInfra resource's route. ex: "/pix-request/"
45
+ # - body [dict]: request parameters. ex: {"requests": [{"amount": 100, "name": "Iron Bank S.A.", "taxId": "20.018.183/0001-80"}]}
46
+ #
47
+ # Parameters (optional):
48
+ #
49
+ # - user [Organization/Project object, default None]: Organization or Project object. Not necessary if StarkInfra.user
50
+ # was set before function call
51
+ # - query [dict, default None]: Query parameters. ex: {"limit": 1, "status": paid}
52
+ #
53
+ # Return:
54
+ #
55
+ # - list of resources jsons with updated attributes
56
+
57
+ def self.post(path:, payload:, query: nil, user: nil)
58
+ content = StarkInfra::Utils::Rest.post_raw(
59
+ path: path,
60
+ query: query,
61
+ payload: payload,
62
+ user: user,
63
+ prefix: "Joker",
64
+ raiseException: false
65
+ )
66
+ end
67
+
68
+ # # Update any StarkInfra resource
69
+ #
70
+ # Send a json with parameters of StarkBank resources to update them
71
+ #
72
+ # Parameters (required):
73
+ #
74
+ # - path [string]: StarkInfra resource's route. ex: "/pix-request/5699165527090460"
75
+ # - body [dict]: request parameters. ex: {"amount": 100}
76
+ #
77
+ # Parameters (optional):
78
+ #
79
+ # - user [Organization/Project object, default None]: Organization or Project object. Not necessary if StarkInfra.user
80
+ # was set before function call
81
+ #
82
+ # Return:
83
+ # - json of the resource with updated attributes
84
+
85
+ def self.patch(path:, payload:, query: nil, user: nil)
86
+ content = StarkInfra::Utils::Rest.patch_raw(
87
+ path: path,
88
+ query: query,
89
+ payload: payload,
90
+ user: user,
91
+ prefix: "Joker",
92
+ raiseException: false
93
+ )
94
+ end
95
+
96
+ # # Put any StarkInfra resource
97
+ #
98
+ # Send a json with parameters of a StarkBank resources to create them.
99
+ # If the resource already exists, you will update it.
100
+ #
101
+ # Parameters (required):
102
+ #
103
+ # - path [string]: StarkInfra resource's route. ex: "/pix-request"
104
+ # - body [dict]: request parameters. ex: {"amount": 100}
105
+ #
106
+ # Parameters (optional):
107
+ #
108
+ # - user [Organization/Project object, default None]: Organization or Project object. Not necessary if StarkInfra.user
109
+ # was set before function call
110
+ #
111
+ # Return:
112
+ # - json of the resource with updated attributes
113
+
114
+ def self.put(path:, payload:, query: nil, user: nil)
115
+ content = StarkInfra::Utils::Rest.put_raw(
116
+ path: path,
117
+ query: query,
118
+ payload: payload,
119
+ user: user,
120
+ prefix: "Joker",
121
+ raiseException: false
122
+ )
123
+ end
124
+
125
+ # # Delete any StarkInfra resource
126
+ #
127
+ # Send parameters of StarkBank resources and delete them
128
+ #
129
+ # Parameters (required):
130
+ #
131
+ # - path [string]: StarkInfra resource's route. ex: "/pix-request/5699165527090460"
132
+ # - body [dict]: request parameters. ex: {"amount": 100}
133
+ #
134
+ # Parameters (optional):
135
+ #
136
+ # - user [Organization/Project object, default None]: Organization or Project object. Not necessary if StarkInfra.user
137
+ # was set before function call
138
+ #
139
+ # Return:
140
+ # - json of the resource with updated attributes
141
+
142
+ def self.delete(path:, query: nil, user: nil)
143
+ content = StarkInfra::Utils::Rest.delete_raw(
144
+ path: path,
145
+ query: query,
146
+ user: user,
147
+ prefix: "Joker",
148
+ raiseException: false
149
+ )
150
+ end
151
+ end
152
+ end
data/lib/starkinfra.rb CHANGED
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('key')
4
- require_relative('user/project')
5
- require_relative('user/organization')
6
3
  require_relative('brcodepreview/brcodepreview')
7
4
  require_relative('cardmethod/cardmethod')
8
5
  require_relative('creditnote/invoice/invoice')
@@ -63,12 +60,23 @@ require_relative('staticbrcode/staticbrcode')
63
60
  require_relative('webhook/webhook')
64
61
  require_relative('event/event')
65
62
  require_relative('event/attempt')
66
- require_relative('utils/endtoendid')
67
- require_relative('utils/returnid')
63
+ require_relative('request/request')
68
64
 
69
65
  # SDK to facilitate Ruby integrations with Stark Infra
70
66
  module StarkInfra
67
+
68
+ API_VERSION = 'v2'
69
+ SDK_VERSION = '0.5.0'
70
+ HOST = "infra"
71
+ public_constant :API_VERSION, :SDK_VERSION, :HOST;
72
+
71
73
  @user = nil
72
74
  @language = 'en-US'
73
- class << self; attr_accessor :user, :language; end
75
+ @timeout = 15
76
+ class << self; attr_accessor :user, :language, :timeout; end
77
+
78
+ Project = StarkCore::Project
79
+ Organization = StarkCore::Organization
80
+ Key = StarkCore::Key
81
+
74
82
  end
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require('starkcore')
3
4
  require_relative('../utils/rest')
4
5
  require_relative('../utils/parse')
5
- require_relative('../utils/checks')
6
- require_relative('../utils/resource')
7
6
 
8
7
  module StarkInfra
9
8
  # # StaticBrcode object
@@ -33,7 +32,7 @@ module StarkInfra
33
32
  # - url [string]: url link to the BR Code image. ex: 'https://brcode-h.development.starkinfra.com/static-qrcode/97756273400d42ce9086404fe10ea0d6.png'
34
33
  # - created [DateTime]: creation datetime for the StaticBrcode. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
35
34
  # - updated [DateTime]: latest update datetime for the StaticBrcode. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
36
- class StaticBrcode < StarkInfra::Utils::Resource
35
+ class StaticBrcode < StarkCore::Utils::Resource
37
36
  attr_reader :name, :key_id, :city, :amount, :cashier_bank_code, :description, :reconciliation_id, :id, :tags, :uuid, :url, :created, :updated
38
37
  def initialize(
39
38
  name:, key_id:, city:, amount:, cashier_bank_code: nil, description: nil, reconciliation_id: nil, id: nil, tags:nil, uuid: nil, url: nil, created: nil, updated: nil
@@ -49,8 +48,8 @@ module StarkInfra
49
48
  @tags = tags
50
49
  @uuid = uuid
51
50
  @url = url
52
- @created = StarkInfra::Utils::Checks.check_datetime(created)
53
- @updated = StarkInfra::Utils::Checks.check_datetime(updated)
51
+ @created = StarkCore::Utils::Checks.check_datetime(created)
52
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
54
53
  end
55
54
 
56
55
  # # Create StaticBrcodes
@@ -100,8 +99,8 @@ module StarkInfra
100
99
  # ## Return:
101
100
  # - generator of StaticBrcode objects with updated attributes
102
101
  def self.query(limit: nil, after: nil, before: nil, uuids: nil, tags: nil, user: nil)
103
- after = StarkInfra::Utils::Checks.check_date(after)
104
- before = StarkInfra::Utils::Checks.check_date(before)
102
+ after = StarkCore::Utils::Checks.check_date(after)
103
+ before = StarkCore::Utils::Checks.check_date(before)
105
104
  StarkInfra::Utils::Rest.get_stream(
106
105
  limit: limit,
107
106
  after: after,
@@ -130,8 +129,8 @@ module StarkInfra
130
129
  # - list of StaticBrcode objects with updated attributes
131
130
  # - cursor to retrieve the next page of StaticBrcode objects
132
131
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, tags: nil, uuids: nil, user: nil)
133
- after = StarkInfra::Utils::Checks.check_date(after)
134
- before = StarkInfra::Utils::Checks.check_date(before)
132
+ after = StarkCore::Utils::Checks.check_date(after)
133
+ before = StarkCore::Utils::Checks.check_date(before)
135
134
  StarkInfra::Utils::Rest.get_page(
136
135
  cursor: cursor,
137
136
  limit: limit,