belvo 1.1.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/belvo/options.rb +13 -0
- data/lib/belvo/resources.rb +50 -0
- data/lib/belvo/version.rb +1 -1
- data/lib/belvo.rb +6 -0
- 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: 2451a25febe9bcc2e507d13977720f0886f89da8ff9e65d639846ca029717a53
|
4
|
+
data.tar.gz: 0ab5eb4ff9f6196ebc876011f3485e4bcba7a7888cbd20264f0abaaf9380e158
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ecbbb2a7c36121c8f9bfffdb5dddc4e4d2eb9065e3405ae0574736c808b2d24796c292dfc98a2b50d3431875d8b25bf6db5aea9946f765f5a1dca3acf5fd4d9
|
7
|
+
data.tar.gz: 90490528e75a6cca01484b74094c750368191b726ad36530912c27dc560c49ae85b19856cb462947d6da9f07bce3eff5169265cb206e07a938eead59d3bd9ab1
|
data/Gemfile.lock
CHANGED
data/lib/belvo/options.rb
CHANGED
@@ -152,6 +152,19 @@ module Belvo
|
|
152
152
|
)
|
153
153
|
end
|
154
154
|
|
155
|
+
# @!class TaxDeclarationOptions < Faraday::Options
|
156
|
+
# Contains configurable properties of a TaxDeclaration
|
157
|
+
# @!attribute save_data [rw] Should data be persisted or not.
|
158
|
+
# @!attribute token [rw] OTP token required by the institution
|
159
|
+
# @!attribute attach_pdf [rw] Should the PDF file be included in the
|
160
|
+
# response or not.
|
161
|
+
class TaxDeclarationOptions < Faraday::Options.new(
|
162
|
+
:token,
|
163
|
+
:save_data,
|
164
|
+
:attach_pdf
|
165
|
+
)
|
166
|
+
end
|
167
|
+
|
155
168
|
# @!class TaxRetentionsOptions < Faraday::Options
|
156
169
|
# Contains configurable properties of a tax retention
|
157
170
|
# @!attribute save_data [rw] Indicates whether or not to persist the
|
data/lib/belvo/resources.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'date'
|
4
4
|
require 'belvo/options'
|
5
5
|
require 'belvo/utils'
|
6
|
+
require 'belvo/exceptions'
|
6
7
|
|
7
8
|
module Belvo
|
8
9
|
# Represents a consumable REST resource from Belvo API
|
@@ -185,6 +186,24 @@ module Belvo
|
|
185
186
|
@endpoint = 'api/transactions/'
|
186
187
|
end
|
187
188
|
|
189
|
+
# List all transactions for specific link id
|
190
|
+
# @param id [String] Resource ID
|
191
|
+
# @param params [Hash] Extra parameters sent as query strings.
|
192
|
+
# @return [Array] List of results when no block is passed.
|
193
|
+
# @yield [Hash] Each result to be processed individually.
|
194
|
+
# @raise [RequestError] If response code is different than 2XX
|
195
|
+
def list(params: nil)
|
196
|
+
params = {} if params.nil?
|
197
|
+
unless params.key?(:link)
|
198
|
+
raise RequestError.new(
|
199
|
+
'Link id required',
|
200
|
+
400,
|
201
|
+
'A link ID is required to list transactions'
|
202
|
+
)
|
203
|
+
end
|
204
|
+
@session.list(@endpoint, params: params)
|
205
|
+
end
|
206
|
+
|
188
207
|
# Retrieve transactions from an existing link
|
189
208
|
# @param link [String] Link UUID
|
190
209
|
# @param date_from [String] Date string (YYYY-MM-DD)
|
@@ -472,6 +491,37 @@ module Belvo
|
|
472
491
|
end
|
473
492
|
end
|
474
493
|
|
494
|
+
# A Tax declaration is the representation of the tax declaration document sent
|
495
|
+
# every year by a person or a business to the tax authority in the country.
|
496
|
+
class TaxDeclaration < Resource
|
497
|
+
def initialize(session)
|
498
|
+
super(session)
|
499
|
+
@endpoint = 'api/tax-declarations/'
|
500
|
+
end
|
501
|
+
|
502
|
+
# Retrieve tax declaration information for a specific fiscal link.
|
503
|
+
# @param link [String] Link UUID
|
504
|
+
# @param year_from [Integer]
|
505
|
+
# @param year_to [Integer]
|
506
|
+
# @param options [TaxDeclarationOptions] Configurable properties
|
507
|
+
# @return [Hash] created tax declarations details
|
508
|
+
# @raise [RequestError] If response code is different than 2XX
|
509
|
+
def retrieve(link:, year_from:, year_to:, options: nil)
|
510
|
+
options = TaxDeclarationOptions.from(options)
|
511
|
+
body = {
|
512
|
+
link: link,
|
513
|
+
year_from: year_from,
|
514
|
+
year_to: year_to,
|
515
|
+
token: options.token,
|
516
|
+
save_data: options.save_data || true,
|
517
|
+
attach_pdf: options.attach_pdf
|
518
|
+
}.merge(options)
|
519
|
+
|
520
|
+
body = clean body: body
|
521
|
+
@session.post(@endpoint, body)
|
522
|
+
end
|
523
|
+
end
|
524
|
+
|
475
525
|
# A tax retention is the amount of money that the payer must deduct from the
|
476
526
|
# total amount of a purchase invoice, according to the regulations of the
|
477
527
|
# fiscal institution.
|
data/lib/belvo/version.rb
CHANGED
data/lib/belvo.rb
CHANGED
@@ -104,6 +104,12 @@ module Belvo
|
|
104
104
|
@tax_returns = TaxReturn.new @session
|
105
105
|
end
|
106
106
|
|
107
|
+
# Provides access to TaxDeclarations resource
|
108
|
+
# @return [TaxDeclaration]
|
109
|
+
def tax_declarations
|
110
|
+
@tax_declarations = TaxDeclaration.new @session
|
111
|
+
end
|
112
|
+
|
107
113
|
# Provides access to TaxStatus resource
|
108
114
|
# @return [TaxStatus]
|
109
115
|
def tax_status
|
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.
|
4
|
+
version: 1.3.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-
|
11
|
+
date: 2022-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|