vat_layer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +3 -0
  3. data/LICENSE +19 -0
  4. data/Rakefile +5 -0
  5. data/lib/apilayer/vat.rb +63 -0
  6. data/lib/vatlayer.rb +4 -0
  7. metadata +193 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8f5dc0fbb939cad4c66a92788c4acad63c887a60
4
+ data.tar.gz: 683aa17f45a05dc3c14cf924c5778741c8b399dc
5
+ SHA512:
6
+ metadata.gz: 27a0f40c82c43b62ab3e1fd15956b5b2a755c9d2d96c93aba0e0f14f56ad409e705a096e0d9784c9bfbd621faeab855800b5598373ca8671203cb2a10e35c203
7
+ data.tar.gz: dd3b56e3282e836b03048d01f06e296f5a07f2c57781fc2279d7afccc3d53f4716772c9ee2b237f59a9f4353dad815efef38b4e207c0c7f7411aa908c9df119d
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+ gem "apilayer", :git => 'https://github.com/actfong/apilayer.git', :branch => 'refactor/separate_gems'
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
+ COUNTRY_CRITERIA_MISSING_MSG = "You must provide either :country_code or :ip_address"
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
+ raise Apilayer::Error.new COUNTRY_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/vatlayer.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'apilayer'
3
+
4
+ require "apilayer/vat"
metadata ADDED
@@ -0,0 +1,193 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vat_layer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alex Fong
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '10.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.10.1
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '10.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.10.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: pry
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.10'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.10.1
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.10'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.10.1
53
+ - !ruby/object:Gem::Dependency
54
+ name: bundler
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '1.7'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 1.7.9
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.7'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 1.7.9
73
+ - !ruby/object:Gem::Dependency
74
+ name: rspec
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '3.0'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.0
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 3.0.0
93
+ - !ruby/object:Gem::Dependency
94
+ name: simplecov
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '0.11'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 0.11.0
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.11'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 0.11.0
113
+ - !ruby/object:Gem::Dependency
114
+ name: vcr
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '3.0'
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 3.0.1
123
+ type: :development
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '3.0'
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 3.0.1
133
+ - !ruby/object:Gem::Dependency
134
+ name: webmock
135
+ requirement: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '2.0'
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: 2.0.1
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '2.0'
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 2.0.1
153
+ description: Ruby wrapper for vatlayer by apilayer. This gem depends on the apilayer
154
+ gem, which provides a common connection-interface to various services of apilayer.net
155
+ (such as currencylayer and vatlayer). See https://currencylayer.com/ and https://apilayer.com/
156
+ for more details.
157
+ email:
158
+ - actfong@gmail.com
159
+ executables: []
160
+ extensions: []
161
+ extra_rdoc_files: []
162
+ files:
163
+ - Gemfile
164
+ - LICENSE
165
+ - Rakefile
166
+ - lib/apilayer/vat.rb
167
+ - lib/vatlayer.rb
168
+ homepage: https://github.com/actfong/vatlayer
169
+ licenses:
170
+ - MIT
171
+ metadata: {}
172
+ post_install_message:
173
+ rdoc_options: []
174
+ require_paths:
175
+ - lib
176
+ required_ruby_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ required_rubygems_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ requirements: []
187
+ rubyforge_project:
188
+ rubygems_version: 2.4.5
189
+ signing_key:
190
+ specification_version: 4
191
+ summary: Ruby wrapper for vatlayer by apilayer. See https://vatlayer.com/ and https://apilayer.com/
192
+ for more details.
193
+ test_files: []