Class: Yelp::Fusion::Endpoint::Phone

Inherits:
Object
  • Object
show all
Defined in:
lib/yelp/fusion/endpoint/phone.rb

Overview

Class to search businesses by phone

Constant Summary collapse

PATH =
'/v3/businesses/search/phone'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Phone

Returns a new instance of Phone.



35
36
37
# File 'lib/yelp/fusion/endpoint/phone.rb', line 35

def initialize(client)
  @client = client
end

Instance Method Details

#phone_search(phone) ⇒ Response::Phone

Make a request to the business endpoint on the API

Examples:

Search for business with params and locale


response = client.phone_search('+14159083801')
response.businesses # [<Business 1>, <Business 2>, <Business 3>]
response.businesses[0].name # 'Yelp'

Parameters:

  • phone (String)

    the phone number

Returns:



51
52
53
54
# File 'lib/yelp/fusion/endpoint/phone.rb', line 51

def phone_search(phone)
  phone_hash = { phone: phone }
  Responses::Phone.new(JSON.parse(phone_request(phone_hash).body))
end