konstati 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +27 -0
- data/README.markdown +85 -0
- data/lib/konstati.rb +39 -0
- metadata +83 -0
data/LICENSE
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Copyright (c) 2011, W3P Projetos Web
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
- Redistributions of source code must retain the above copyright notice, this list
|
8
|
+
of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
- Redistributions in binary form must reproduce the above copyright notice, this
|
11
|
+
list of conditions and the following disclaimer in the documentation and/or other
|
12
|
+
materials provided with the distribution.
|
13
|
+
|
14
|
+
Neither the name of W3P Projetos Web nor the names of its contributors may be used
|
15
|
+
to endorse or promote products derived from this software without specific prior
|
16
|
+
written permission.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
19
|
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
20
|
+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
21
|
+
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
22
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
23
|
+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
24
|
+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26
|
+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
27
|
+
SUCH DAMAGE.
|
data/README.markdown
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# Konstati Ruby API Client
|
2
|
+
|
3
|
+
Konstati is a service that performs realtime antispam tests agains HTML email
|
4
|
+
messages. Its main purpose is to provide means to email marketers to verify
|
5
|
+
their campaigns before actually sending them.
|
6
|
+
|
7
|
+
As of the date of this document, the only available antispam test is based on
|
8
|
+
Spamassassin.
|
9
|
+
|
10
|
+
This library provides access to the API just like any other activeresource
|
11
|
+
client library.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Use RubyGems to install this library:
|
16
|
+
|
17
|
+
$ gem install konstati
|
18
|
+
|
19
|
+
## Authentication
|
20
|
+
|
21
|
+
Konstati uses HTTP basic authentication, which can be setup using:
|
22
|
+
|
23
|
+
Konstati::Base.authenticate(:username => "user", :password => "password")
|
24
|
+
|
25
|
+
If authentication fails, Konstati will return 401 Unauhtorized.
|
26
|
+
|
27
|
+
## Spamassassin Tests
|
28
|
+
|
29
|
+
### Create a New Test
|
30
|
+
|
31
|
+
This is a sample request:
|
32
|
+
|
33
|
+
result = Konstati::Tests::Spamassassin.create(
|
34
|
+
:bodyHtml => "<p>Hello World</p>", # required
|
35
|
+
:bodyText => "Hello World", # optional
|
36
|
+
:subject => "Free stuff!", # required
|
37
|
+
:fromEmail => "email@example.com", # required
|
38
|
+
:fromName => "John Doe", # required
|
39
|
+
:lang => "pt_BR", # required
|
40
|
+
:customer => "mycustomerlogin" # optional
|
41
|
+
)
|
42
|
+
|
43
|
+
The result will contain the following data:
|
44
|
+
|
45
|
+
id # (String) unique test id, you can use this to query it
|
46
|
+
isSpam # (Boolean) if the message is spam or not (thresold: 7.0 points)
|
47
|
+
lang # (String) language used on the results
|
48
|
+
score # (Float) total spam score for the message
|
49
|
+
customer # (String) optional customer name/login
|
50
|
+
message # (Message) contains all message-related parameters specified in the request
|
51
|
+
status # (String) status of the spam test (done/processing/error/cancelled)
|
52
|
+
testDuration # (Float) time it took for the test to be processed (in seconds)
|
53
|
+
matchedRules # (Array) this Array contains all matched Spamassassin rules,
|
54
|
+
# where each object contains "ruleName", "description",
|
55
|
+
# "score" and "tips" (may be empty)
|
56
|
+
|
57
|
+
### Get a Test Result
|
58
|
+
|
59
|
+
result = Konstati::Tests::Spamassassin.find("4d54f05b898d2994e41dde8b")
|
60
|
+
|
61
|
+
If test does not exist, 404 Not Found will be raised.
|
62
|
+
|
63
|
+
### List Test Results
|
64
|
+
|
65
|
+
results = Konstati::Tests::Spamassassin.find(:all, :params => {})
|
66
|
+
|
67
|
+
Optional parameters in :params may be used to filter results. Available parameters are **lang**,
|
68
|
+
**status** and **customer**. Each parameter can be used alone or in a combination with other(s).
|
69
|
+
|
70
|
+
Here are some examples:
|
71
|
+
|
72
|
+
# all tests performed by "johndoe"
|
73
|
+
results = Konstati::Tests::Spamassassin.find(:all, :params => {:customer => "johndoe"})
|
74
|
+
|
75
|
+
# all tests in pt_BR by "johndoe"
|
76
|
+
results = Konstati::Tests::Spamassassin.find(:all, :params => {:customer => "johndoe", :lang => "pt_BR"})
|
77
|
+
|
78
|
+
# all tests with "done" status in "en_EN"
|
79
|
+
results = Konstati::Tests::Spamassassin.find(:all, :params => {:status => "done", :lang => "en_EN"})
|
80
|
+
|
81
|
+
You can also perform pagination using **perPage** and **pageNumber** parameters. Default behavior is to
|
82
|
+
return the first 20 results. These parameters can also be used together with filters:
|
83
|
+
|
84
|
+
# give me 40 tests performed by "johndoe" in pt_BR
|
85
|
+
results = Konstati::Tests::Spamassassin.find(:all, :params => {:lang => "en_EN", :perPage => 40, :customer => "johndoe"})
|
data/lib/konstati.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "active_resource"
|
2
|
+
|
3
|
+
module Konstati
|
4
|
+
|
5
|
+
VERSION = "0.1.0"
|
6
|
+
|
7
|
+
class Base < ActiveResource::Base
|
8
|
+
|
9
|
+
self.format = :json
|
10
|
+
self.site = "http://api.konstati.co/"
|
11
|
+
self.headers['User-Agent'] = "Konstati Ruby Client v0.1"
|
12
|
+
|
13
|
+
def self.authenticate(options)
|
14
|
+
self.user = options[:username]
|
15
|
+
self.password = options[:password]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.element_path(id, prefix_options = {}, query_options = nil)
|
19
|
+
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
20
|
+
"#{prefix(prefix_options)}#{collection_name}/#{id}#{query_string(query_options)}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.collection_path(prefix_options = {}, query_options = nil)
|
24
|
+
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
25
|
+
"#{prefix(prefix_options)}#{collection_name}#{query_string(query_options)}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module Tests
|
30
|
+
|
31
|
+
class Spamassassin < Base
|
32
|
+
self.site = "http://api.konstati.co/"
|
33
|
+
self.collection_name = "tests/spamassassin"
|
34
|
+
self.element_name = "tests/spamassassin"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: konstati
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Pedro Padron
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-02-11 00:00:00 -02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: activeresource
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Ruby client to the Konstati API
|
36
|
+
email: ppadron@w3p.com.br
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README.markdown
|
43
|
+
- LICENSE
|
44
|
+
files:
|
45
|
+
- lib/konstati.rb
|
46
|
+
- README.markdown
|
47
|
+
- LICENSE
|
48
|
+
has_rdoc: true
|
49
|
+
homepage: http://konstati.co/
|
50
|
+
licenses:
|
51
|
+
- BSD
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project: konstati
|
78
|
+
rubygems_version: 1.3.7
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Ruby client to the Konstati API
|
82
|
+
test_files: []
|
83
|
+
|