Class: RefreshingmenusApi::Client

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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(options = {})
  @auth_token = options[:auth_token]
  @version = options[:version] || '1'
  @locale = options[:locale] || 'nl'

  self.class.base_uri(options[:base_uri] || 'www.refreshingmenus.com')
  self.class.endpoint("api/v#{version}")

  add_query_options!(:auth_token => auth_token)
  add_query_options!(:locale => locale)
end

Instance Attribute Details

#auth_tokenObject (readonly)

Returns the value of attribute auth_token.



86
87
88
# File 'lib/refreshingmenus_api.rb', line 86

def auth_token
  @auth_token
end

#localeObject (readonly)

Returns the value of attribute locale.



86
87
88
# File 'lib/refreshingmenus_api.rb', line 86

def locale
  @locale
end

#versionObject (readonly)

Returns the value of attribute version.



86
87
88
# File 'lib/refreshingmenus_api.rb', line 86

def version
  @version
end

Instance Method Details

Raises:

  • (ArgumentError)


109
110
111
112
# File 'lib/refreshingmenus_api.rb', line 109

def menu(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

Raises:

  • (ArgumentError)


104
105
106
107
# File 'lib/refreshingmenus_api.rb', line 104

def places(options)
  raise ArgumentError, "Expected options to be a Hash, got #{options.inspect}." if not options.is_a?(Hash)
  get('places.json', :extra_query => options, :transform => Place)
end