asaas-sdk 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +6 -1
- data/lib/asaas/list_object.rb +15 -13
- data/lib/asaas/resources/base.rb +8 -13
- data/lib/asaas/resources/finance.rb +5 -4
- data/lib/asaas/resources/has_client.rb +6 -1
- data/lib/asaas/resources/transfer.rb +6 -0
- data/lib/asaas/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e1e48c5ecf2b4a9ad5d592669c2c3999196cc5fdaee7425fbd7f24137d72c715
|
|
4
|
+
data.tar.gz: a2d31385b28339e9415f1c458a12bfdb0de6634361e5ed390c8389d7defccf53
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 44ba93d66d206d166e4724873b2f7e8afdc1fd54ede61fab34d01a297c2209945a6293d0003a9c773df0b14291666d46afd57c2a0ed8f64da845553d562eca5a
|
|
7
|
+
data.tar.gz: 2a94a9fb4edea9fb562c94e8704b2411361311514d1c66a910baa814514484187ab630275159e119e9a5c7236ba54caa9f2ab5da103a97827b3dfb5304fd2425
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.1] - 2026-11-12
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `Transfer.cancel(id, opts)` calls `DELETE /transfers/:id/cancel`. `Transfer.delete`
|
|
14
|
+
hits `/transfers/:id`, which isn't the cancel endpoint.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- `update`, `delete`, `list`, `Finance.balance`, `Finance.statistics` and
|
|
18
|
+
`Finance.extract` now forward the per-call `retryable` and `timeout` options.
|
|
19
|
+
`ListObject#next_page` keeps them, so `auto_paging_each` honours them on every page.
|
|
20
|
+
|
|
10
21
|
## [0.1.0] - 2026-11-11
|
|
11
22
|
|
|
12
23
|
First public release, published as `asaas-sdk`. The Ruby namespace is `Asaas`;
|
data/README.md
CHANGED
|
@@ -131,6 +131,11 @@ automatically repeated after an ambiguous response, set `retryable: false` and
|
|
|
131
131
|
reconcile the payment before any new refund submission. Passing an idempotency
|
|
132
132
|
key forwards the header; it does not by itself prove provider-side deduplication.
|
|
133
133
|
|
|
134
|
+
The generic `create`, `retrieve`, `update`, `delete` and `list` (including the
|
|
135
|
+
pages `auto_paging_each` fetches), `Finance.balance`, `Finance.statistics`,
|
|
136
|
+
`Finance.extract` and `Transfer.cancel` accept the same `retryable` and
|
|
137
|
+
`timeout` options.
|
|
138
|
+
|
|
134
139
|
### Subscriptions
|
|
135
140
|
|
|
136
141
|
```ruby
|
|
@@ -192,7 +197,7 @@ Asaas::PaymentLink.add_image("lnk_123", image: "base64data")
|
|
|
192
197
|
Asaas::Transfer.create(value: 500.0, walletId: "wal_abc")
|
|
193
198
|
Asaas::Transfer.retrieve("tra_123")
|
|
194
199
|
Asaas::Transfer.list
|
|
195
|
-
Asaas::Transfer.
|
|
200
|
+
Asaas::Transfer.cancel("tra_123") # DELETE /transfers/:id/cancel
|
|
196
201
|
```
|
|
197
202
|
|
|
198
203
|
### Installments
|
data/lib/asaas/list_object.rb
CHANGED
|
@@ -6,15 +6,17 @@ module Asaas
|
|
|
6
6
|
|
|
7
7
|
attr_reader :data, :has_more, :total_count, :limit, :offset
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@
|
|
12
|
-
@
|
|
13
|
-
@
|
|
14
|
-
@
|
|
15
|
-
@
|
|
16
|
-
@
|
|
17
|
-
@
|
|
9
|
+
# request_options (retryable, timeout) also apply to every next_page call.
|
|
10
|
+
def initialize(attrs, client:, path:, params: {}, request_options: {})
|
|
11
|
+
@data = Array(attrs["data"]).map { AsaasObject.construct_from(_1) }
|
|
12
|
+
@has_more = attrs["hasMore"] || false
|
|
13
|
+
@total_count = attrs["totalCount"]
|
|
14
|
+
@limit = attrs["limit"]
|
|
15
|
+
@offset = attrs["offset"] || 0
|
|
16
|
+
@client = client
|
|
17
|
+
@path = path
|
|
18
|
+
@params = params
|
|
19
|
+
@request_options = request_options
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
def each(&block)
|
|
@@ -25,8 +27,8 @@ module Asaas
|
|
|
25
27
|
return nil unless @has_more
|
|
26
28
|
|
|
27
29
|
next_params = @params.merge("offset" => @offset + @limit, "limit" => @limit)
|
|
28
|
-
raw = @client.request(:get, @path, params: next_params)
|
|
29
|
-
self.class.new(raw, client: @client, path: @path, params: next_params)
|
|
30
|
+
raw = @client.request(:get, @path, params: next_params, **@request_options)
|
|
31
|
+
self.class.new(raw, client: @client, path: @path, params: next_params, request_options: @request_options)
|
|
30
32
|
end
|
|
31
33
|
|
|
32
34
|
def auto_paging_each(&block)
|
|
@@ -41,8 +43,8 @@ module Asaas
|
|
|
41
43
|
end
|
|
42
44
|
end
|
|
43
45
|
|
|
44
|
-
def self.construct_from(attrs, client:, path:, params: {})
|
|
45
|
-
new(attrs, client: client, path: path, params: params)
|
|
46
|
+
def self.construct_from(attrs, client:, path:, params: {}, request_options: {})
|
|
47
|
+
new(attrs, client: client, path: path, params: params, request_options: request_options)
|
|
46
48
|
end
|
|
47
49
|
|
|
48
50
|
def inspect
|
data/lib/asaas/resources/base.rb
CHANGED
|
@@ -14,36 +14,31 @@ module Asaas
|
|
|
14
14
|
:post,
|
|
15
15
|
resource_path,
|
|
16
16
|
params: params,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
idempotency_key: opts[:idempotency_key]
|
|
17
|
+
idempotency_key: opts[:idempotency_key],
|
|
18
|
+
**request_options(opts)
|
|
20
19
|
)
|
|
21
20
|
AsaasObject.construct_from(response)
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
def self.retrieve(id, opts = {})
|
|
25
|
-
response = client(opts).request(
|
|
26
|
-
:get,
|
|
27
|
-
"#{resource_path}/#{id}",
|
|
28
|
-
retryable: opts.fetch(:retryable, true),
|
|
29
|
-
timeout: opts[:timeout]
|
|
30
|
-
)
|
|
24
|
+
response = client(opts).request(:get, "#{resource_path}/#{id}", **request_options(opts))
|
|
31
25
|
AsaasObject.construct_from(response)
|
|
32
26
|
end
|
|
33
27
|
|
|
34
28
|
def self.update(id, params = {}, opts = {})
|
|
35
|
-
response = client(opts).request(:put, "#{resource_path}/#{id}", params: params)
|
|
29
|
+
response = client(opts).request(:put, "#{resource_path}/#{id}", params: params, **request_options(opts))
|
|
36
30
|
AsaasObject.construct_from(response)
|
|
37
31
|
end
|
|
38
32
|
|
|
39
33
|
def self.delete(id, opts = {})
|
|
40
|
-
response = client(opts).request(:delete, "#{resource_path}/#{id}")
|
|
34
|
+
response = client(opts).request(:delete, "#{resource_path}/#{id}", **request_options(opts))
|
|
41
35
|
AsaasObject.construct_from(response)
|
|
42
36
|
end
|
|
43
37
|
|
|
44
38
|
def self.list(params = {}, opts = {})
|
|
45
|
-
response = client(opts).request(:get, resource_path, params: params)
|
|
46
|
-
ListObject.construct_from(response, client: client(opts), path: resource_path, params: params
|
|
39
|
+
response = client(opts).request(:get, resource_path, params: params, **request_options(opts))
|
|
40
|
+
ListObject.construct_from(response, client: client(opts), path: resource_path, params: params,
|
|
41
|
+
request_options: request_options(opts))
|
|
47
42
|
end
|
|
48
43
|
end
|
|
49
44
|
end
|
|
@@ -6,19 +6,20 @@ module Asaas
|
|
|
6
6
|
extend HasClient
|
|
7
7
|
|
|
8
8
|
def self.balance(opts = {})
|
|
9
|
-
response = client(opts).request(:get, "/finance/balance")
|
|
9
|
+
response = client(opts).request(:get, "/finance/balance", **request_options(opts))
|
|
10
10
|
AsaasObject.construct_from(response)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def self.statistics(params = {}, opts = {})
|
|
14
|
-
response = client(opts).request(:get, "/finance/payment/statistics", params: params)
|
|
14
|
+
response = client(opts).request(:get, "/finance/payment/statistics", params: params, **request_options(opts))
|
|
15
15
|
AsaasObject.construct_from(response)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def self.extract(params = {}, opts = {})
|
|
19
19
|
path = "/financialTransactions"
|
|
20
|
-
response = client(opts).request(:get, path, params: params)
|
|
21
|
-
ListObject.construct_from(response, client: client(opts), path: path, params: params
|
|
20
|
+
response = client(opts).request(:get, path, params: params, **request_options(opts))
|
|
21
|
+
ListObject.construct_from(response, client: client(opts), path: path, params: params,
|
|
22
|
+
request_options: request_options(opts))
|
|
22
23
|
end
|
|
23
24
|
end
|
|
24
25
|
end
|
|
@@ -4,12 +4,17 @@ module Asaas
|
|
|
4
4
|
module Resources
|
|
5
5
|
module HasClient
|
|
6
6
|
def self.extended(base)
|
|
7
|
-
base.private_class_method(:client)
|
|
7
|
+
base.private_class_method(:client, :request_options)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def client(opts = {})
|
|
11
11
|
Client.new(api_key: opts[:api_key])
|
|
12
12
|
end
|
|
13
|
+
|
|
14
|
+
# Per-call transport options every request accepts: retry and timeout.
|
|
15
|
+
def request_options(opts = {})
|
|
16
|
+
{ retryable: opts.fetch(:retryable, true), timeout: opts[:timeout] }
|
|
17
|
+
end
|
|
13
18
|
end
|
|
14
19
|
end
|
|
15
20
|
end
|
|
@@ -4,6 +4,12 @@ module Asaas
|
|
|
4
4
|
module Resources
|
|
5
5
|
class Transfer < Base
|
|
6
6
|
def self.resource_path = "/transfers"
|
|
7
|
+
|
|
8
|
+
# Cancels a transfer that hasn't reached the bank yet.
|
|
9
|
+
def self.cancel(id, opts = {})
|
|
10
|
+
response = client(opts).request(:delete, "#{resource_path}/#{id}/cancel", **request_options(opts))
|
|
11
|
+
AsaasObject.construct_from(response)
|
|
12
|
+
end
|
|
7
13
|
end
|
|
8
14
|
end
|
|
9
15
|
end
|
data/lib/asaas/version.rb
CHANGED