215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
# File 'lib/currency_conversion.rb', line 215
def timeframe(start_date, end_date, currencies, options = {})
if start_date.nil?
raise CurrencyLayer::MissingArgumentException.new 'start_date'
return
end
if end_date.nil?
raise CurrencyLayer::MissingArgumentException.new 'end_date'
return
end
if currencies.nil?
raise CurrencyLayer::MissingArgumentException.new 'currencies'
return
end
q = options.dup
q.access_key = @access_key
q.start_date = start_date
q.end_date = end_date
q.currencies = currencies
req = CurrencyLayer::TimeframeRequest.new(q)
req_dto = req.to_dh
begin
res = self.class.get('/timeframe', req_dto)
res.inspect
if (res[CurrencyLayer::TimeframeResponse::ERROR_EXPR])
raise CurrencyLayer::TimeframeException.new res[CurrencyLayer::TimeframeResponse::ERROR_EXPR]
end
return res.parsed_response
rescue => e
puts e.inspect
return e
end
end
|