Class: Mandrill::Messages

Inherits:
Object
  • Object
show all
Defined in:
lib/mandrill/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master) ⇒ Messages



769
770
771
# File 'lib/mandrill/api.rb', line 769

def initialize(master)
    @master = master
end

Instance Attribute Details

#masterObject

Returns the value of attribute master.



767
768
769
# File 'lib/mandrill/api.rb', line 767

def master
  @master
end

Instance Method Details

#cancel_scheduled(id) ⇒ Hash

Cancels a scheduled email.



1131
1132
1133
1134
# File 'lib/mandrill/api.rb', line 1131

def cancel_scheduled(id)
    _params = {:id => id}
    return @master.call 'messages/cancel-scheduled', _params
end

#content(id) ⇒ Hash

Get the full content of a recently sent message



1052
1053
1054
1055
# File 'lib/mandrill/api.rb', line 1052

def content(id)
    _params = {:id => id}
    return @master.call 'messages/content', _params
end

#info(id) ⇒ Hash

Get the information for a single recently sent message



1026
1027
1028
1029
# File 'lib/mandrill/api.rb', line 1026

def info(id)
    _params = {:id => id}
    return @master.call 'messages/info', _params
end

#list_scheduled(to = nil) ⇒ Array

Queries your scheduled emails.



1117
1118
1119
1120
# File 'lib/mandrill/api.rb', line 1117

def list_scheduled(to=nil)
    _params = {:to => to}
    return @master.call 'messages/list-scheduled', _params
end

#parse(raw_message) ⇒ Hash

Parse the full MIME document for an email message, returning the content of the message broken into its constituent pieces



1081
1082
1083
1084
# File 'lib/mandrill/api.rb', line 1081

def parse(raw_message)
    _params = {:raw_message => raw_message}
    return @master.call 'messages/parse', _params
end

#reschedule(id, send_at) ⇒ Hash

Reschedules a scheduled email.



1146
1147
1148
1149
# File 'lib/mandrill/api.rb', line 1146

def reschedule(id, send_at)
    _params = {:id => id, :send_at => send_at}
    return @master.call 'messages/reschedule', _params
end

#search(query = '*', date_from = nil, date_to = nil, tags = nil, senders = nil, api_keys = nil, limit = 100) ⇒ Array

Search recently sent messages and optionally narrow by date range, tags, senders, and API keys. If no date range is specified, results within the last 7 days are returned. This method may be called up to 20 times per minute. If you need the data more often, you can use <a href=“/api/docs/messages.html#method=info”>/messages/info.json</a> to get the information for a single message, or <a href=“help.mandrill.com/entries/21738186-Introduction-to-Webhooks”>webhooks</a> to push activity to your own application for querying.



964
965
966
967
# File 'lib/mandrill/api.rb', line 964

def search(query='*', date_from=nil, date_to=nil, tags=nil, senders=nil, api_keys=nil, limit=100)
    _params = {:query => query, :date_from => date_from, :date_to => date_to, :tags => tags, :senders => senders, :api_keys => api_keys, :limit => limit}
    return @master.call 'messages/search', _params
end

#search_time_series(query = '*', date_from = nil, date_to = nil, tags = nil, senders = nil) ⇒ Array

Search the content of recently sent messages and return the aggregated hourly stats for matching messages



988
989
990
991
# File 'lib/mandrill/api.rb', line 988

def search_time_series(query='*', date_from=nil, date_to=nil, tags=nil, senders=nil)
    _params = {:query => query, :date_from => date_from, :date_to => date_to, :tags => tags, :senders => senders}
    return @master.call 'messages/search-time-series', _params
end

#send(message, async = false, ip_pool = nil, send_at = nil) ⇒ Array

Send a new transactional message through Mandrill



841
842
843
844
# File 'lib/mandrill/api.rb', line 841

def send(message, async=false, ip_pool=nil, send_at=nil)
    _params = {:message => message, :async => async, :ip_pool => ip_pool, :send_at => send_at}
    return @master.call 'messages/send', _params
end

#send_raw(raw_message, from_email = nil, from_name = nil, to = nil, async = false, ip_pool = nil, send_at = nil, return_path_domain = nil) ⇒ Array

Take a raw MIME document for a message, and send it exactly as if it were sent through Mandrill’s SMTP servers



1102
1103
1104
1105
# File 'lib/mandrill/api.rb', line 1102

def send_raw(raw_message, from_email=nil, from_name=nil, to=nil, async=false, ip_pool=nil, send_at=nil, return_path_domain=nil)
    _params = {:raw_message => raw_message, :from_email => from_email, :from_name => from_name, :to => to, :async => async, :ip_pool => ip_pool, :send_at => send_at, :return_path_domain => return_path_domain}
    return @master.call 'messages/send-raw', _params
end

#send_template(template_name, template_content, message, async = false, ip_pool = nil, send_at = nil) ⇒ Array

Send a new transactional message through Mandrill using a template



919
920
921
922
# File 'lib/mandrill/api.rb', line 919

def send_template(template_name, template_content, message, async=false, ip_pool=nil, send_at=nil)
    _params = {:template_name => template_name, :template_content => template_content, :message => message, :async => async, :ip_pool => ip_pool, :send_at => send_at}
    return @master.call 'messages/send-template', _params
end