This gem supports ruby version 1.9+ only.
Installation
Add this line to your application's Gemfile:
gem 'commentatr'
And then execute:
$ bundle
Or install it yourself as:
$ gem install commentatr
Usage
Initialize client
Commentatr::Client.new()
Commentatr::Client.new(partner_host: "example.com", token: "...your secret token...")
Commentatr::Client.new(client_id: 42, token: "...your secret token...")
Fetch comments for blog
cttr.comments(page_id: "blog-1")
cttr.comments(page_id: "blog-1", order: "desc", limit: 5)
cttr.comments(page_id: "blog-1", after: Time.now.to_i - 3600)
Fetch comments for all client blogs
cttr.client_comments(order: "asc", offset: 100, limit: 10)
Fetch counters of comments for each entry of each client blog
cttr.counters
Moderator actions
cttr.approve(comment_id: 1)
cttr.reject(comment_id: 2)
cttr.delete(comment_id: 3)
cttr.junk(comment_id: 4)
cttr.approve(comment_id: [1, 2, 3, 4])
Admin actions
cttr = Commentatr::Client.new(partner_host: "example.com", token: "...your secret token...")
cttr.update_config(approval: false, readonly: true)
commentatr_config[:token] = cttr.regenerate_blog_token(partner_host: "example.com")
commentatr_config[:token] = cttr.regenerate_client_token
You can perform all these actions passing all needed authentication params for each query
cttr = Commentatr::Client.new
cttr.comments(
partner_host: "example.com",
token: "...your secret token...",
page_id: "blog-1",
order: "asc",
offset: 50,
limit: 10
)
Working with responses
All responses are stored in Commentatr::Response
objects
response = cttr.comments(page_id: "blog-1")
response.code
response.body.success
response.body.data
response.body.errors