Module: Ohanakapa::Client::Locations

Included in:
Ohanakapa::Client
Defined in:
lib/ohanakapa/client/locations.rb

Overview

Methods for the Locations API

Instance Method Summary collapse

Instance Method Details

#location(id) ⇒ Sawyer::Resource Also known as: loc

Get a single location based on its ID

Examples:

Ohanakapa.location('519c44065634241897000023')
Ohanakapa.loc('519c44065634241897000023')

Parameters:

  • id (String)

    location ID.

Returns:

  • (Sawyer::Resource)

See Also:



36
37
38
# File 'lib/ohanakapa/client/locations.rb', line 36

def location(id)
  get("locations/#{id}")
end

#locations(options = {}) ⇒ Array<Sawyer::Resource> Also known as: locs

List all locations

This provides a dump of every location, in the order that they were uploaded to the Ohana DB.

Examples:

Ohanakapa.locations
Ohanakapa.locs

Returns:

  • (Array<Sawyer::Resource>)

    List of Locations.

See Also:



22
23
24
# File 'lib/ohanakapa/client/locations.rb', line 22

def locations(options={})
  paginate "locations", options
end

#nearby(id, options = {}) ⇒ Sawyer::Resource

Get nearby locations to an location, based on its ID

Examples:

Ohanakapa.nearby('519c44065634241897000023', :radius => 0.5)

Parameters:

  • id (String)

    location ID.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :radius (Float)

Returns:

  • (Sawyer::Resource)

    Hash representing nearby locations.



49
50
51
# File 'lib/ohanakapa/client/locations.rb', line 49

def nearby(id, options={})
  get("locations/#{id}/nearby", options)
end

#update_location(id, options) ⇒ Sawyer::Resource

Update a location

Examples:

Ohanakapa.update_location("521d33a01974fcdb2b0036a9", :kind => "entertainment")

Parameters:

  • id (String)

    location ID.

  • options (Hash)

    A customizable set of options.

Options Hash (options):

  • :kind (String)

Returns:

  • (Sawyer::Resource)


61
62
63
# File 'lib/ohanakapa/client/locations.rb', line 61

def update_location(id, options)
  put "locations/#{id}", :query => options
end