Method: Printaura::Api.method_missing

Defined in:
lib/printaura/api.rb

.method_missing(m, *args, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/printaura/api.rb', line 5

def self.method_missing(m, *args, &block)
  #we only really care about the array options
  options = args.last || {}

  postparams= {key: Printaura::Config.API_KEY, hash: Printaura::Config.API_HASH, method: m}.update(options)
  puts postparams

  result = JSON.parse(RestClient.post("http://www.api.printaura.com/api.php", postparams))

  raise result["message"] unless result["status"]

  return result
end