class Connoisseur::Client

Public Class Methods

build(key: Connoisseur.key, user_agent: Connoisseur.user_agent) click to toggle source

Public: Build a Connoisseur client.

key - Your Akismet API key, obtained from akismet.com.

Defaults to Connoisseur.key.

user_agent - The String value to provide in the User-Agent header when issuing

HTTP requests to the Akismet API. Defaults to Connoisseur.user_agent.

Raises ArgumentError if the key is nil or blank. Returns a Connoisseur::Client.

# File lib/connoisseur/client.rb, line 14
def self.build(key: Connoisseur.key, user_agent: Connoisseur.user_agent)
  Connoisseur::Client.new \
    Connoisseur::Service.new(key: key, user_agent: user_agent)
end
new(service) click to toggle source

Internal: Initialize a Connoisseur client.

service - A Connoisseur::Service for issuing API requests.

# File lib/connoisseur/client.rb, line 22
def initialize(service)
  @service = service
end

Public Instance Methods

comment(&block) click to toggle source

Public: Build a comment.

Yields a Connoisseur::Comment::Definition for declaring the comment's attributes.

Examples

client.comment do |c|
  c.blog url: "https://example.com"
  c.post url: "https://example.com/posts/hello-world"
  c.author name: "Jane Smith"
  c.content "Nice post!"
end
# => #<Connoisseur::Comment ...>

Returns a Connoisseur::Comment.

# File lib/connoisseur/client.rb, line 41
def comment(&block)
  Connoisseur::Comment.define(@service, &block)
end
verify_key_for(blog:) click to toggle source

Public: Verify the client's Akismet API key.

blog - The URL of the blog associated with the key.

Returns true or false indicating whether the key is valid for the given blog.

# File lib/connoisseur/client.rb, line 50
def verify_key_for(blog:)
  @service.verify_key_for(blog: blog)
end