Module: Postmark

Defined in:
lib/postmark/response_parsers/active_support.rb,
lib/postmark.rb,
lib/postmark/json.rb,
lib/postmark/bounce.rb,
lib/postmark/http_client.rb,
lib/postmark/response_parsers/json.rb,
lib/postmark/response_parsers/yajl.rb

Overview

assume activesupport is already loaded

Defined Under Namespace

Modules: HttpClient, Json, ResponseParsers Classes: Bounce, InternalServerError, InvalidApiKeyError, InvalidMessageError, UnknownError

Constant Summary collapse

HEADERS =
{
  'Content-type' => 'application/json',
  'Accept'       => 'application/json'
}
MAX_RETRIES =
2

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



32
33
34
# File 'lib/postmark.rb', line 32

def api_key
  @api_key
end

.hostObject

The host to connect to.



47
48
49
# File 'lib/postmark.rb', line 47

def host
  @host
end

.http_open_timeoutObject

Returns the value of attribute http_open_timeout.



32
33
34
# File 'lib/postmark.rb', line 32

def http_open_timeout
  @http_open_timeout
end

.http_read_timeoutObject

Returns the value of attribute http_read_timeout.



32
33
34
# File 'lib/postmark.rb', line 32

def http_read_timeout
  @http_read_timeout
end

.max_retriesObject

Returns the value of attribute max_retries.



32
33
34
# File 'lib/postmark.rb', line 32

def max_retries
  @max_retries
end

.path_prefixObject

The path of the listener



52
53
54
# File 'lib/postmark.rb', line 52

def path_prefix
  @path_prefix
end

.portObject

The port on which your Postmark server runs.



42
43
44
# File 'lib/postmark.rb', line 42

def port
  @port
end

.proxy_hostObject

Returns the value of attribute proxy_host.



32
33
34
# File 'lib/postmark.rb', line 32

def proxy_host
  @proxy_host
end

.proxy_passObject

Returns the value of attribute proxy_pass.



32
33
34
# File 'lib/postmark.rb', line 32

def proxy_pass
  @proxy_pass
end

.proxy_portObject

Returns the value of attribute proxy_port.



32
33
34
# File 'lib/postmark.rb', line 32

def proxy_port
  @proxy_port
end

.proxy_userObject

Returns the value of attribute proxy_user.



32
33
34
# File 'lib/postmark.rb', line 32

def proxy_user
  @proxy_user
end

.response_parser_classObject



37
38
39
# File 'lib/postmark.rb', line 37

def response_parser_class
  @response_parser_class ||= Object.const_defined?(:ActiveSupport) ? :ActiveSupport : :Json
end

.secureObject

Returns the value of attribute secure.



32
33
34
# File 'lib/postmark.rb', line 32

def secure
  @secure
end

.sleep_between_retriesObject

Returns the value of attribute sleep_between_retries.



32
33
34
# File 'lib/postmark.rb', line 32

def sleep_between_retries
  @sleep_between_retries
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Postmark)

    the object that the method was called on



72
73
74
# File 'lib/postmark.rb', line 72

def configure
  yield self
end

.delivery_statsObject



90
91
92
# File 'lib/postmark.rb', line 90

def delivery_stats
  HttpClient.get("deliverystats")
end

.send_through_postmark(message) ⇒ Object

:nodoc:



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/postmark.rb', line 76

def send_through_postmark(message) #:nodoc:
  @retries = 0
  begin
    HttpClient.post("email", Postmark::Json.encode(convert_mail(message)))
  rescue Exception => e
    if @retries < max_retries
       @retries += 1
       retry
    else
      raise
    end
  end
end