class Yelp::Fusion::Endpoint::Transaction

Endpoint to search for Yelp transactions

Constants

PATH

Public Class Methods

new(client) click to toggle source
# File lib/yelp/fusion/endpoint/transaction.rb, line 35
def initialize(client)
  @client = client
end

Public Instance Methods

transaction_by_coordinates(transaction_type, coordinates) click to toggle source

Search by coordinates: give it a latitude and longitude along with option accuracy, altitude, and altitude_accuracy to search an area. More info at www.yelp.com/developers/documentation/v3/transaction_search

@param coordinates [Hash] a hash of latitude and longitude. @param params [Hash] a hash that corresponds to params on the API:

https://www.yelp.com/developers/documentation/v3/transaction_search

@return [Response::Search] a parsed object of the response.

For a complete list of possible response values visit:
https://www.yelp.com/developers/documentation/v3/transaction_search

@example Search for business with params

coordinates = { latitude: 37.786732,
                longitude: -122.399978 }

response = client.search('delivery', coordinates)
response.businesses # [<Business 1>, <Business 2>, <Business 3>]
response.businesses[0].name # 'Yelp'
# File lib/yelp/fusion/endpoint/transaction.rb, line 71
def transaction_by_coordinates(transaction_type, coordinates)
  raise Error::MissingLatLng if coordinates[:latitude].nil? ||
                                coordinates[:longitude].nil?

  result = transaction_request(transaction_type, coordinates)
  Responses::Transaction.new(JSON.parse(result.body))
end

Private Instance Methods

transaction_request(transaction_type, location) click to toggle source

Make a request to the transaction endpoint of the API The endpoint requires a format of /v3/transaction_search so the primary request parameter is concatenated. After getting the response back it's checked to see if there are any API errors and raises the relevant one if there is.

@param transaction_type [String] it has to be delivery @param location [Hash] a hash of supported location @return [Faraday::Response] the raw response back from the connection

# File lib/yelp/fusion/endpoint/transaction.rb, line 90
def transaction_request(transaction_type, location)
  result = @client.connection.get (PATH +
    ERB::Util.url_encode(transaction_type) + '/search'), location
  Error.check_for_error(result)
  result
end