Class: DevRuby::Resources::CommentsResource

Inherits:
BaseResource show all
Defined in:
lib/dev_ruby/resources/comments_resource.rb

Instance Attribute Summary

Attributes inherited from BaseResource

#client

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize

Constructor Details

This class inherits a constructor from DevRuby::Resources::BaseResource

Instance Method Details

#all(**params) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dev_ruby/resources/comments_resource.rb', line 6

def all(**params)
  params = to_default_pagination_params(params)

  response = get_request('comments', params: params)

  if Helpers.expected_response?(response, 200)
    collection = Collection.from_response(response: response,
                                          type: DevRuby::Objects::Comment,
                                          params: params)

    Success(collection)
  else
    Failure(error_parser(response))
  end
end

#find(id) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dev_ruby/resources/comments_resource.rb', line 22

def find(id)
  response = get_request("comments/#{id}")

  if Helpers.expected_response?(response, 200)
    comment = DevRuby::Objects::Comment.new(response.body)

    Success(comment)
  else
    Failure(error_parser(response))
  end
end