Class: PostProxy::Resources::ProfileComments
- Inherits:
-
Object
- Object
- PostProxy::Resources::ProfileComments
- Defined in:
- lib/postproxy/resources/profile_comments.rb
Instance Method Summary collapse
- #create(profile_id, parent_id:, text:) ⇒ Object
- #delete(profile_id, comment_id) ⇒ Object
- #get(profile_id, comment_id) ⇒ Object
-
#initialize(client) ⇒ ProfileComments
constructor
A new instance of ProfileComments.
- #list(profile_id, placement_id: nil, page: nil, per_page: nil) ⇒ Object
Constructor Details
#initialize(client) ⇒ ProfileComments
Returns a new instance of ProfileComments.
4 5 6 |
# File 'lib/postproxy/resources/profile_comments.rb', line 4 def initialize(client) @client = client end |
Instance Method Details
#create(profile_id, parent_id:, text:) ⇒ Object
29 30 31 32 33 |
# File 'lib/postproxy/resources/profile_comments.rb', line 29 def create(profile_id, parent_id:, text:) result = @client.request(:post, "/profiles/#{profile_id}/comments", json: { parent_id: parent_id, text: text }) ProfileComment.new(**result) end |
#delete(profile_id, comment_id) ⇒ Object
35 36 37 38 |
# File 'lib/postproxy/resources/profile_comments.rb', line 35 def delete(profile_id, comment_id) result = @client.request(:delete, "/profiles/#{profile_id}/comments/#{comment_id}") AcceptedResponse.new(**result) end |
#get(profile_id, comment_id) ⇒ Object
24 25 26 27 |
# File 'lib/postproxy/resources/profile_comments.rb', line 24 def get(profile_id, comment_id) result = @client.request(:get, "/profiles/#{profile_id}/comments/#{comment_id}") ProfileComment.new(**result) end |
#list(profile_id, placement_id: nil, page: nil, per_page: nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/postproxy/resources/profile_comments.rb', line 8 def list(profile_id, placement_id: nil, page: nil, per_page: nil) params = {} params[:placement_id] = placement_id if placement_id params[:page] = page if page params[:per_page] = per_page if per_page result = @client.request(:get, "/profiles/#{profile_id}/comments", params: params) comments = (result[:data] || []).map { |c| ProfileComment.new(**c) } PaginatedResponse.new( data: comments, total: result[:total], page: result[:page], per_page: result[:per_page] ) end |