quaderno 2.0.2 → 2.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/.github/workflows/test.yml +35 -0
- data/README.md +27 -2
- data/changelog.md +4 -0
- data/lib/quaderno-ruby/base.rb +4 -1
- data/lib/quaderno-ruby/exceptions/exceptions.rb +5 -0
- data/lib/quaderno-ruby/report_request.rb +4 -0
- 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: a9b1cc29c32e037177c8c590bf7aeec9712e6313445aa7e496584a56e773764f
|
4
|
+
data.tar.gz: cf3ff48c4eb21de4f6669f4cb69350c2d8393f6318ea15899a559c5d865a711b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce39d849088fe2d0203af6cb46f2d1af55b9ea364be9cc72f28ae5276426352a0b8c2f6c1e5433e5af6afa5997e1b10d61b9c7721629ed69bc11e03cefbebcfb
|
7
|
+
data.tar.gz: d822575449a512681d494565381beb6e5bb50f5ef6b680d3b3d2c7e90c86e84d1d747026c915398bae87c3244eeeca4c57ed3a7983a6774a104dca0a443b85ca
|
@@ -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.0
|
5
|
+
Current version is 2.1.0 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
|
|
@@ -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,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.1.0
|
4
|
+
* Added a new `Quaderno::Exceptions::ServerError` exception for more transparency, and better control of workflows
|
5
|
+
* Added a `user_agent_header` optional configuration to make debugging oauth integrations easier
|
6
|
+
|
3
7
|
## 2.0.2
|
4
8
|
* Fix an issue with the parameters sent during the `validate_vat_number` request
|
5
9
|
* Renames `validate_vat_number` into `validate_tax_id`
|
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)
|
@@ -56,6 +57,8 @@ class Quaderno::Base < OpenStruct
|
|
56
57
|
data.rate_limit_info = response
|
57
58
|
|
58
59
|
data
|
60
|
+
elsif response.response.is_a?(Net::HTTPServerError)
|
61
|
+
raise_exception(Quaderno::Exceptions::ServerError, 'Server error', response)
|
59
62
|
else
|
60
63
|
raise_exception(Quaderno::Exceptions::InvalidSubdomainOrToken, 'Invalid subdomain or token', response)
|
61
64
|
end
|
@@ -140,7 +143,7 @@ class Quaderno::Base < OpenStruct
|
|
140
143
|
end
|
141
144
|
|
142
145
|
def self.user_agent_header
|
143
|
-
{ "User-Agent" => "Quaderno Ruby Gem #{Quaderno::VERSION}" }
|
146
|
+
@_user_agent_header ||= { "User-Agent" => ["Quaderno Ruby Gem #{Quaderno::VERSION}", @@user_agent_suffix].compact.join(' - ') }
|
144
147
|
end
|
145
148
|
|
146
149
|
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.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.0
|
4
|
+
version: 2.1.0
|
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.0.
|
191
|
+
rubygems_version: 3.0.3
|
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