Module: Catch::Place

Included in:
Client
Defined in:
lib/catch/place.rb

Instance Method Summary collapse

Instance Method Details

#add_place(latitude, longitude, params = {}) ⇒ Object

Add a place

Waiting on annotations

Parameters:

  • :latitude (Integer)

    The latitude.

  • :longitude (Integer)

    The longitude.

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

    a customizable set of options

Options Hash (params):

  • :address (String)

    The address of the place.

  • :name (String)

    The name of the place

  • :phone (String)

    A phone number for the place

  • :rating (Integer)

    A rating for the place (0 - 5)

  • :created_at (DateTime)

    Date at which the comment was created.

  • :modified_at (DateTime)

    Date of last modification

  • :category (String)

    A category for the place



32
33
34
35
36
37
38
# File 'lib/catch/place.rb', line 32

def add_place(latitude, longitude, params={})
  params[:latitude] = latitude
  params[:longitude] = longitude
  payload = params.map {|k,v| "#{k}=#{v}"}.join("&")
  response = connection.put "places", payload
  response.body.result
end

#delete_place(id) ⇒ Object

Deletes the place

Parameters:

  • :id (Integer)

    The id of a place



63
64
65
# File 'lib/catch/place.rb', line 63

def delete_place(id)
  connection.delete("places/#{id}").body.status == 'ok'
end

#modify_place(id, params = {}) ⇒ Object

Modifies the properties of a place

Waiting on annotations

Parameters:

  • :id (Integer)

    The id of a place

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

    a customizable set of options

Options Hash (params):

  • :latitude (Integer)

    The latitude.

  • :longitude (Integer)

    The longitude.

  • :address (String)

    The address of the place.

  • :name (String)

    The name of the place

  • :phone (String)

    A phone number for the place

  • :rating (Integer)

    A rating for the place (0 - 5)

  • :created_at (DateTime)

    Date at which the comment was created.

  • :modified_at (DateTime)

    Date of last modification

  • :category (String)

    A category for the place

  • :server_modified_at (DateTime)

    Providing the server_modified_at timestamp will ensure that the object being modified is not out of date



54
55
56
57
58
# File 'lib/catch/place.rb', line 54

def modify_place(id, params={})
  payload = params.map {|k,v| "#{k}=#{v}"}.join("&")
  response = connection.post "places/#{id}", payload
  response.body.result
end

#place(id) ⇒ Object

Returns a place by id

Parameters:

  • :id (Integer)

    The id of a place



16
17
18
# File 'lib/catch/place.rb', line 16

def place(id)
  connection.get("places/#{id}").body
end

#places(params = {}) ⇒ Object

Lists all places for the user



6
7
8
9
10
11
# File 'lib/catch/place.rb', line 6

def places(params={})
  connection.get do |req|
    req.url("places")
    req.params.merge!(params)
  end.body.result
end