Module: Insightly2::DSL::Notes

Included in:
Insightly2::DSL
Defined in:
lib/insightly2/dsl/notes.rb

Instance Method Summary collapse

Instance Method Details

#create_note(note:) ⇒ Insightly2::Resources::Note?

POST /v2.1/Notes Creates a note.

Parameters:

  • note (Hash)

    The note to create.

Returns:

Raises:

  • (ArgumentError)

    If the method arguments are blank.



37
38
39
40
# File 'lib/insightly2/dsl/notes.rb', line 37

def create_note(note:)
  raise ArgumentError, "Note cannot be blank" if note.blank?
  Resources::Note.parse(request(:post, "Notes", note))
end

#create_note_comment(id:, comment:) ⇒ Faraday::Response

POST /v2.1/Notes/c_id/Comments Create a comment for a note.

Parameters:

  • id (String, Fixnum)

    A Note’s ID.

  • comment (String)

    The comment to add to the note.

Returns:

  • (Faraday::Response)

    .

Raises:

  • (ArgumentError)

    If the method arguments are blank.



48
49
50
51
52
# File 'lib/insightly2/dsl/notes.rb', line 48

def create_note_comment(id:, comment:)
  raise ArgumentError, "ID cannot be blank" if id.blank?
  raise ArgumentError, "Comment cannot be blank" if comment.blank?
  request(:post, "Notes/#{id}/Comments", comment)
end

#create_note_file(id:, filename:) ⇒ Faraday::Response

POST /v2.1/Notes?c_id=c_id&filename=filename Adds a File Attachment to a Note.

Parameters:

  • id (String, Fixnum)

    A Note’s ID.

  • filename (String)

    The name of the file.

Returns:

  • (Faraday::Response)

    .

Raises:

  • (ArgumentError)

    If the method arguments are blank.



60
61
62
63
64
# File 'lib/insightly2/dsl/notes.rb', line 60

def create_note_file(id:, filename:)
  raise ArgumentError, "ID cannot be blank" if id.blank?
  raise ArgumentError, "Filename cannot be blank" if filename.blank?
  request(:post, "Notes?c_id=#{id}&filename=#{filename}")
end

#delete_note(id:) ⇒ Faraday::Response

DELETE /v2.1/Notes/id

Parameters:

  • id (String, Fixnum)

    A note’s ID.

Returns:

  • (Faraday::Response)

    .

Raises:

  • (ArgumentError)

    If the method arguments are blank.



80
81
82
83
# File 'lib/insightly2/dsl/notes.rb', line 80

def delete_note(id:)
  raise ArgumentError, "ID cannot be blank" if id.blank?
  request(:delete, "Notes/#{id}")
end

#get_note(id:) ⇒ Insightly2::Resources::Note?

GET /v2.1/Notes/id Get a note.

Parameters:

  • id (String, Fixnum)

    A note’s ID.

Returns:

Raises:

  • (ArgumentError)

    If the method arguments are blank.



10
11
12
13
# File 'lib/insightly2/dsl/notes.rb', line 10

def get_note(id:)
  raise ArgumentError, "ID cannot be blank" if id.blank?
  Resources::Note.parse(request(:get, "Notes/#{id}"))
end

#get_note_comments(id:) ⇒ Array?

GET /v2.1/Notes/c_id/Comments Gets the comments attached to a note.

Parameters:

  • id (String, Fixnum)

    A note’s ID.

Returns:

  • (Array, nil)

    .

Raises:

  • (ArgumentError)

    If the method arguments are blank.



20
21
22
23
# File 'lib/insightly2/dsl/notes.rb', line 20

def get_note_comments(id:)
  raise ArgumentError, "ID cannot be blank" if id.blank?
  Resources::Comment.parse(request(:get, "Notes/#{id}/Comments"))
end

#get_notesInsightly2::Resources::Note?

GET /v2.1/Notes Get a list of notes.

Returns:



28
29
30
# File 'lib/insightly2/dsl/notes.rb', line 28

def get_notes
  Resources::Note.parse(request(:get, "Notes"))
end

#update_note(note:) ⇒ Insightly2::Resources::Note?

PUT /v2.1/Notes Updates a note.

Parameters:

  • note (Hash)

    The note to update.

Returns:

Raises:

  • (ArgumentError)

    If the method arguments are blank.



71
72
73
74
# File 'lib/insightly2/dsl/notes.rb', line 71

def update_note(note:)
  raise ArgumentError, "Note cannot be blank" if note.blank?
  Resources::Note.parse(request(:put, "Notes", note))
end