Class: RefreshingmenusApi::Client
- Inherits:
-
Object
- Object
- RefreshingmenusApi::Client
- Includes:
- APISmith::Client
- Defined in:
- lib/refreshingmenus_api.rb
Overview
Usage: api = RefreshingmenusApi::Client.new(:auth_token => ‘your_auth_token_here’) api.places(:q => ‘some query’)
Constant Summary collapse
- ERRORS =
{ 404 => NotFoundError, 422 => UnprocessableEntityError, }
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
readonly
Returns the value of attribute auth_token.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
Options: * :auth_token - Your RefreshingMenus Authentication token (API) * :version - Version (defaults to 1) * :locale - The language (defaults to ‘nl’).
- #menu(guid) ⇒ Object
- #places(options) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Options:
-
:auth_token - Your RefreshingMenus Authentication token (API)
-
:version - Version (defaults to 1)
-
:locale - The language (defaults to ‘nl’)
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/refreshingmenus_api.rb', line 92 def initialize( = {}) @auth_token = [:auth_token] @version = [:version] || '1' @locale = [:locale] || 'nl' self.class.base_uri([:base_uri] || 'www.refreshingmenus.com') self.class.endpoint("api/v#{version}") (:auth_token => auth_token) (:locale => locale) end |
Instance Attribute Details
#auth_token ⇒ Object (readonly)
Returns the value of attribute auth_token.
86 87 88 |
# File 'lib/refreshingmenus_api.rb', line 86 def auth_token @auth_token end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
86 87 88 |
# File 'lib/refreshingmenus_api.rb', line 86 def locale @locale end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
86 87 88 |
# File 'lib/refreshingmenus_api.rb', line 86 def version @version end |
Instance Method Details
#menu(guid) ⇒ Object
109 110 111 112 |
# File 'lib/refreshingmenus_api.rb', line 109 def (guid) raise ArgumentError, "Expected guid to be a String, got #(guid.inspect}." if not guid.is_a?(String) get("menus/#{guid}.json", :transform => Menu) end |
#places(options) ⇒ Object
104 105 106 107 |
# File 'lib/refreshingmenus_api.rb', line 104 def places() raise ArgumentError, "Expected options to be a Hash, got #{.inspect}." if not .is_a?(Hash) get('places.json', :extra_query => , :transform => Place) end |