Class: Mmjmenu::Client
- Inherits:
-
Object
- Object
- Mmjmenu::Client
- Includes:
- HTTParty
- Defined in:
- lib/mmjmenu/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
-
#initialize(api_key) ⇒ Client
constructor
Your API key can be generated on the options screen.
- #menu_item(menu_item_id, options = {}) ⇒ Object
-
#menu_items(options = {}) ⇒ Object
Menu Items.
-
#unconfirmed_patients(options = {}) ⇒ Object
Patients.
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_key ⇒ Object (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
#menu_item(menu_item_id, options = {}) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/mmjmenu/client.rb', line 43 def (, ={}) request = get("/menu_items/#{}") success = request.code == 200 response = Hashie::Mash.new(request) if success Hashie::Mash.new(response['menu_item'] || {}).update(:success? => success) end |
#menu_items(options = {}) ⇒ Object
Menu Items
33 34 35 36 37 38 39 40 41 |
# File 'lib/mmjmenu/client.rb', line 33 def (={}) [:status] ||= 'active' if [:status].to_s.downcase == 'on_hold' request = get("/menu_items/on_hold", :query => ) else request = get("/menu_items", :query => ) 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( = {}) request = get("/patients/unconfirmed", :query => ) request['patients'].map{|c| Hashie::Mash.new(c)} end |