starkbank 2.10.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b3c14df2e63024dc300445af57b93d5d7c03fbe7e40efc79f4b130684982118
4
- data.tar.gz: 621f032aa81a0c42d8d8df9491d5c66dfa1938207a9f68920d0f4abe7356cdef
3
+ metadata.gz: dd9a69de2b18932531236001ae087424da0ee70dbe7bbcef98247700e2708802
4
+ data.tar.gz: bdc7087b33f13f85f9f1cc0d5bb257f3ececfbe128efc13bdd749d90062a8c54
5
5
  SHA512:
6
- metadata.gz: 8e8317904c404ed9a8051169e0079d705224bbea35cf7c735b3f164c955cf212494c76fb3fbfbc74f0f75b89c7b55194ffac31e0efde0b2002ddb886029930b6
7
- data.tar.gz: 6f9c6037b10ae646945aa1163b5e64fb7ac70303767a12976a91ffa167bd8453dd7b0f7b32fece994bc6b976632ee67a5860c24a215135129ea4b535d354cdff
6
+ metadata.gz: d1efd923d66ad145799e10bdf3c8866a30c9762334cc2c017ca6252c0440200a2beca5b9458b29eedd2487edb12f99f3424fc6bcc7c958e2293dbe9e5b34bdeb
7
+ data.tar.gz: e783927a5d21f7d417b90d01442143de64cef5808db8e7cebae36e15700e546897b84dc429a1e297a38eb4dcc4ab9087f839580d858ba96454fe2d61f4a7ccae
@@ -131,6 +131,23 @@ module StarkBank
131
131
  )
132
132
  end
133
133
 
134
+ # # Update Deposit entity
135
+ #
136
+ # Update the Deposit by passing its id to be partially or fully reversed.
137
+ #
138
+ # ## Parameters (required):
139
+ # - id [string]: Deposit unique id. ex: '5656565656565656'
140
+ #
141
+ # ## Parameters (optional):
142
+ # - amount [string, nil]: The new amount of the Deposit. If the amount = 0 the Deposit will be fully reversed
143
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
144
+ #
145
+ # ## Return:
146
+ # - target Deposit with updated attributes
147
+ def self.update(id, amount: nil, user: nil)
148
+ StarkBank::Utils::Rest.patch_id(id: id, amount: amount, user: user, **resource)
149
+ end
150
+
134
151
  def self.resource
135
152
  {
136
153
  resource_name: 'Deposit',
@@ -18,19 +18,13 @@ module StarkBank
18
18
  # - owner_type [string]: DICT key owner type. ex 'naturalPerson' or 'legalPerson'
19
19
  # - bank_name [string]: bank name associated with the DICT key. ex: 'Stark Bank'
20
20
  # - ispb [string]: bank ISPB associated with the DICT key. ex: '20018183'
21
- # - branch_code [string]: bank account branch code associated with the DICT key. ex: '9585'
22
- # - account_number [string]: bank account number associated with the DICT key. ex: '9828282578010513'
23
- # - account_type [string]: bank account type associated with the DICT key. ex: 'checking', 'saving', 'salary' or 'payment'
21
+ # - branch_code [string]: encrypted bank account branch code associated with the DICT key. ex: 'ZW5jcnlwdGVkLWJyYW5jaC1jb2Rl'
22
+ # - account_number [string]: encrypted bank account number associated with the DICT key. ex: 'ZW5jcnlwdGVkLWFjY291bnQtbnVtYmVy'
23
+ # - account_type [string]: bank account type associated with the DICT key. ex: 'checking', 'savings', 'salary' or 'payment'
24
24
  # - status [string]: current DICT key status. ex: 'created', 'registered', 'canceled' or 'failed'
25
- # - account_created [DateTime or string]: creation datetime of the bank account associated with the DICT key. ex: '2020-11-05T14:55:08.812665+00:00'
26
- # - owned [DateTime or string]: datetime since when the current owner hold this DICT key. ex : '2020-11-05T14:55:08.812665+00:00'
27
- # - created [DateTime or string]: creation datetime for the DICT key. ex: '2020-03-10 10:30:00.000'
28
25
  class DictKey < StarkCore::Utils::Resource
29
26
  attr_reader :id, :type, :name, :tax_id, :owner_type, :bank_name, :ispb, :branch_code, :account_number, :account_type, :status, :account_created, :owned, :created
30
- def initialize(
31
- id:, type:, name:, tax_id:, owner_type:, bank_name:, ispb:, branch_code:, account_number:,
32
- account_type:, status:, account_created:, owned:, created:
33
- )
27
+ def initialize(id:, type:, name:, tax_id:, owner_type:, bank_name:, ispb:, branch_code:, account_number:, account_type:, status:)
34
28
  super(id)
35
29
  @type = type
36
30
  @name = name
@@ -42,9 +36,6 @@ module StarkBank
42
36
  @account_number = account_number
43
37
  @account_type = account_type
44
38
  @status = status
45
- @account_created = StarkCore::Utils::Checks.check_datetime(account_created)
46
- @owned = StarkCore::Utils::Checks.check_datetime(owned)
47
- @created = StarkCore::Utils::Checks.check_datetime(created)
48
39
  end
49
40
 
50
41
  # # Retrieve a specific DictKey
@@ -141,10 +132,7 @@ module StarkBank
141
132
  branch_code: json['branch_code'],
142
133
  account_number: json['account_number'],
143
134
  type: json['type'],
144
- status: json['status'],
145
- account_created: json['account_created'],
146
- owned: json['owned'],
147
- created: json['created']
135
+ status: json['status']
148
136
  )
149
137
  }
150
138
  }
@@ -221,6 +221,7 @@ module StarkBank
221
221
  # - amount [string, nil]: Nominal amount charged by the invoice. ex: 100 (R$1.00)
222
222
  # - due [datetime.date or string, default nil]: Invoice due date in UTC ISO format. ex: DateTime.new(2020, 3, 10, 10, 30, 12, 21)
223
223
  # - expiration [number, default nil]: time interval in seconds between the due date and the expiration date. ex 123456789
224
+ # - user [Organization/Project object]: Organization or Project object. Not necessary if StarkBank.user was set before function call
224
225
  #
225
226
  # ## Return:
226
227
  # - updated Invoice object
@@ -14,8 +14,6 @@ module StarkBank
14
14
  # - name [string]: Payment receiver name. ex: 'Tony Stark'
15
15
  # - tax_id [string]: Payment receiver tax ID. ex: '012.345.678-90'
16
16
  # - bank_code [string]: Payment receiver bank code. ex: '20018183'
17
- # - branch_code [string]: Payment receiver branch code. ex: '0001'
18
- # - account_number [string]: Payment receiver account number. ex: '1234567'
19
17
  # - account_type [string]: Payment receiver account type. ex: 'checking'
20
18
  # - allow_change [bool]: If True, the payment is able to receive amounts that are different from the nominal one. ex: True or False
21
19
  # - amount [integer]: Value in cents that this payment is expecting to receive. If 0, any value is accepted. ex: 123 (= R$1,23)
@@ -26,14 +24,12 @@ module StarkBank
26
24
  # - discount_amount [integer]: Current discount value in cents that this payment is expecting. ex: 123 (= R$1,23)
27
25
  # - reconciliation_id [string]: Reconciliation ID linked to this payment. ex: 'txId', 'payment-123'
28
26
  class BrcodePreview < StarkCore::Utils::SubResource
29
- attr_reader :status, :name, :tax_id, :bank_code, :branch_code, :account_number, :account_type, :allow_change, :amount, :nominal_amount, :interest_amount, :fine_amount, :reduction_amount, :discount_amount, :reconciliation_id
30
- def initialize(status:, name:, tax_id:, bank_code:, branch_code:, account_number:, account_type:, allow_change:, amount:, nominal_amount:, interest_amount:, fine_amount:, reduction_amount:, discount_amount:, reconciliation_id:)
27
+ attr_reader :status, :name, :tax_id, :bank_code, :account_type, :allow_change, :amount, :nominal_amount, :interest_amount, :fine_amount, :reduction_amount, :discount_amount, :reconciliation_id
28
+ def initialize(status:, name:, tax_id:, bank_code:, account_type:, allow_change:, amount:, nominal_amount:, interest_amount:, fine_amount:, reduction_amount:, discount_amount:, reconciliation_id:)
31
29
  @status = status
32
30
  @name = name
33
31
  @tax_id = tax_id
34
32
  @bank_code = bank_code
35
- @branch_code = branch_code
36
- @account_number = account_number
37
33
  @account_type = account_type
38
34
  @allow_change = allow_change
39
35
  @amount = amount
@@ -54,8 +50,6 @@ module StarkBank
54
50
  name: json['name'],
55
51
  tax_id: json['tax_id'],
56
52
  bank_code: json['bank_code'],
57
- branch_code: json['branch_code'],
58
- account_number: json['account_number'],
59
53
  account_type: json['account_type'],
60
54
  allow_change: json['allow_change'],
61
55
  amount: json['amount'],
@@ -0,0 +1,151 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+ require_relative('../utils/parse')
6
+
7
+ module StarkBank
8
+
9
+ class Request
10
+
11
+ # # Retrieve any StarkBank resource
12
+ #
13
+ # Receive a json of resources previously created in StarkBank's API
14
+ #
15
+ # Parameters (required):
16
+ #
17
+ # - path [string]: StarkBank resource's route. ex: "/invoice/"
18
+ # - query [json, 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 StarkBank.user
23
+ # was set before function call
24
+ #
25
+ # Return:
26
+ # - json of StarkBank objects with updated attributes
27
+
28
+ def self.get(path:, query: nil, user: nil)
29
+ content = StarkBank::Utils::Rest.get_raw(
30
+ path: path,
31
+ query: query,
32
+ user: user,
33
+ prefix: "Joker",
34
+ raiseException: false
35
+ )
36
+ end
37
+
38
+ # # Create any StarkBank resource
39
+ #
40
+ # Send a json to create StarkBank resources
41
+ #
42
+ # Parameters (required):
43
+ #
44
+ # - path [string]: StarkBank resource's route. ex: "/invoice/"
45
+ # - body [json]: request parameters. ex: {"invoices": [{"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 StarkBank.user
50
+ # was set before function call
51
+ # - query [json, 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 = StarkBank::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 StarkBank resource
69
+ #
70
+ # Send a json with parameters of StarkBank resources to update them
71
+ #
72
+ # Parameters (required):
73
+ #
74
+ # - path [string]: StarkBank resource's route. ex: "/invoice/5699165527090460"
75
+ # - body [json]: request parameters. ex: {"amount": 100}
76
+ #
77
+ # Parameters (optional):
78
+ #
79
+ # - user [Organization/Project object, default None]: Organization or Project object. Not necessary if StarkBank.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 = StarkBank::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 StarkBank 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]: StarkBank resource's route. ex: "/split-profile"
104
+ # - body [json]: request parameters. ex: {"profiles": [{"interval": day, "delay": "1"}]}
105
+ #
106
+ # Parameters (optional):
107
+ #
108
+ # - user [Organization/Project object, default None]: Organization or Project object. Not necessary if StarkBank.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 = StarkBank::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 StarkBank resource
126
+ #
127
+ # Send parameters of StarkBank resources and delete them
128
+ #
129
+ # Parameters (required):
130
+ #
131
+ # - path [string]: StarkBank resource's route. ex: "/transfer/5699165527090460"
132
+ #
133
+ # Parameters (optional):
134
+ #
135
+ # - user [Organization/Project object, default None]: Organization or Project object. Not necessary if StarkBank.user
136
+ # was set before function call
137
+ #
138
+ # Return:
139
+ # - json of the resource with updated attributes
140
+
141
+ def self.delete(path:, query: nil, user: nil)
142
+ content = StarkBank::Utils::Rest.delete_raw(
143
+ path: path,
144
+ query: query,
145
+ user: user,
146
+ prefix: "Joker",
147
+ raiseException: false
148
+ )
149
+ end
150
+ end
151
+ end
data/lib/starkbank.rb CHANGED
@@ -54,12 +54,13 @@ require_relative('payment_preview/boleto_preview')
54
54
  require_relative('payment_preview/tax_preview')
55
55
  require_relative('payment_preview/utility_preview')
56
56
  require_relative('institution/institution')
57
+ require_relative('request/request')
57
58
 
58
59
  # SDK to facilitate Ruby integrations with Stark Bank
59
60
  module StarkBank
60
61
 
61
62
  API_VERSION = 'v2'
62
- SDK_VERSION = '2.10.0'
63
+ SDK_VERSION = '2.12.0'
63
64
  HOST = "bank"
64
65
  public_constant :API_VERSION, :SDK_VERSION, :HOST;
65
66
 
data/lib/utils/rest.rb CHANGED
@@ -126,20 +126,6 @@ module StarkBank
126
126
  )
127
127
  end
128
128
 
129
- def self.post_raw(path:, payload:, user:, **query)
130
- return StarkCore::Utils::Rest.post_raw(
131
- host: StarkBank::HOST,
132
- sdk_version: StarkBank::SDK_VERSION,
133
- user: user ? user : StarkBank.user,
134
- path: path,
135
- payload: payload,
136
- api_version: StarkBank::API_VERSION,
137
- language: StarkBank.language,
138
- timeout: StarkBank.timeout,
139
- **query,
140
- )
141
- end
142
-
143
129
  def self.delete_id(resource_name:, resource_maker:, user:, id:)
144
130
  return StarkCore::Utils::Rest.delete_id(
145
131
  resource_name: resource_name,
@@ -168,6 +154,85 @@ module StarkBank
168
154
  **payload
169
155
  )
170
156
  end
157
+
158
+ def self.get_raw(path:, prefix: nil, raiseException: nil, user: nil, query: nil)
159
+ return StarkCore::Utils::Rest.get_raw(
160
+ host: StarkBank::HOST,
161
+ sdk_version: StarkBank::SDK_VERSION,
162
+ user: user ? user : StarkBank.user,
163
+ path: path,
164
+ api_version: StarkBank::API_VERSION,
165
+ language: StarkBank.language,
166
+ timeout: StarkBank.timeout,
167
+ prefix: prefix,
168
+ raiseException: raiseException,
169
+ query: query
170
+ )
171
+ end
172
+
173
+ def self.post_raw(path:, payload:, query: nil, prefix: nil, raiseException: nil, user:)
174
+
175
+ return StarkCore::Utils::Rest.post_raw(
176
+ host: StarkBank::HOST,
177
+ sdk_version: StarkBank::SDK_VERSION,
178
+ user: user ? user : StarkBank.user,
179
+ path: path,
180
+ payload: payload,
181
+ api_version: StarkBank::API_VERSION,
182
+ language: StarkBank.language,
183
+ timeout: StarkBank.timeout,
184
+ query: query,
185
+ prefix: prefix,
186
+ raiseException: raiseException
187
+ )
188
+ end
189
+
190
+ def self.patch_raw(path:, payload:, query: nil, prefix: nil, raiseException: nil, user: nil)
191
+ return StarkCore::Utils::Rest.patch_raw(
192
+ host: StarkBank::HOST,
193
+ sdk_version: StarkBank::SDK_VERSION,
194
+ user: user ? user : StarkBank.user,
195
+ path: path,
196
+ payload: payload,
197
+ api_version: StarkBank::API_VERSION,
198
+ language: StarkBank.language,
199
+ timeout: StarkBank.timeout,
200
+ query: query,
201
+ prefix: prefix,
202
+ raiseException: raiseException
203
+ )
204
+ end
205
+
206
+ def self.put_raw(path:, payload:, query: nil, prefix: nil, raiseException: nil, user: nil)
207
+ return StarkCore::Utils::Rest.put_raw(
208
+ host: StarkBank::HOST,
209
+ sdk_version: StarkBank::SDK_VERSION,
210
+ user: user ? user : StarkBank.user,
211
+ path: path,
212
+ payload: payload,
213
+ api_version: StarkBank::API_VERSION,
214
+ language: StarkBank.language,
215
+ timeout: StarkBank.timeout,
216
+ query: query,
217
+ prefix: prefix,
218
+ raiseException: raiseException
219
+ )
220
+ end
221
+
222
+ def self.delete_raw(path:, query: nil, prefix: nil, raiseException: nil, user: nil)
223
+ return StarkCore::Utils::Rest.delete_raw(
224
+ host: StarkBank::HOST,
225
+ sdk_version: StarkBank::SDK_VERSION,
226
+ user: user ? user : StarkBank.user,
227
+ path: path,
228
+ api_version: StarkBank::API_VERSION,
229
+ language: StarkBank.language,
230
+ timeout: StarkBank.timeout,
231
+ query: query,
232
+ prefix: prefix,
233
+ raiseException: raiseException
234
+ )
235
+ end
171
236
  end
172
237
  end
173
238
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starkbank
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - starkbank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-12 00:00:00.000000000 Z
11
+ date: 2024-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: starkcore
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.0
19
+ version: 0.2.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.0
26
+ version: 0.2.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -117,6 +117,7 @@ files:
117
117
  - lib/payment_preview/tax_preview.rb
118
118
  - lib/payment_preview/utility_preview.rb
119
119
  - lib/payment_request/payment_request.rb
120
+ - lib/request/request.rb
120
121
  - lib/starkbank.rb
121
122
  - lib/tax_payment/log.rb
122
123
  - lib/tax_payment/tax_payment.rb