class Thron::Gateway::Comment

Constants

PACKAGE

Public Class Methods

routes() click to toggle source
# File lib/thron/gateway/comment.rb, line 11
def self.routes
  @routes ||= {
    comment_detail: Route::factory(name: 'detail', package: PACKAGE, verb: Route::Verbs::GET),
    list_comments: Route::factory(name: 'getComments', package: PACKAGE, verb: Route::Verbs::GET),
    insert_comment: Route::factory(name: 'insertComment', package: PACKAGE),
    report_comment_abuse: Route::factory(name: 'reportAbuse', package: PACKAGE)
  }
end

Public Instance Methods

comment_detail(options = {}) click to toggle source
# File lib/thron/gateway/comment.rb, line 20
def comment_detail(options = {})
  comment_id = options[:comment_id]
  query = { 
    clientId: client_id,
    commentId: comment_id
  }
  route(to: __callee__, query: query, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body.fetch('comment') { {} })
  end
end
insert_comment(options = {}) click to toggle source
# File lib/thron/gateway/comment.rb, line 49
def insert_comment(options = {})
  content_id = options[:content_id]
  data = options[:data]
  category_id = options[:category_id]
  body = { 
    clientId: client_id,
    contentId: content_id,
    comment: data,
    categoryIdForAcl: category_id
  }
  route(to: __callee__, body: body, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body.fetch('comment') { {} })
  end
end
list_comments(options = {}) click to toggle source
# File lib/thron/gateway/comment.rb, line 31
def list_comments(options = {})
  criteria = options.fetch(:criteria) { {} }
  locale = options[:locale]
  order_by = options[:order_by]
  offset = options[:offset].to_i
  limit = options[:limit].to_i
  order_by = order_by ? { orderBy: order_by } : {}
  query = { 
    clientId: client_id,
    locale: locale,
    offset: offset,
    numberOfResults: limit
  }.merge(criteria).merge(order_by)
  route(to: __callee__, query: query, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body.fetch('comments') { [] })
  end
end
report_comment_abuse(options = {}) click to toggle source
# File lib/thron/gateway/comment.rb, line 64
def report_comment_abuse(options = {})
  comment_id = options[:comment_id]
  user_id = options[:user_id]
  query = { 
    clientId: client_id,
    commentId: comment_id,
    userId: user_id
  }
  route(to: __callee__, query: query, token_id: token_id)
end