belvo 1.0.1 → 1.1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +13 -1
- data/lib/belvo/options.rb +20 -1
- data/lib/belvo/resources.rb +44 -1
- data/lib/belvo/version.rb +1 -1
- data/lib/belvo.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77535d19fd4a624ef494fa4c6354fc427bbfa388122398bace8dbe011207a006
|
4
|
+
data.tar.gz: e7655524ec6125db8fadb1f1b7fbee29e82685a4ead7edfecaec56a618f09bda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6366c18991ba3ff5b24efbfde467560a05d52d1392f349cf8a38c0515a59bba430fa2456e0fbcf35fdc89a0a28cdd43756371e5bc0dcc106afc6e03e3f845bac
|
7
|
+
data.tar.gz: 2ea9b99bd9dba5890256ca1c3404943d08b606187f8ecf6453f133d047955fca96691224b98d816699144bb6110353902b71e3543934e858d1834c76762630db
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -81,7 +81,7 @@ begin
|
|
81
81
|
username: 'janedoe',
|
82
82
|
password: 'super-secret',
|
83
83
|
options: { access_mode: Belvo::Link::AccessMode::SINGLE }
|
84
|
-
|
84
|
+
)
|
85
85
|
|
86
86
|
belvo.accounts.retrieve(link: new_link['id'])
|
87
87
|
|
@@ -94,6 +94,18 @@ rescue Belvo::RequestError => e
|
|
94
94
|
end
|
95
95
|
```
|
96
96
|
|
97
|
+
## Pagination
|
98
|
+
|
99
|
+
All `list` methods only return the first page of results. If you want to iterate by all pages, you will need to specify the `page` as a parameter:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
#`api/transactions`
|
103
|
+
...
|
104
|
+
belvo.transactions.list(params: {page: "2"})
|
105
|
+
...
|
106
|
+
```
|
107
|
+
When the result of your call is `nil`, this indicates that there are no more pages to iterate over.
|
108
|
+
|
97
109
|
**Note:** If you create a `Link` without specifying [access_mode](https://docs.belvo.com/#operation/RegisterLink), the SDK will respect the default value from the API.
|
98
110
|
|
99
111
|
## Development
|
data/lib/belvo/options.rb
CHANGED
@@ -152,9 +152,28 @@ module Belvo
|
|
152
152
|
)
|
153
153
|
end
|
154
154
|
|
155
|
+
# @!class TaxRetentionsOptions < Faraday::Options
|
156
|
+
# Contains configurable properties of a tax retention
|
157
|
+
# @!attribute save_data [rw] Indicates whether or not to persist the
|
158
|
+
# data in Belvo. By default, this is set to `true` and we return a
|
159
|
+
# 201 Created response. When set to `false`, the data won't be persisted
|
160
|
+
# and we return a 200 OK response.
|
161
|
+
# @!attribute attach_xml [rw] When set to `true`, you will receive the XML
|
162
|
+
# tax retention in the response.
|
163
|
+
class TaxRetentionsOptions < Faraday::Options.new(
|
164
|
+
:save_data,
|
165
|
+
:attach_xml,
|
166
|
+
:date_from,
|
167
|
+
:date_to
|
168
|
+
)
|
169
|
+
end
|
170
|
+
|
155
171
|
# @!class TaxStatusOptions < Faraday::Options
|
156
172
|
# Contains configurable properties of a TaxStatus
|
157
|
-
# @!attribute save_data [rw]
|
173
|
+
# @!attribute save_data [rw] Indicates whether or not to persist the data
|
174
|
+
# in Belvo. By default, this is set to `true` and we return a 201 Created
|
175
|
+
# response. When set to `false`, the data won't be persisted and we return
|
176
|
+
# a 200 OK response.
|
158
177
|
# @!attribute token [rw] OTP token required by the institution
|
159
178
|
# @!attribute attach_pdf [rw] Should the PDF file be included in the
|
160
179
|
# response or not.
|
data/lib/belvo/resources.rb
CHANGED
@@ -472,6 +472,48 @@ module Belvo
|
|
472
472
|
end
|
473
473
|
end
|
474
474
|
|
475
|
+
# A tax retention is the amount of money that the payer must deduct from the
|
476
|
+
# total amount of a purchase invoice, according to the regulations of the
|
477
|
+
# fiscal institution.
|
478
|
+
class TaxRetentions < Resource
|
479
|
+
def initialize(session)
|
480
|
+
super(session)
|
481
|
+
@endpoint = 'api/tax-retentions/'
|
482
|
+
end
|
483
|
+
|
484
|
+
class TaxRetentionsType
|
485
|
+
INFLOW = 'inflow'
|
486
|
+
OUTFLOW = 'outflow'
|
487
|
+
end
|
488
|
+
|
489
|
+
# Retrieve tax retentions from a specific fiscal link.
|
490
|
+
# @param link [String] The `link.id` that you want to get information
|
491
|
+
# for (UUID).
|
492
|
+
# @param type [TaxRetentionsType] The type of tax retention in relation to
|
493
|
+
# the invoice (from the perspective of the Link owner). `OUTFLOW` relates
|
494
|
+
# to a tax retention for a sent invoice. `INFLOW` relates to a tax
|
495
|
+
# retention for a received invoice. (inflow or outflow)
|
496
|
+
# @param options [TaxRetentionsOptions] Configurable properties
|
497
|
+
def retrieve(link:, type:, options: nil)
|
498
|
+
options = TaxRetentionsOptions.from(options)
|
499
|
+
body = {
|
500
|
+
link: link,
|
501
|
+
date_from: options.date_from,
|
502
|
+
date_to: options.date_to,
|
503
|
+
save_data: options.save_data,
|
504
|
+
attach_xml: options.attach_xml,
|
505
|
+
type: type
|
506
|
+
}.merge(options)
|
507
|
+
body = clean body: body
|
508
|
+
@session.post(@endpoint, body)
|
509
|
+
end
|
510
|
+
|
511
|
+
def resume(_session_id, _token, _link: nil)
|
512
|
+
raise NotImplementedError \
|
513
|
+
'TaxRetentions does not support resuming a session'
|
514
|
+
end
|
515
|
+
end
|
516
|
+
|
475
517
|
# A Tax status is the representation of the tax situation of a person or a
|
476
518
|
# business to the tax authority in the country.
|
477
519
|
class TaxStatus < Resource
|
@@ -498,7 +540,8 @@ module Belvo
|
|
498
540
|
end
|
499
541
|
|
500
542
|
def resume(_session_id, _token, _link: nil)
|
501
|
-
raise NotImplementedError
|
543
|
+
raise NotImplementedError \
|
544
|
+
'TaxRetentions does not support resuming a session.'
|
502
545
|
end
|
503
546
|
end
|
504
547
|
|
data/lib/belvo/version.rb
CHANGED
data/lib/belvo.rb
CHANGED
@@ -110,7 +110,13 @@ module Belvo
|
|
110
110
|
@tax_status = TaxStatus.new @session
|
111
111
|
end
|
112
112
|
|
113
|
-
# Provides access to
|
113
|
+
# Provides access to the TaxRetentions resource
|
114
|
+
# @return [TaxRetentions]
|
115
|
+
def tax_retentions
|
116
|
+
@tax_retentions = TaxRetentions.new @session
|
117
|
+
end
|
118
|
+
|
119
|
+
# Provides access to the Institutions resource
|
114
120
|
# @return [Institution]
|
115
121
|
def institutions
|
116
122
|
@institutions = Institution.new @session
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: belvo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Belvo Finance S.L.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05
|
11
|
+
date: 2022-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|