Class: Basecamp::Services::CommentsService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/basecamp/generated/services/comments_service.rb

Overview

Service for Comments operations

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Basecamp::Services::BaseService

Instance Method Details

#create(recording_id:, content:) ⇒ Hash

Create a new comment on a recording

Parameters:

  • recording_id (Integer)

    recording id ID

  • content (String)

    content

Returns:

  • (Hash)

    response data



45
46
47
48
49
# File 'lib/basecamp/generated/services/comments_service.rb', line 45

def create(recording_id:, content:)
  with_operation(service: "comments", operation: "create", is_mutation: true, resource_id: recording_id) do
    http_post("/recordings/#{recording_id}/comments.json", body: compact_params(content: content)).json
  end
end

#get(comment_id:) ⇒ Hash

Get a single comment by id

Parameters:

  • comment_id (Integer)

    comment id ID

Returns:

  • (Hash)

    response data



13
14
15
16
17
# File 'lib/basecamp/generated/services/comments_service.rb', line 13

def get(comment_id:)
  with_operation(service: "comments", operation: "get", is_mutation: false, resource_id: comment_id) do
    http_get("/comments/#{comment_id}", operation: "GetComment").json
  end
end

#list(recording_id:, page: nil, max_items: nil) ⇒ ListEnumerator<Hash>

List comments on a recording

Parameters:

  • recording_id (Integer)

    recording id ID

  • page (Integer, nil) (defaults to: nil)

    Page number for paginating through results. Defaults to 1. A positive value selects exactly that page, not a starting offset; see SPEC section 8.

  • max_items (Integer, nil) (defaults to: nil)

    cap on items yielded across pages; nil or non-positive means no cap

Returns:

  • (ListEnumerator<Hash>)

    lazily paginated results (#meta carries pagination metadata)



34
35
36
37
38
39
# File 'lib/basecamp/generated/services/comments_service.rb', line 34

def list(recording_id:, page: nil, max_items: nil)
  wrap_paginated(service: "comments", operation: "list", is_mutation: false, resource_id: recording_id) do
    params = compact_query_params(page: page)
    paginate("/recordings/#{recording_id}/comments.json", params: params, operation: "ListComments", max_items: max_items)
  end
end

#update(comment_id:, content:) ⇒ Hash

Update an existing comment

Parameters:

  • comment_id (Integer)

    comment id ID

  • content (String)

    content

Returns:

  • (Hash)

    response data



23
24
25
26
27
# File 'lib/basecamp/generated/services/comments_service.rb', line 23

def update(comment_id:, content:)
  with_operation(service: "comments", operation: "update", is_mutation: true, resource_id: comment_id) do
    http_put("/comments/#{comment_id}", body: compact_params(content: content)).json
  end
end