apilayer 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +5 -0
  3. data/lib/apilayer/currency.rb +16 -0
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b96da80c728f03b13491f9a4d7f24dc8b445c90
4
- data.tar.gz: 4ae80aaded90734d72100e480ab120ec25025f05
3
+ metadata.gz: f751df7c6d98bc85da716312177f4a7ab6eb4336
4
+ data.tar.gz: bd01cf1ae3de71292d21fe1010741215d0b654d3
5
5
  SHA512:
6
- metadata.gz: 7353484a6d9eefc43d098f1853a0bf4c27aa121d0f2785d493f4870b1cde71ecbd429d2da00de0bd568f8870f958a22dfeab4f51244ee8d5f1ed79130a92a3b6
7
- data.tar.gz: 4a95462f310c84991796fa576558809369ed6f8f74f6d3905c65cf063fb1264bc649d9c9ff6b5c56886cd91d789ab719c25940f5ca178100b05fafc984e8b0d4
6
+ metadata.gz: 64980240ef6a80e0d31d103956eff1c1d5c2b2d161521e2ea7c783916ae62532ea271d88280898c572af27d879f95a63ed7a384dc055fc51ea1fa4253d1302c1
7
+ data.tar.gz: e49ab2c049641a8e10452debd5413fc25ac980f8f82997b017bb4343288b6b93687bb55f9b0fe4e5335fc350438e7efc8ed56b8eaf5753286e40cff95e9cc3b5
@@ -3,6 +3,9 @@
3
3
  Ruby wrapper for various services of apilayer.
4
4
  See http://apilayer.com for more details.
5
5
 
6
+ === Version 1.2
7
+ Added .convert to Apilayer::Currency
8
+
6
9
  === Version 1.1
7
10
  - Major change to how .live and .historical in Apilayer::Currency are invoked.
8
11
  - Added :source option to Apilayer::Currency.live and Apilayer::Currency.historical methods. This option is only available to paid users of currencylayer.
@@ -48,6 +51,8 @@ After setting the access_key for *currencylayer*, you can use Apilayer::Currency
48
51
  Apilayer::Currency.historical(:source => "EUR") # source-currency is USD by default
49
52
  Apilayer::Currency.historical("2016-01-01", :currencies => %w[GBP CHF], :source => "EUR")
50
53
 
54
+ Apilayer::Currency.convert("EUR", "CHF", 100) # convert 100 EUR to CHF
55
+ Apilayer::Currency.convert("EUR", "CHF", 100, "2015-06-01") # conversion based on specific date
51
56
  ==== vatlayer
52
57
  After setting the access_key for *vatlayer*, you can use Apilayer::Vat to call *vatlayer*'s API
53
58
 
@@ -11,6 +11,7 @@ module Apilayer
11
11
  INVALID_OPTIONS_MSG = "You have provided an invalid option. Allowed options are :currencies and :source"
12
12
  LIVE_SLUG = "live"
13
13
  HISTORICAL_SLUG = "historical"
14
+ CONVERT_SLUG = "convert"
14
15
 
15
16
  ## Validations
16
17
  #
@@ -62,6 +63,21 @@ module Apilayer
62
63
  end
63
64
  end
64
65
 
66
+ ##
67
+ # Api-Method: Calls the /convert endpoint, requires :from, :to and :amount
68
+ # When :date hasn't been passed, the latest available exchange rates will be used for your conversion.
69
+ # Example:
70
+ # Apilayer::Currency.convert("EUR", "CHF", 100)
71
+ # Apilayer::Currency.convert("EUR", "CHF", 100, "2015-06-01")
72
+ def self.convert(from, to, amount, date=nil)
73
+ params = {:from => from, :to => to, :amount => amount}
74
+ params.merge!(:date => date) if date
75
+ get_and_parse(CONVERT_SLUG, params)
76
+ end
77
+
78
+
79
+
80
+ ## Internal Methods
65
81
  def self.get_and_parse_with_options(slug, opts, params={})
66
82
  params = add_options_to_params(opts, params)
67
83
  get_and_parse(slug, params)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apilayer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Fong