Module: Catch::Note

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

Instance Method Summary collapse

Instance Method Details

#add_note(params = {}) ⇒ Object

Create a new note.

Waiting on annotations

Parameters:

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

    a customizable set of options

Options Hash (params):

  • :latitude (Integer)

    The latitude.

  • :longitude (Integer)

    The longitude.

  • :source (String)

    Source (application) which created note.

  • :text (String)

    The text of the note

  • :mode (String)

    The sharing settings for the note. If unset, private is implied. (public | private | shared)

  • :accuracy_position (Float)

    The accuracy of coordinates from GPS.

  • :altitude (Float)

    The altitude from GPS associated with the note.

  • :bearing (Float)

    The bearing from GPS associated with the note

  • :speed (Float)

    The speed from GPS associated with the note

  • :speed (Float)

    The speed from GPS associated with the note

  • :created_at (DateTime)

    Date at which the comment was created.

  • :modified_at (DateTime)

    Date of last modification

  • :reminder_at (DateTime)

    Will present a reminder at the time specified on supported devices



47
48
49
50
51
# File 'lib/catch/note.rb', line 47

def add_note(params={})
  payload = params.map {|k,v| "#{k}=#{v}"}.join("&")
  response = connection.post "notes", payload
  response.body.notes.first
end

#delete_note(id) ⇒ Object

Deletes a note, or annotations of a note if specified

Parameters:

  • note_id (Integer)

    Note ID



78
79
80
# File 'lib/catch/note.rb', line 78

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

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

Modify a note

Waiting on annotations

Parameters:

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

    a customizable set of options

Options Hash (params):

  • :latitude (Integer)

    The latitude.

  • :longitude (Integer)

    The longitude.

  • :source (String)

    Source (application) which created note.

  • :text (String)

    The text of the note

  • :mode (String)

    The sharing settings for the note. If unset, private is implied. (public | private | shared)

  • :accuracy_position (Float)

    The accuracy of coordinates from GPS.

  • :altitude (Float)

    The altitude from GPS associated with the note.

  • :bearing (Float)

    The bearing from GPS associated with the note

  • :speed (Float)

    The speed from GPS associated with the note

  • :speed (Float)

    The speed from GPS associated with the note

  • :created_at (DateTime)

    Date at which the comment was created.

  • :modified_at (DateTime)

    Date of last modification

  • :reminder_at (DateTime)

    Will present a reminder at the time specified on supported devices



69
70
71
72
73
# File 'lib/catch/note.rb', line 69

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

#note(id) ⇒ Object

Retrieves a single note

Parameters:

  • note_id (Integer)

    Note ID

  • params (Hash)

    a customizable set of options



27
28
29
# File 'lib/catch/note.rb', line 27

def note(id)
  connection.get("notes/#{id}").body.notes.first
end

#notes(params = {}) ⇒ Object

Lists multiple notes for the current user.

Specifies a note sort order. Valid sort orders are: created_asc sort by note creation date in ascending order (most recent first) create_dec sort by note creation date in descending order (most recent last) modified_asc sort by note modification date in ascending order (most recent first) modified_dec sort by note modification date in descending order (most recent last) text_asc sort by the note text content from in ascending order (A to Z) text_dec sort by the note text content from in descending order (Z to A)

Parameters:

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

    a customizable set of options

Options Hash (params):

  • :sort (String)

    default is created_dec

  • :full (Boolean)

    Whether or not to return full results.

  • :limit (Integer)

    The number of results to return per page. The default is to return all results.

  • :offset (Integer)

    The offset from which to collect results, with default of zero. The number of results is specified by limit.



16
17
18
19
20
21
# File 'lib/catch/note.rb', line 16

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