apilayer 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +22 -12
- data/lib/apilayer.rb +10 -1
- data/lib/apilayer/connection_helper.rb +7 -2
- data/lib/apilayer/currency.rb +3 -1
- data/lib/apilayer/vat.rb +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b78b1270c33ed6f9b1a8879031dcb80fa82bee9b
|
4
|
+
data.tar.gz: b1349cc942a471919e688af35cf447a60d955296
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a247fd53c936004185f43a3e67b3bef676718ca6df248d33032f50d5a4a44e6f1fa8a1657e2f0400179230d2a31a20887ec6c8bd2716d2b95454df3586787de
|
7
|
+
data.tar.gz: dd6fc9340d265b22c5542717496e67b9fff07339f602704bfe8a55358b3016403a393c7c9bc698c5fe19ad9ea8a538adcb6544b8df294db9ef7dba9b6db7e323
|
data/README.rdoc
CHANGED
@@ -3,13 +3,14 @@
|
|
3
3
|
Ruby wrapper for various services of apilayer.
|
4
4
|
See http://apilayer.com for more details.
|
5
5
|
|
6
|
-
=== Version 1.
|
7
|
-
|
6
|
+
=== Version 1.5
|
7
|
+
Improved reconfiguration-mechanism in Apilayer.
|
8
|
+
Added HTTPS-option in Apilayer module.
|
9
|
+
With this release, all paid-features of vatlayer and currencylayer are fully covered.
|
8
10
|
|
9
|
-
=== Version 1.
|
11
|
+
=== Version 1.2 - 1.4
|
12
|
+
Added .change and .list to Apilayer::Currency
|
10
13
|
Added .timeframe to Apilayer::Currency
|
11
|
-
|
12
|
-
=== Version 1.2
|
13
14
|
Added .convert to Apilayer::Currency
|
14
15
|
|
15
16
|
=== Version 1.1
|
@@ -39,11 +40,18 @@ Then you can use your access_key(s) to configure your Apilayer module like this:
|
|
39
40
|
Apilayer.configure do |configs|
|
40
41
|
configs.vat_key = "my_vatlayer_access_key_123"
|
41
42
|
configs.currency_key = "my_currencylayer_access_key_123"
|
43
|
+
configs.vat_https = false
|
44
|
+
configs.currency_https = true
|
42
45
|
end
|
43
46
|
|
44
|
-
Please note that you
|
47
|
+
Please note that you only need to set the access keys and https connections that you need.
|
48
|
+
If unset, these values are just nil.
|
45
49
|
|
46
|
-
|
50
|
+
You can always review you configurations with:
|
51
|
+
|
52
|
+
Apilayer.configs
|
53
|
+
|
54
|
+
Once your configurations are set, you are ready to go
|
47
55
|
|
48
56
|
==== currencylayer
|
49
57
|
After setting the access_key for *currencylayer*, you can use Apilayer::Currency to call *currencylayer*'s API
|
@@ -86,12 +94,14 @@ After setting the access_key for *vatlayer*, you can use Apilayer::Vat to call *
|
|
86
94
|
Apilayer::Vat.price(100, :country, "NL")
|
87
95
|
Apilayer::Vat.price(100, :ip_address, "176.249.153.36")
|
88
96
|
|
89
|
-
==== Re-Configure Apilayer
|
90
|
-
If you happened to have forgotten to
|
97
|
+
==== Re-Configure Apilayer
|
98
|
+
If you happened to have forgotten to set or entered an incorrect value, you can re-configure your Apilayer module by:
|
91
99
|
|
92
|
-
# Example: reconfigure
|
93
|
-
Apilayer::Vatlayer.reset_connection
|
100
|
+
# Example: reconfigure https for vatlayer
|
94
101
|
Apilayer.configure do |configs|
|
95
|
-
configs.
|
102
|
+
configs.vat_https = true
|
96
103
|
end
|
104
|
+
|
105
|
+
The action above will not affect the other Apilayer configurations you have set previously.
|
106
|
+
When you try to connect to Apilayer again, it will create a new connection based on the values you provided.
|
97
107
|
|
data/lib/apilayer.rb
CHANGED
@@ -8,7 +8,7 @@ module Apilayer
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.init_configs
|
11
|
-
keys = Struct.new(:currency_key, :vat_key)
|
11
|
+
keys = Struct.new(:currency_key, :vat_key, :currency_https, :vat_https)
|
12
12
|
keys.new
|
13
13
|
end
|
14
14
|
|
@@ -21,6 +21,7 @@ module Apilayer
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.configure
|
24
|
+
reset_observers_connections
|
24
25
|
yield(configs)
|
25
26
|
end
|
26
27
|
end
|
@@ -28,4 +29,12 @@ end
|
|
28
29
|
require "apilayer/connection_helper"
|
29
30
|
require "apilayer/currency"
|
30
31
|
require "apilayer/vat"
|
32
|
+
|
33
|
+
module Apilayer
|
34
|
+
OBSERVERS = [Apilayer::Currency, Apilayer::Vat]
|
35
|
+
def self.reset_observers_connections
|
36
|
+
OBSERVERS.each(&:reset_connection)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
31
40
|
require "apilayer/error"
|
@@ -5,10 +5,15 @@ module Apilayer
|
|
5
5
|
# Creates a connection for the extended module to an apilayer-service, such as currencylayer and vatlayer.
|
6
6
|
# Uses access_key(s) configured with Apilayer module.
|
7
7
|
def connection
|
8
|
-
@connection ||= ::Faraday.new(
|
9
|
-
:
|
8
|
+
@connection ||= ::Faraday.new(
|
9
|
+
:url => "#{protocol}://apilayer.net",
|
10
|
+
:params => {"access_key" => Apilayer.configs[self.const_get(:APILAYER_CONFIG_KEY)]}
|
11
|
+
)
|
10
12
|
end
|
11
13
|
|
14
|
+
def protocol
|
15
|
+
Apilayer.configs[self.const_get(:APILAYER_SECURE)] ? "https" : "http"
|
16
|
+
end
|
12
17
|
##
|
13
18
|
# Resets the connection for the extended module. Used when the user needs to re-enter his/her access_key(s)
|
14
19
|
def reset_connection
|
data/lib/apilayer/currency.rb
CHANGED
@@ -5,9 +5,11 @@ module Apilayer
|
|
5
5
|
extend ConnectionHelper
|
6
6
|
|
7
7
|
##
|
8
|
-
#
|
8
|
+
# The following constants determine which values in Apilayer.configs to be used
|
9
9
|
# in order to to make a connection to currencylayer
|
10
10
|
APILAYER_CONFIG_KEY = :currency_key
|
11
|
+
APILAYER_SECURE = :currency_https
|
12
|
+
|
11
13
|
INVALID_OPTIONS_MSG = "You have provided an invalid option. Allowed options are :currencies and :source"
|
12
14
|
INVALID_TIMEFRAME_MSG = "start_date and end_date must be either provided together or left out together."
|
13
15
|
LIVE_SLUG = "live"
|
data/lib/apilayer/vat.rb
CHANGED
@@ -7,10 +7,10 @@ module Apilayer
|
|
7
7
|
COUNTRY_CRITERIA_MISSING_MSG = "You must provide either :country_code or :ip_address"
|
8
8
|
|
9
9
|
##
|
10
|
-
#
|
10
|
+
# The following constants determine which values in Apilayer.configs to be used
|
11
11
|
# in order to make a connection to vatlayer
|
12
12
|
APILAYER_CONFIG_KEY = :vat_key
|
13
|
-
|
13
|
+
APILAYER_SECURE = :vat_https
|
14
14
|
##
|
15
15
|
# Validates whether a supported criteria has been provided to .rate and .price
|
16
16
|
def self.validate_country_criteria(criteria)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apilayer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Fong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -190,8 +190,8 @@ dependencies:
|
|
190
190
|
- - ">="
|
191
191
|
- !ruby/object:Gem::Version
|
192
192
|
version: 2.0.1
|
193
|
-
description: Ruby wrapper for currencylayer and vatlayer from apilayer.com.
|
194
|
-
|
193
|
+
description: Ruby wrapper for currencylayer and vatlayer from apilayer.com. See https://apilayer.com/
|
194
|
+
for more details.
|
195
195
|
email:
|
196
196
|
- actfong@gmail.com
|
197
197
|
executables: []
|
@@ -230,6 +230,6 @@ rubyforge_project:
|
|
230
230
|
rubygems_version: 2.4.5
|
231
231
|
signing_key:
|
232
232
|
specification_version: 4
|
233
|
-
summary: Ruby wrapper for currencylayer and vatlayer from apilayer.com.
|
234
|
-
|
233
|
+
summary: Ruby wrapper for currencylayer and vatlayer from apilayer.com. See https://apilayer.com/
|
234
|
+
for more details.
|
235
235
|
test_files: []
|