Module: MetalpriceAPI::Endpoints

Included in:
Client
Defined in:
lib/metalpriceapi/endpoints/index.rb

Instance Method Summary collapse

Instance Method Details

#carat(base = '', date = nil) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/metalpriceapi/endpoints/index.rb', line 55

def carat(base = '', date = nil)
  options = removeEmpty({
      'base': base,
      'date': date
  })
  get('carat', options)
end

#change(start_date, end_date, base = '', currencies = nil) ⇒ Object



45
46
47
48
49
50
51
52
53
# 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) ⇒ Object



25
26
27
28
29
30
31
32
33
# 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) ⇒ Object



17
18
19
20
21
22
23
# 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) ⇒ Object



9
10
11
12
13
14
15
# 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

#fetchSymbolsObject



5
6
7
# File 'lib/metalpriceapi/endpoints/index.rb', line 5

def fetchSymbols
  get('symbols')
end

#timeframe(start_date, end_date, base = nil, currencies = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/metalpriceapi/endpoints/index.rb', line 35

def timeframe(start_date, end_date, base = nil, currencies = nil)
  options = removeEmpty({
      'start_date': start_date,
      'end_date': end_date,
      'base': base,
      'currencies': (currencies || []).join(',')
  })
  get('timeframe', options)
end