Class: Mmjmenu::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/mmjmenu/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Client

Your API key can be generated on the options screen.



24
25
26
27
28
29
30
# File 'lib/mmjmenu/client.rb', line 24

def initialize(api_key)
  @api_key = api_key
  
  self.class.base_uri "https://mmjmenu.com/api/v1"
  self.class.basic_auth @api_key, 'x'
  
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



21
22
23
# File 'lib/mmjmenu/client.rb', line 21

def api_key
  @api_key
end

Instance Method Details



43
44
45
46
47
48
# File 'lib/mmjmenu/client.rb', line 43

def menu_item(menu_item_id, options={})
  request = get("/menu_items/#{menu_item_id}")
  success = request.code == 200
  response = Hashie::Mash.new(request) if success
  Hashie::Mash.new(response['menu_item'] || {}).update(:success? => success)
end

Menu Items



33
34
35
36
37
38
39
40
41
# File 'lib/mmjmenu/client.rb', line 33

def menu_items(options={})
  options[:status] ||= 'active'
  if options[:status].to_s.downcase == 'on_hold'
    request = get("/menu_items/on_hold", :query => options)
  else
    request = get("/menu_items", :query => options)
  end
  request['menu_items'].map{|c| Hashie::Mash.new(c)}
end

#unconfirmed_patients(options = {}) ⇒ Object

Patients



51
52
53
54
# File 'lib/mmjmenu/client.rb', line 51

def unconfirmed_patients(options = {})
  request = get("/patients/unconfirmed", :query => options)
  request['patients'].map{|c| Hashie::Mash.new(c)}
end