vat_layer-ruby-3 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c2e19f08fa8ea210df08c646f54d033868e2a8e25cb5dd0388f9b9543a89de82
4
+ data.tar.gz: c145010e453e9c51466fd4ae779f1e20575991e1077ed9262e1ec0d9d406638a
5
+ SHA512:
6
+ metadata.gz: 65558010bb8ec7468fafe42e8734ce06c33a9604b920de8eb69d48ca5ee7ab18e648cc1217ab6a9b88336613195513a7864844a878ef40525366cdd0a4303c50
7
+ data.tar.gz: 93411308d93f271b30b53e4f7675f53b17c3f2231f8f486f1f55427077ff17eee40b4e5aca5155c38bc53e7e532e15e66175513eb1b0c4051f96596d7818650e
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2016 Alex Fong http://www.github.com/actfong
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'rspec/core/rake_task'
2
+ task :default => :spec
3
+ desc 'Run test suite'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,63 @@
1
+ ##
2
+ # Ruby wrapper for vatlayer. See https://vatlayer.com/documentation for more info
3
+ module Apilayer
4
+ module Vat
5
+ extend ConnectionHelper
6
+
7
+ CRITERIA_MISSING_MSG = 'You must provide either :country_code or :ip_address'.freeze
8
+
9
+ ##
10
+ # Validates whether a supported criteria has been provided to .rate and .price
11
+ def self.validate_country_criteria(criteria)
12
+ unless [:country_code, :ip_address].include? criteria
13
+ fail Apilayer::Error.new CRITERIA_MISSING_MSG
14
+ end
15
+ end
16
+
17
+ ### API methods
18
+ #
19
+
20
+ ##
21
+ # Api-Method: Calls the /validate endpoint to validate a given VAT-number.
22
+ # Example:
23
+ # Apilayer::Vat.validate("LU26375245")
24
+ def self.validate(vat_number)
25
+ params = { vat_number: vat_number }
26
+ get_and_parse('validate', params)
27
+ end
28
+
29
+ ##
30
+ # Api-Method: Calls the /rate endpoint to get the VAT-rate of a given country,
31
+ # based on country-code or ip-address.
32
+ # Example:
33
+ # Apilayer::Vat.rate(:country_code, "NL")
34
+ # Apilayer::Vat.rate(:ip_address, "176.249.153.36")
35
+ def self.rate(criteria, value)
36
+ validate_country_criteria(criteria)
37
+ params = { criteria.to_sym => value }
38
+ get_and_parse('rate', params)
39
+ end
40
+
41
+ ##
42
+ # Api-Method: Calls the /rate_list endpoint to get the standard and reduced VAT-rates
43
+ # for all EU countries.
44
+ # Example:
45
+ # Apilayer::Vat.rate_list
46
+ def self.rate_list
47
+ get_and_parse('rate_list')
48
+ end
49
+
50
+ ##
51
+ # Api-Method: Calls the /price endpoint to get price including and excluding VAT
52
+ # for a given price and country. It also returns the VAT rate for that country
53
+ # Example:
54
+ # Apilayer::Vat.price(100, :country, "NL")
55
+ # Apilayer::Vat.price(100, :ip_address, "176.249.153.36")
56
+ def self.price(price, criteria, value)
57
+ validate_country_criteria(criteria)
58
+ params = { amount: price, criteria.to_sym => value }
59
+ get_and_parse('price', params)
60
+ end
61
+
62
+ end
63
+ end
data/lib/vat_layer.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'apilayer'
3
+
4
+ require "apilayer/vat"
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vat_layer-ruby-3
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Alex Fong, Tom Brammar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-10-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: apilayer-ruby-3
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.12'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.12'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.22'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.22'
97
+ - !ruby/object:Gem::Dependency
98
+ name: vcr
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '6.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '6.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.19'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.19'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rexml
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.2'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.2'
139
+ description: Ruby wrapper for vatlayer by apilayer. This gem depends on the apilayer-ruby-3
140
+ gem, which provides a common connection-interface to various services of apilayer.net.
141
+ See https://apilayer.com/ for more details.
142
+ email:
143
+ - rubygems-org@premiacapital.com
144
+ executables: []
145
+ extensions: []
146
+ extra_rdoc_files: []
147
+ files:
148
+ - Gemfile
149
+ - LICENSE
150
+ - Rakefile
151
+ - lib/apilayer/vat.rb
152
+ - lib/vat_layer.rb
153
+ homepage: https://github.com/actfong/vat_layer
154
+ licenses:
155
+ - MIT
156
+ metadata: {}
157
+ post_install_message:
158
+ rdoc_options: []
159
+ require_paths:
160
+ - lib
161
+ required_ruby_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ requirements: []
172
+ rubygems_version: 3.4.10
173
+ signing_key:
174
+ specification_version: 4
175
+ summary: Ruby wrapper for vatlayer by apilayer. See https://vatlayer.com/ and https://apilayer.com/
176
+ for more details.
177
+ test_files: []