Class: Google::Places::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/google/places/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Client

Returns a new instance of Client.



13
14
15
# File 'lib/google/places/client.rb', line 13

def initialize(api_key)
  @api_key = api_key
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



11
12
13
# File 'lib/google/places/client.rb', line 11

def api_key
  @api_key
end

Instance Method Details

#nearby_search(location, radius, options = {}) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/google/places/client.rb', line 60

def nearby_search(location, radius, options = {})
  options = options.with_indifferent_access
  self.class.get(
    "/nearbysearch/json",
    { query: build_search_request_parameters(location, radius, options) }
  )
end

#place_add(name, location, types, options = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/google/places/client.rb', line 41

def place_add(name, location, types, options = {})
  options = options.with_indifferent_access
  self.class.post(
    "/add/json",
    {
      query: { key: api_key },
      body: build_add_request_body(name, location, types, options)
    }
  )
end

#place_autocomplete(input, options = {}) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/google/places/client.rb', line 17

def place_autocomplete(input, options = {})
  options = options.with_indifferent_access
  self.class.get(
    "/autocomplete/json",
    { query: build_request_parameters(input, options) }
  )
end

#place_details(place_id, options = {}) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/google/places/client.rb', line 52

def place_details(place_id, options = {})
  options = options.with_indifferent_access
  self.class.get(
    "/details/json",
    { query: build_details_request_parameters(place_id, options) }
  )
end

#place_photos(photo_reference, options = {}) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/google/places/client.rb', line 33

def place_photos(photo_reference, options = {})
  options = options.with_indifferent_access
  self.class.get(
    "/photo",
    { query: build_photo_request_parameters(photo_reference, options) }
  )
end

#query_autocomplete(input, options = {}) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/google/places/client.rb', line 25

def query_autocomplete(input, options = {})
  options = options.with_indifferent_access
  self.class.get(
    "/queryautocomplete/json",
    { query: build_request_parameters(input, options) }
  )
end

#radar_search(location, radius, options = {}) ⇒ Object



76
77
78
79
80
81
82
# File 'lib/google/places/client.rb', line 76

def radar_search(location, radius, options = {})
  options = options.with_indifferent_access
  self.class.get(
    "/radarsearch/json",
    { query: build_search_request_parameters(location, radius, options) }
  )
end

#text_search(query, options = {}) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/google/places/client.rb', line 68

def text_search(query, options = {})
  options = options.with_indifferent_access
  self.class.get(
    "/textsearch/json",
    { query: build_text_search_request_parameters(query, options) }
  )
end