Class: Yelp::Request

Inherits:
Record show all
Defined in:
lib/yelp/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Request

Returns a new instance of Request.



21
22
23
24
25
26
27
# File 'lib/yelp/request.rb', line 21

def initialize (params)
  default_params = {
    :compress_response => true,
    :response_format => Yelp::ResponseFormat::JSON_TO_RUBY
    }
  super(default_params.merge(params))
end

Instance Attribute Details

#compress_responseObject (readonly) Also known as: compress_response?

specifies whether the response content should be transmitted over the wire compressed, defaulting to true.



7
8
9
# File 'lib/yelp/request.rb', line 7

def compress_response
  @compress_response
end

#response_formatObject (readonly)

one of the Yelp::ResponseFormat format specifiers detailing the desired format of the search results, defaulting to Yelp::ResponseFormat::JSON_TO_RUBY.



12
13
14
# File 'lib/yelp/request.rb', line 12

def response_format
  @response_format
end

#yws_idObject (readonly)

the Yelp Web Services ID to be passed with the request for authentication purposes. See www.yelp.com/developers/getting_started/api_access to get your own.



17
18
19
# File 'lib/yelp/request.rb', line 17

def yws_id
  @yws_id
end

Instance Method Details

#to_yelp_paramsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/yelp/request.rb', line 29

def to_yelp_params
  params = {
    :ywsid => yws_id
  }

  # if they specified anything other than a json variant, we
  # need to tell yelp what we're looking for
  case @response_format
  when Yelp::ResponseFormat::PICKLE
    params[:output] = 'pickle'
  when Yelp::ResponseFormat::PHP 
    params[:output] = 'php'
  end

  params
end