Class: CakeMail::Relay

Inherits:
Object
  • Object
show all
Defined in:
lib/cakemail/relay.rb

Class Method Summary collapse

Class Method Details

.get_logs(args) ⇒ Object

Retrieves logs from Relay.

Arguments :

  • args = { :user => required, :log_type => required, :start_time => optional, :end_time => optional }

Raises:

  • (ArgumentError)


54
55
56
57
58
59
60
61
# File 'lib/cakemail/relay.rb', line 54

def get_logs(args)
  raise ArgumentError if args.nil? or args[:user] or args[:log_type].nil?
  options = { :user_key => args[:user].user_key, :log_type => args[:log_type] }
  options[:start_time] = args[:start_time] unless args[:start_time].nil?
  options[:end_time] = args[:end_time] unless args[:end_time].nil?
  res = args[:user].session.request("CakeMail::API::ClassRelay", "Send", options)
  return res['bounce_log']
end

.send(args) ⇒ Object

Send an email using the Relay.

Arguments :

  • args = { :user => required, :email => required, :sender_name => required, :sender_email => required, :subject => required, :html_message => optional, :text_message => optional, :encoding => optional, :track_opening => optional, :track_clicks_in_html => optional, :track_clicks_in_text => optional, :data => optional/custom }

Custom format of :data :

  • { :type => “text”, :name => “schedule” }, { :type => “text”, :name => “schedule” }, …

Raises:

  • (ArgumentError)


37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cakemail/relay.rb', line 37

def send(args)
  raise ArgumentError if args.nil? or args[:user] or args[:email].nil? or args[:sender_name] or args[:sender_email] or args[:subject]
  options = { :user_key => args[:user].user_key, :email => args[:email], :sender_name => args[:sender_name], 
    :sender_email => args[:sender_email], :subject => args[:subject] }
  options[:html_message] = args[:html_message] unless args[:html_message].nil?
  options[:text_message] = args[:text_message] unless args[:text_message].nil?
  options[:encoding] = args[:encoding] unless args[:encoding].nil?
  options[:track_opening] = args[:track_opening] unless args[:track_opening].nil?
  options[:track_clicks_in_html] = args[:track_clicks_in_html] unless args[:track_clicks_in_html].nil?
  options[:track_clicks_in_text] = args[:track_clicks_in_text] unless args[:track_clicks_in_text].nil?
  options[:data] = args[:data] unless args[:data].nil?
  res = args[:user].session.request("CakeMail::API::ClassRelay", "Send", options)
end