269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
# File 'lib/currency_conversion.rb', line 269
def change(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::ChangeRequest.new(q)
req_dto = req.to_dh
begin
res = self.class.get('/change', req_dto)
res.inspect
if (res[CurrencyLayer::ChangeResponse::ERROR_EXPR])
raise CurrencyLayer::ChangeException.new res[CurrencyLayer::ChangeResponse::ERROR_EXPR]
end
return res.parsed_response
rescue => e
puts e.inspect
return e
end
end
|