module MetalpriceAPI::Endpoints

Public Instance Methods

change(start_date, end_date, base = '', currencies = nil) click to toggle source
# File lib/metalpriceapi/endpoints/index.rb, line 45
def change(start_date, end_date, base = '', currencies = nil)
  options = removeEmpty({
      'start_date': start_date,
      'end_date': end_date,
      'base': base,
      'currencies': (currencies || []).join(',')
  })
  get('change', options)
end
convert(from_currency = nil, to_currency = nil, amount = nil, date = nil) click to toggle source
# File lib/metalpriceapi/endpoints/index.rb, line 25
def convert(from_currency = nil, to_currency = nil, amount = nil, date = nil)
  options = removeEmpty({
      'from': from_currency,
      'to': to_currency,
      'amount': amount,
      'date': date
  })
  get('convert', options)
end
fetchHistorical(date, base = nil, currencies = nil) click to toggle source
# File lib/metalpriceapi/endpoints/index.rb, line 17
def fetchHistorical(date, base = nil, currencies = nil)
  options = removeEmpty({
    base: base,
    currencies: (currencies || []).join(',')
  })
  get(date, options)
end
fetchLive(base = nil, currencies = nil) click to toggle source
# File lib/metalpriceapi/endpoints/index.rb, line 9
def fetchLive(base = nil, currencies = nil)
  options = removeEmpty({
    base: base,
    currencies: (currencies || []).join(',')
  })
  get('latest', options)
end
fetchSymbols() click to toggle source
# File lib/metalpriceapi/endpoints/index.rb, line 5
def fetchSymbols
  get('symbols')
end
timeframe(start_date = nil, end_date = nil, base = nil, currencies = nil) click to toggle source
# File lib/metalpriceapi/endpoints/index.rb, line 35
def timeframe(start_date = nil, end_date = nil, base = nil, currencies = nil)
  options = removeEmpty({
      'start_date': start_date,
      'end_date': end_date,
      'base': base,
      'currencies': (currencies || []).join(',')
  })
  get('timeframe', options)
end

Private Instance Methods

removeEmpty(options) click to toggle source
# File lib/metalpriceapi/endpoints/index.rb, line 57
def removeEmpty(options)
  options.each do |key, value|
    if (!value || value == '')
      options.delete(key)
    end
  end
  options
end