currencyconversion 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/example/example_list.rb +27 -0
- data/lib/currency_conversion/list/list_exception.rb +13 -0
- data/lib/currency_conversion/list/list_options.rb +15 -0
- data/lib/currency_conversion/list/list_request.rb +18 -0
- data/lib/currency_conversion/list/list_response.rb +15 -0
- data/lib/currency_conversion/version.rb +1 -1
- data/lib/currency_conversion.rb +38 -0
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7da06db9b4adfa274c28d4e9a3111d32f8fff7e
|
4
|
+
data.tar.gz: e037e6b63c7b7500bfcd9bd5ead2879fc44120b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 631387c053ed47dc9d698280908414102bd9cac64194ef380db9657978879a6b22a967db0742d5bfb41e125ed26653220e8f04a9a99868e14d7f12d4fd8483cc
|
7
|
+
data.tar.gz: 7278ed992900ec32dcf760446f27b4ccf0401986aebc87b36ad887562131e83ef620c3a3f4f8080b6a93db54dd1818186385d57f40d5a8766442cb4c026651a8
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'dotenv'
|
2
|
+
require 'currency_conversion'
|
3
|
+
require 'currency_conversion/list/list_options'
|
4
|
+
|
5
|
+
# Load Environment Variables
|
6
|
+
Dotenv.load
|
7
|
+
|
8
|
+
begin
|
9
|
+
|
10
|
+
# Declare the Client instance passing in the authentication parameters
|
11
|
+
@client = CurrencyLayer::Client.new(ENV['ACCESS_KEY'])
|
12
|
+
|
13
|
+
# We declare the options
|
14
|
+
options = CurrencyLayer::ListOptions.new()
|
15
|
+
|
16
|
+
# We make the call to fetch the list of currencies
|
17
|
+
response = @client.list(options)
|
18
|
+
|
19
|
+
# If its a success, we print a message to the user
|
20
|
+
if !response.nil?
|
21
|
+
puts 'SUCCESS : List of Currencies Fetched...' << response.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
rescue => e
|
25
|
+
puts e.inspect
|
26
|
+
|
27
|
+
end
|
data/lib/currency_conversion.rb
CHANGED
@@ -3,6 +3,8 @@ require "hashable"
|
|
3
3
|
require "currency_conversion/version"
|
4
4
|
require "currency_conversion/live/live_request"
|
5
5
|
require "currency_conversion/live/live_response"
|
6
|
+
require "currency_conversion/list/list_request"
|
7
|
+
require "currency_conversion/list/list_response"
|
6
8
|
|
7
9
|
module CurrencyLayer
|
8
10
|
|
@@ -64,5 +66,41 @@ module CurrencyLayer
|
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
69
|
+
def list(options = {})
|
70
|
+
|
71
|
+
# Create a shallow copy so we don't manipulate the original reference
|
72
|
+
q = options.dup
|
73
|
+
|
74
|
+
# Populate the Query
|
75
|
+
q.access_key = @access_key
|
76
|
+
|
77
|
+
# We then create the Request
|
78
|
+
req = CurrencyLayer::ListRequest.new(q)
|
79
|
+
|
80
|
+
# We create a Hash of the request so we can send it via HTTP
|
81
|
+
req_dto = req.to_dh
|
82
|
+
|
83
|
+
begin
|
84
|
+
|
85
|
+
# We make the actual request
|
86
|
+
res = self.class.get('/list', req_dto)
|
87
|
+
|
88
|
+
# We ensure that we tap the response so we can use the results
|
89
|
+
res.inspect
|
90
|
+
|
91
|
+
if (res[CurrencyLayer::ListResponse::ERROR_EXPR])
|
92
|
+
raise CurrencyLayer::ListException.new res[CurrencyLayer::ListResponse::ERROR_EXPR]
|
93
|
+
end
|
94
|
+
|
95
|
+
# We just return the parsed binary response
|
96
|
+
return res.parsed_response
|
97
|
+
|
98
|
+
rescue => e
|
99
|
+
puts e.inspect
|
100
|
+
return e
|
101
|
+
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
67
105
|
end
|
68
106
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: currencyconversion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Andreas Moelgaard
|
@@ -126,10 +126,15 @@ files:
|
|
126
126
|
- bin/console
|
127
127
|
- bin/setup
|
128
128
|
- currency_conversion.gemspec
|
129
|
+
- example/example_list.rb
|
129
130
|
- example/example_live.rb
|
130
131
|
- example/example_live_w_currencies_as_array.rb
|
131
132
|
- example/example_live_w_source.rb
|
132
133
|
- lib/currency_conversion.rb
|
134
|
+
- lib/currency_conversion/list/list_exception.rb
|
135
|
+
- lib/currency_conversion/list/list_options.rb
|
136
|
+
- lib/currency_conversion/list/list_request.rb
|
137
|
+
- lib/currency_conversion/list/list_response.rb
|
133
138
|
- lib/currency_conversion/live/live_exception.rb
|
134
139
|
- lib/currency_conversion/live/live_options.rb
|
135
140
|
- lib/currency_conversion/live/live_request.rb
|