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



66
67
68
69
70
71
72
# File 'lib/metalpriceapi/endpoints/index.rb', line 66

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

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



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

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



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

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

#fetchOHLC(base = nil, currency = nil, date = nil, unit = nil, date_type = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/metalpriceapi/endpoints/index.rb', line 25

def fetchOHLC(base = nil, currency = nil, date = nil, unit = nil, date_type = nil)
  options = removeEmpty({
    base: base,
    currency: currency,
    date: date,
    unit: unit,
    date_type: dateType
  })
  get('ohlc', 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



46
47
48
49
50
51
52
53
54
# File 'lib/metalpriceapi/endpoints/index.rb', line 46

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

#usageObject



74
75
76
# File 'lib/metalpriceapi/endpoints/index.rb', line 74

def usage
  get('usage')
end