Giter VIP home page Giter VIP logo

ruby-konstati's Introduction

Konstati Ruby API Client

Konstati is a service that performs realtime antispam tests agains HTML email messages. Its main purpose is to provide means to email marketers to verify their campaigns before actually sending them.

As of the date of this document, the only available antispam test is based on Spamassassin.

This library provides access to the API just like any other activeresource client library.

Installation

Use RubyGems to install this library:

$ gem install konstati

Authentication

Konstati uses HTTP basic authentication, which can be setup using:

Konstati.username = "user"
Konstati.apikey   = "apikey"

If authentication fails, Konstati will return 401 Unauhtorized.

Spamassassin Tests

Create a New Test

This is a sample request:

result = Konstati::Tests.create(
  :bodyHtml  => "<p>Hello World</p>",  # required
  :bodyText  => "Hello World",         # optional
  :subject   => "Free stuff!",         # required
  :fromEmail => "[email protected]",   # required
  :fromName  => "John Doe",            # required
  :customer  => "mycustomerlogin"      # optional
)

The result will contain the following data:

id            # (String)  unique test id, you can use this to query it later
emailMessage  # (Hash)    contains all message-related parameters specified in the request
customer      # (String)  optional customer name/login supplied in the request
lang          # (String)  language used on the results
type          # (String)  type of test (currently only spamassassin)
status        # (String)  status of the spam test (done/processing/error/cancelled)
startedAt     # (Float)   when the test was started (in seconds)
updatedAt     # (Float)   when the test was last updated (in seconds)
totalRuntime  # (Float)   time it took for the test to be processed (in seconds)
result        # (Hash)    contains all test result fields (score, isSpam, matchedRules)

Get a Test Result

result = Konstati::Tests.find("4d54f05b898d2994e41dde8b")

If test does not exist, 404 Not Found will be raised.

List Test Results

results = Konstati::Tests.find(:params => {})

Optional parameters in :params may be used to filter results. Available parameters are lang, status and customer. Each parameter can be used alone or with other(s).

Here are some examples:

# all tests performed by "johndoe"
results = Konstati::Tests.find(:params => {:customer => "johndoe"})

# all tests in pt by "johndoe"
results = Konstati::Tests.find(:params => {:customer => "johndoe", :lang => "pt"})

# all tests with "done" status in "en"
results = Konstati::Tests  .find(:params => {:status => "done", :lang => "en"})

You can also perform pagination using perPage and pageNumber parameters. Default behavior is to return the first 20 results. These parameters can also be used together with filters:

# give me 40 tests performed by "johndoe" in pt
results = Konstati::Tests.find(:params => {:lang => "en", :perPage => 40, :customer => "johndoe"})

ruby-konstati's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.