quaderno 2.0.1 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +35 -0
- data/README.md +31 -6
- data/changelog.md +11 -0
- data/lib/quaderno-ruby/base.rb +8 -1
- data/lib/quaderno-ruby/exceptions/exceptions.rb +5 -0
- data/lib/quaderno-ruby/report_request.rb +4 -0
- data/lib/quaderno-ruby/tax.rb +4 -2
- data/lib/quaderno-ruby/version.rb +1 -1
- data/lib/quaderno-ruby.rb +1 -1
- data/quaderno.gemspec +17 -18
- metadata +8 -7
- data/.travis.yml +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2a54020a3dc74c8a5e2404f97a769d1543a50fefe6ecb96525b9e9813dbf3c9
|
4
|
+
data.tar.gz: 266177a86d010c6ab328415ad48922c38114aff87c75d5033af90518eead03da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59597e1a56992dd3c1175dff0d3b6d7321870b04e990900a573945b10f827907d74ae89c6da565dd6ac18d6ed46f3e07af72533d5fdb23063194e0321e0e0a1e
|
7
|
+
data.tar.gz: 9ed734de5dd0490047b61dfe0f0a644dc071c1f0cd5bcf9ff3a51dd876990aa1966710b5c354f18ebe98170410af7d9bc9a1f6032e949bca0245599f9e1d3c79
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby-version: ['2.5', '2.6', '2.7', '3.0']
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
- name: Set up Ruby
|
27
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
28
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
29
|
+
# uses: ruby/setup-ruby@v1
|
30
|
+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
33
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
34
|
+
- name: Run tests
|
35
|
+
run: bundle exec rspec ./spec/**/*.rb
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Quaderno-ruby is a ruby wrapper for [Quaderno API] (https://github.com/quaderno/quaderno-api).
|
4
4
|
|
5
|
-
Current version is 2.
|
5
|
+
Current version is 2.1.1 See the changelog [here](https://github.com/quaderno/quaderno-ruby/blob/master/changelog.md)
|
6
6
|
|
7
7
|
## Installation & Configuration
|
8
8
|
|
@@ -19,6 +19,7 @@ To configure just add this to your initializers
|
|
19
19
|
config.auth_token = 'my_authenticate_token'
|
20
20
|
config.url = 'https://my_subdomain.quadernoapp.com/api/'
|
21
21
|
config.api_version = API_VERSION # Optional, defaults to the API version set in your account
|
22
|
+
config.user_agent_header = 'my custom user agent' # Optional, will make support for your account more efficient if you are doing oauth integrations
|
22
23
|
end
|
23
24
|
```
|
24
25
|
|
@@ -527,17 +528,17 @@ will delete the webhook with the id passed as parameter. If the deletion was suc
|
|
527
528
|
|
528
529
|
will calculate the taxes applied for a customer based on the data pased as parameters.
|
529
530
|
|
530
|
-
### Validate
|
531
|
+
### Validate tax ID
|
531
532
|
```ruby
|
532
533
|
country = 'IE'
|
533
|
-
|
534
|
+
tax_id = 'IE6388047V'
|
534
535
|
|
535
|
-
result = Quaderno::Tax.
|
536
|
+
result = Quaderno::Tax.validate_tax_id(country, tax_id) #=> Quaderno::Tax
|
536
537
|
|
537
538
|
result.valid #=> Boolean or nil
|
538
539
|
```
|
539
540
|
|
540
|
-
will validate the
|
541
|
+
will validate the tax ID or business number for the specified country.
|
541
542
|
|
542
543
|
## Evidences
|
543
544
|
|
@@ -584,6 +585,29 @@ will update the specified checkout session with the data of the hash passed as s
|
|
584
585
|
```
|
585
586
|
will delete the checkout session with the id passed as parameter. If the deletion was successful, an instance of `Quaderno::CheckoutSession` with the `deleted` attribute set to `true` will be returned.
|
586
587
|
|
588
|
+
## Managing report requests
|
589
|
+
|
590
|
+
### Getting report requests
|
591
|
+
```ruby
|
592
|
+
Quaderno::ReportRequest.all #=> Array
|
593
|
+
```
|
594
|
+
|
595
|
+
will return an array with all your report requests.
|
596
|
+
|
597
|
+
### Finding a report request
|
598
|
+
```ruby
|
599
|
+
Quaderno::ReportRequest.find(id) #=> Quaderno::ReportRequest
|
600
|
+
```
|
601
|
+
|
602
|
+
will return the report request with the id passed as parameter.
|
603
|
+
|
604
|
+
### Creating a new report request
|
605
|
+
|
606
|
+
```ruby
|
607
|
+
Quaderno::ReportRequest.create(params) #=> Quaderno::ReportRequest
|
608
|
+
```
|
609
|
+
|
610
|
+
will create a report request using the information of the hash passed as parameter and return an instance of Quaderno::ReportRequest with the created report request.
|
587
611
|
|
588
612
|
## Exceptions
|
589
613
|
Quaderno-ruby exceptions raise depending on the type of error:
|
@@ -603,6 +627,7 @@ Quaderno-ruby exceptions raise depending on the type of error:
|
|
603
627
|
|
604
628
|
Quaderno::Exceptions::RequiredFieldsEmptyOrInvalid # Raised if the format of the request is right but some validations failed. You can JSON parse the exception message to get which field triggered the exception. For example: '{"errors":{"vat_number":["is not a valid German vat number"]}}'
|
605
629
|
|
630
|
+
Quaderno::Exceptions::ServerError # Raised when Quaderno returns an HTTP response code of the 50X family. Try again later or contact support if the issue persists
|
606
631
|
```
|
607
632
|
|
608
633
|
All those exceptions inherit from `Quaderno::Exceptions::BaseException`.
|
@@ -614,7 +639,7 @@ Whenever you call the `all` method on one of the classes, the result will be a `
|
|
614
639
|
collection = Quaderno::Contact.all
|
615
640
|
|
616
641
|
collection.class #=> Quaderno::Collection
|
617
|
-
collection.
|
642
|
+
collection.has_more? #=> true
|
618
643
|
collection.next_page #=> another instance of
|
619
644
|
```
|
620
645
|
|
data/changelog.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.1.1
|
4
|
+
* Added assign operator to the user_agent_header
|
5
|
+
|
6
|
+
## 2.1.0
|
7
|
+
* Added a new `Quaderno::Exceptions::ServerError` exception for more transparency, and better control of workflows
|
8
|
+
* Added a `user_agent_header` optional configuration to make debugging oauth integrations easier
|
9
|
+
|
10
|
+
## 2.0.2
|
11
|
+
* Fix an issue with the parameters sent during the `validate_vat_number` request
|
12
|
+
* Renames `validate_vat_number` into `validate_tax_id`
|
13
|
+
|
3
14
|
## 2.0.1
|
4
15
|
* Fix an issue where requests would result in an error due to a missing `require`
|
5
16
|
|
data/lib/quaderno-ruby/base.rb
CHANGED
@@ -15,6 +15,7 @@ class Quaderno::Base < OpenStruct
|
|
15
15
|
@@rate_limit_info = nil
|
16
16
|
@@api_version = nil
|
17
17
|
@@url = PRODUCTION_URL
|
18
|
+
@@user_agent_suffix = nil
|
18
19
|
|
19
20
|
# Class methods
|
20
21
|
def self.api_model(klass)
|
@@ -46,6 +47,10 @@ class Quaderno::Base < OpenStruct
|
|
46
47
|
@@url = url
|
47
48
|
end
|
48
49
|
|
50
|
+
def self.user_agent_header=(custom_user_agent)
|
51
|
+
@@user_agent_suffix = custom_user_agent
|
52
|
+
end
|
53
|
+
|
49
54
|
def self.authorization(auth_token, mode = nil)
|
50
55
|
mode ||= :production
|
51
56
|
url = mode == :sandbox ? SANDBOX_URL : PRODUCTION_URL
|
@@ -56,6 +61,8 @@ class Quaderno::Base < OpenStruct
|
|
56
61
|
data.rate_limit_info = response
|
57
62
|
|
58
63
|
data
|
64
|
+
elsif response.response.is_a?(Net::HTTPServerError)
|
65
|
+
raise_exception(Quaderno::Exceptions::ServerError, 'Server error', response)
|
59
66
|
else
|
60
67
|
raise_exception(Quaderno::Exceptions::InvalidSubdomainOrToken, 'Invalid subdomain or token', response)
|
61
68
|
end
|
@@ -140,7 +147,7 @@ class Quaderno::Base < OpenStruct
|
|
140
147
|
end
|
141
148
|
|
142
149
|
def self.user_agent_header
|
143
|
-
{ "User-Agent" => "Quaderno Ruby Gem #{Quaderno::VERSION}" }
|
150
|
+
{ "User-Agent" => ["Quaderno Ruby Gem #{Quaderno::VERSION}", @@user_agent_suffix].compact.join(' - ') }
|
144
151
|
end
|
145
152
|
|
146
153
|
def self.version_header
|
@@ -24,6 +24,9 @@ module Quaderno::Exceptions
|
|
24
24
|
class UnsupportedApiVersion < BaseException
|
25
25
|
end
|
26
26
|
|
27
|
+
class ServerError < BaseException
|
28
|
+
end
|
29
|
+
|
27
30
|
def self.included(receiver)
|
28
31
|
receiver.send :extend, ClassMethods
|
29
32
|
end
|
@@ -50,6 +53,8 @@ module Quaderno::Exceptions
|
|
50
53
|
if params[:has_documents].nil? == false
|
51
54
|
raise_exception(Quaderno::Exceptions::HasAssociatedDocuments, party_response.body, party_response) if party_response.response.class == Net::HTTPClientError
|
52
55
|
end
|
56
|
+
|
57
|
+
raise_exception(Quaderno::Exceptions::ServerError, 'Server error', response) if party_response.response.is_a?(Net::HTTPServerError)
|
53
58
|
end
|
54
59
|
|
55
60
|
def raise_exception(klass, message, response)
|
data/lib/quaderno-ruby/tax.rb
CHANGED
@@ -26,11 +26,11 @@ class Quaderno::Tax < Quaderno::Base
|
|
26
26
|
data
|
27
27
|
end
|
28
28
|
|
29
|
-
def self.
|
29
|
+
def self.validate_tax_id(country, tax_id, options = {})
|
30
30
|
authentication = get_authentication(options.merge(api_model: api_model))
|
31
31
|
|
32
32
|
response = get("#{authentication[:url]}tax_ids/validate.json",
|
33
|
-
query: { country: country,
|
33
|
+
query: { country: country, tax_id: tax_id },
|
34
34
|
basic_auth: authentication[:basic_auth],
|
35
35
|
headers: default_headers.merge(authentication[:headers])
|
36
36
|
)
|
@@ -42,6 +42,8 @@ class Quaderno::Tax < Quaderno::Base
|
|
42
42
|
|
43
43
|
data
|
44
44
|
end
|
45
|
+
# TODO: Temporary alias to be removed in future releases
|
46
|
+
self.singleton_class.send(:alias_method, :validate_vat_number, :validate_tax_id)
|
45
47
|
|
46
48
|
def self.reports(options = {})
|
47
49
|
authentication = get_authentication(options.merge(api_model: api_model))
|
data/lib/quaderno-ruby.rb
CHANGED
@@ -10,4 +10,4 @@ require 'quaderno-ruby/helpers/authentication'
|
|
10
10
|
require 'quaderno-ruby/collection'
|
11
11
|
|
12
12
|
%w(block crud deliver payment retrieve).each { |filename| require "quaderno-ruby/behavior/#{filename}" }
|
13
|
-
%w(base contact item invoice receipt credit income estimate expense recurring document_item report evidence payment webhook tax checkout_session).each { |filename| require "quaderno-ruby/#{ filename }" }
|
13
|
+
%w(base contact item invoice receipt credit income estimate expense recurring document_item report report_request evidence payment webhook tax checkout_session).each { |filename| require "quaderno-ruby/#{ filename }" }
|
data/quaderno.gemspec
CHANGED
@@ -4,30 +4,29 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'quaderno-ruby/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'quaderno'
|
8
8
|
spec.version = Quaderno::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email =
|
9
|
+
spec.authors = ['Recrea']
|
10
|
+
spec.email = 'carlos@recrea.es'
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.licenses = [
|
12
|
+
spec.summary = 'Ruby wrapper for the Quaderno API (https://quaderno.io/docs/api)'
|
13
|
+
spec.description = ' A ruby wrapper for Quaderno API '
|
14
|
+
spec.homepage = 'http://github.com/quaderno/quaderno-ruby'
|
15
|
+
spec.licenses = ['MIT']
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir =
|
18
|
+
spec.bindir = 'exe'
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = %w(lib)
|
21
|
-
spec.date =
|
21
|
+
spec.date = '2018-05-07'
|
22
22
|
spec.extra_rdoc_files = %w(LICENSE.txt README.md)
|
23
23
|
|
24
|
-
|
25
|
-
spec.
|
26
|
-
spec.add_development_dependency('
|
27
|
-
spec.add_development_dependency('
|
28
|
-
spec.add_development_dependency('
|
29
|
-
spec.add_development_dependency('
|
30
|
-
spec.add_development_dependency(
|
31
|
-
spec.add_development_dependency(
|
32
|
-
spec.add_development_dependency("rspec", "~> 3.0")
|
24
|
+
spec.add_dependency('httparty', '~> 0.13')
|
25
|
+
spec.add_development_dependency('rdoc', '>= 6.3.1')
|
26
|
+
spec.add_development_dependency('activesupport', '~> 4.2.0')
|
27
|
+
spec.add_development_dependency('webmock', '~> 1.22.6')
|
28
|
+
spec.add_development_dependency('vcr', '>= 0')
|
29
|
+
spec.add_development_dependency('bundler', '~> 2.2')
|
30
|
+
spec.add_development_dependency('rake', '>= 12.3.3')
|
31
|
+
spec.add_development_dependency('rspec', '~> 3.0')
|
33
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quaderno
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Recrea
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 6.3.1
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 6.3.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,9 +131,9 @@ extra_rdoc_files:
|
|
131
131
|
- README.md
|
132
132
|
files:
|
133
133
|
- ".document"
|
134
|
+
- ".github/workflows/test.yml"
|
134
135
|
- ".gitignore"
|
135
136
|
- ".rspec"
|
136
|
-
- ".travis.yml"
|
137
137
|
- Gemfile
|
138
138
|
- LICENSE.txt
|
139
139
|
- README.md
|
@@ -164,6 +164,7 @@ files:
|
|
164
164
|
- lib/quaderno-ruby/receipt.rb
|
165
165
|
- lib/quaderno-ruby/recurring.rb
|
166
166
|
- lib/quaderno-ruby/report.rb
|
167
|
+
- lib/quaderno-ruby/report_request.rb
|
167
168
|
- lib/quaderno-ruby/tax.rb
|
168
169
|
- lib/quaderno-ruby/version.rb
|
169
170
|
- lib/quaderno-ruby/webhook.rb
|
@@ -187,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
188
|
- !ruby/object:Gem::Version
|
188
189
|
version: '0'
|
189
190
|
requirements: []
|
190
|
-
rubygems_version: 3.
|
191
|
+
rubygems_version: 3.1.6
|
191
192
|
signing_key:
|
192
193
|
specification_version: 4
|
193
194
|
summary: Ruby wrapper for the Quaderno API (https://quaderno.io/docs/api)
|
data/.travis.yml
DELETED