class Postal::Client
Public Class Methods
instance()
click to toggle source
Create and cache a global instance of client based on the environment variables which can be provided. In 90% of cases, Postal
will be accessed through this.
# File lib/postal/client.rb, line 13 def self.instance @instance ||= Client.new(Postal.config.host, Postal.config.server_key) end
new(host, server_key)
click to toggle source
Initialize a new client with the host and API key
# File lib/postal/client.rb, line 20 def initialize(host, server_key) @host = host @server_key = server_key end
Public Instance Methods
messages()
click to toggle source
Provide a scope to access messages
# File lib/postal/client.rb, line 28 def messages MessageScope.new(self) end
moonrope()
click to toggle source
Return the backend moonrope instance for this client
# File lib/postal/client.rb, line 53 def moonrope @moonrope ||= begin headers= {'X-Server-API-Key' => @server_key} MoonropeClient::Connection.new(@host, :headers => headers, :ssl => true) end end
send_message(&block)
click to toggle source
Send a message
# File lib/postal/client.rb, line 35 def send_message(&block) message = SendMessage.new(self) block.call(message) message.send! end
send_raw_message(&block)
click to toggle source
Send a raw message
# File lib/postal/client.rb, line 44 def send_raw_message(&block) message = SendRawMessage.new(self) block.call(message) message.send! end