vatlayer 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aed645c587d1b11f1aa960bfccc0c5bdbfe59d93
4
+ data.tar.gz: 12541c0fa7f8312c70df83a9cd63fd03b3f319fa
5
+ SHA512:
6
+ metadata.gz: 554992ae042e6d8fd701839cd66cbb984709c6027b53f64793592ed5eedef9dc4e0aac5998cfcf8e5518b050ce0aa89188709fd41a1c88d5a65a5b1800283352
7
+ data.tar.gz: cafc98712222d9bee54aa820f50055aaba2641f09ab734afeb9759bc2990af7fb43d189c0a9098b7bdd4db8a42ee30f875e3cb571b3edc7cad6fd9428fdd560a
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,10 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.1
3
+ Exclude:
4
+ - spec/**/*
5
+
6
+ Documentation:
7
+ Enabled: false
8
+
9
+ Metrics/LineLength:
10
+ Max: 120
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.4.2
4
+
5
+ script:
6
+ - rspec spec/
7
+ - bundle exec rubocop
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in vatlayer.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Vlad Romaniuk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,111 @@
1
+ # Vatlayer
2
+
3
+ [![Build Status](https://travis-ci.org/drEnilight/vatlayer-ruby.svg?branch=master)](https://travis-ci.org/drEnilight/vatlayer-ruby) [![codecov.io](https://codecov.io/github/drEnilight/vatlayer-ruby/coverage.svg?branch=master)](https://codecov.io/gh/drEnilight/vatlayer-ruby?branch=master)
4
+
5
+ The Ruby gem for accessing the Vatlayer API painlessly, easily, and awesomely! This gem is actively being developed. **Be sure to check the branch for the version you're using.**
6
+
7
+ **Important and helpful links:**
8
+
9
+ - [Vatlayer API documentation](https://vatlayer.com/documentation)
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'vatlayer'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install vatlayer
26
+
27
+ ## Usage
28
+
29
+ ```ruby
30
+ require 'vatlayer'
31
+ vatlayer = Vatlayer.new('Your API access key')
32
+
33
+ ```
34
+ You can find your API key in your Vatlayer account, by [reference](https://vatlayer.com/dashboard). API access is available for every Vatlayer account.
35
+
36
+ ## Configuration
37
+
38
+ API keys *must* be configured in the gem setup. You can do this anywhere in your application before you make API calls using the gem. You can find your API key in your Vatlayer account, by [reference](https://vatlayer.com/dashboard). API access is available for every Vatlayer account.
39
+
40
+ ```ruby
41
+ Vatlayer.configure do |config|
42
+ config.access_key = 'a1sad2f4g2srf'
43
+ config.https = true
44
+ end
45
+ ```
46
+
47
+ * `config.access_key` - your Vatlayer access key
48
+ * `config.https` - you can use https mode, default `false`
49
+
50
+ Please note that the https configuration is optional and only available to paid-accounts. If unset, these configuration-values are just nil.
51
+
52
+ ## Available methods
53
+
54
+ Creating an instance of the Vatlayer client:
55
+ ```ruby
56
+ vatlayer = Vatlayer.new('Your API access key')
57
+ ```
58
+ If you've configured the gem with a default `access_key`, then you can just instantiate the class.
59
+ ```ruby
60
+ vatlayer = Vatlayer.new
61
+ ```
62
+
63
+ #### Validate
64
+ ```ruby
65
+ vatlayer.validate('LU26375245')
66
+
67
+ # <Vatlayer::Response::Data:0x0000555fd334ba10
68
+ # @valid=true,
69
+ # @database="ok",
70
+ # @format_valid=true,
71
+ # @query="LU26375245",
72
+ # @country_code="LU",
73
+ # @vat_number="26375245",
74
+ # @company_name="AMAZON EUROPE CORE S.A R.L.",
75
+ # @company_address="5, RUE PLAETIS L-2338 LUXEMBOURG">
76
+ ```
77
+
78
+ #### Rate
79
+ TODO
80
+
81
+ #### Rate list
82
+ TODO
83
+
84
+ #### Price
85
+ TODO
86
+
87
+ ### Fetch errors
88
+
89
+ ```ruby
90
+ vatlayer = Vatlayer.new('invalid_access_key')
91
+ vatlayer.validate('LU26375245')
92
+
93
+ # <Vatlayer::Response::Data:0x0000555fd3379c80
94
+ # @success=false,
95
+ # @error=#<Vatlayer::Response::Error:0x0000555fd33797d0
96
+ # @code=101,
97
+ # @type="invalid_access_key",
98
+ # @info="You have not supplied a valid API Access Key. [Technical Support: support@apilayer.com]">
99
+ ```
100
+
101
+
102
+ ## License
103
+ The Teamleader GEM is released under the MIT License.
104
+
105
+ ## Contributing
106
+
107
+ 1. Fork it
108
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
109
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
110
+ 4. Push to the branch (`git push origin my-new-feature`)
111
+ 5. Create a new Pull Request
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'vatlayer'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), 'vatlayer/api'))
4
+ require File.expand_path(File.join(File.dirname(__FILE__), 'vatlayer/configuration'))
5
+ require File.expand_path(File.join(File.dirname(__FILE__), 'vatlayer/response/error'))
6
+ require File.expand_path(File.join(File.dirname(__FILE__), 'vatlayer/response/data'))
7
+ require File.expand_path(File.join(File.dirname(__FILE__), 'vatlayer/version'))
8
+
9
+ module Vatlayer
10
+ module_function
11
+
12
+ def configuration
13
+ @configuration ||= Configuration.new
14
+ end
15
+
16
+ def configure
17
+ yield(configuration)
18
+ end
19
+
20
+ def new(access_key = Vatlayer.configuration.access_key, https: Vatlayer.configuration.https)
21
+ Api.new(access_key, https)
22
+ end
23
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'http'
4
+
5
+ module Vatlayer
6
+ class Api
7
+ attr_reader :access_key, :https
8
+
9
+ def initialize(access_key, https)
10
+ @access_key = access_key
11
+ @https = https
12
+ end
13
+
14
+ def validate(number)
15
+ params = { vat_number: number }
16
+ Vatlayer::Response::Data.new(request('/validate', params))
17
+ end
18
+
19
+ private
20
+
21
+ def api_base_url
22
+ https ? 'https://apilayer.net/api' : 'http://apilayer.net/api'
23
+ end
24
+
25
+ def request(path, params)
26
+ response = HTTP.get(api_base_url + path, params: prepared_params(params)).parse
27
+ response.each_with_object({}) { |(k, v), h| h[k] = v.is_a?(String) ? v.tr("\n", ' ') : v }
28
+ end
29
+
30
+ def prepared_params(params)
31
+ params.merge(access_key: access_key)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Configuration
4
+ attr_accessor :access_key, :https
5
+
6
+ def initialize
7
+ @access_key = 'Your Access key'
8
+ @https = false
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vatlayer
4
+ module Response
5
+ class Data
6
+ attr_reader :error
7
+
8
+ def initialize(attributes)
9
+ attributes.each do |(key, value)|
10
+ self.class.class_eval { attr_accessor :"#{key}" }
11
+ public_send("#{key}=", key == 'error' ? Vatlayer::Response::Error.new(value) : value)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vatlayer
4
+ module Response
5
+ class Error
6
+ def initialize(attributes)
7
+ attributes.each do |(key, value)|
8
+ self.class.class_eval { attr_accessor :"#{key}" }
9
+ public_send("#{key}=", value)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vatlayer
4
+ VERSION = '0.2.3'.freeze
5
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require File.expand_path('lib/vatlayer/version', __dir__)
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'vatlayer'
9
+ spec.version = Vatlayer::VERSION
10
+ spec.authors = ['Vlad Romaniuk']
11
+ spec.email = ['romanuk_v@live.ru']
12
+
13
+ spec.summary = 'A Ruby wrapper around vatlayer.com API'
14
+ spec.description = 'A Ruby wrapper around vatlayer.com API.'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'http', '~> 3.3.0'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.16'
25
+ spec.add_development_dependency 'codecov'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rspec', '~> 3.0'
28
+ spec.add_development_dependency 'rubocop', '~> 0.54'
29
+ spec.required_ruby_version = '>= 2.1'
30
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vatlayer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.3
5
+ platform: ruby
6
+ authors:
7
+ - Vlad Romaniuk
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-05-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: codecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.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.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.54'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.54'
97
+ description: A Ruby wrapper around vatlayer.com API.
98
+ email:
99
+ - romanuk_v@live.ru
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".rubocop.yml"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/setup
114
+ - lib/vatlayer.rb
115
+ - lib/vatlayer/api.rb
116
+ - lib/vatlayer/configuration.rb
117
+ - lib/vatlayer/response/data.rb
118
+ - lib/vatlayer/response/error.rb
119
+ - lib/vatlayer/version.rb
120
+ - vatlayer.gemspec
121
+ homepage:
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '2.1'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.6.13
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: A Ruby wrapper around vatlayer.com API
145
+ test_files: []