Module: PostmarkSpamcheck

Defined in:
lib/postmark_spamcheck.rb,
lib/postmark_spamcheck/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.clientObject



6
7
8
# File 'lib/postmark_spamcheck.rb', line 6

def self.client
  @client ||= Restfulie.at('http://spamcheck.postmarkapp.com/filter').as("application/json").accepts("application/json")
end

.report_for(email) ⇒ Object

Raises:



17
18
19
20
21
22
# File 'lib/postmark_spamcheck.rb', line 17

def self.report_for(email)
  resource = client.post(:email => email, :options => 'long').resource
  raise Error, resource['message'] unless resource['success']

  resource['report']
end

.score_for(email) ⇒ Object

Raises:



10
11
12
13
14
15
# File 'lib/postmark_spamcheck.rb', line 10

def self.score_for(email)
  resource = client.post(:email => email, :options => 'short').resource
  raise Error, resource['message'] unless resource['success']

  resource['score'].to_f
end