Module: Insightly2::DSL::Comments

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

Instance Method Summary collapse

Instance Method Details

#create_comment_attachment(id: nil, filename: nil) ⇒ Faraday::Response

POST /v2.1/Comments?c_id=c_id&filename=filename Adds a file attachment to a comment.

Parameters:

  • id (String, Fixnum) (defaults to: nil)

    A comment’s ID.

  • filename (String) (defaults to: nil)

    The name of the attachment.

Returns:

  • (Faraday::Response)

    .

Raises:

  • (ArgumentError)

    If the method arguments are blank.



21
22
23
24
25
# File 'lib/insightly2/dsl/comments.rb', line 21

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

#delete_comment(id: nil) ⇒ Faraday::Response

DELETE /v2.1/Comments/id Deletes a comment.

Parameters:

  • id (String, Fixnum) (defaults to: nil)

    A comment’s ID.

Returns:

  • (Faraday::Response)

    .

Raises:

  • (ArgumentError)

    If the method arguments are blank.



42
43
44
45
# File 'lib/insightly2/dsl/comments.rb', line 42

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

#get_comment(id: nil) ⇒ Insightly2::Resources::Comment?

GET /v2.1/Comments/id Get a comment.

Parameters:

  • id (String, Fixnum) (defaults to: nil)

    A comment’s ID.

Returns:

Raises:

  • (ArgumentError)

    If the method arguments are blank.



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

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

#update_comment(comment: nil) ⇒ Insightly2::Resources::Comment?

PUT /v2.1/Comments Updates a comment.

Parameters:

  • comment (Hash) (defaults to: nil)

    The comment to update.

Returns:

Raises:

  • (ArgumentError)

    If the method arguments are blank.



32
33
34
35
# File 'lib/insightly2/dsl/comments.rb', line 32

def update_comment(comment: nil)
  raise ArgumentError, "Comment cannot be blank" if comment.blank?
  Resources::Comment.parse(request(:put, "Comments", comment))
end