module SmtpLw::Client::Messages

Public Instance Methods

get_message(id) click to toggle source
# File lib/smtp_lw/client/messages.rb, line 13
def get_message(id)
  res = get("messages/#{id}")
  res.body
end
list_messages(status, start_date, end_date, options = {}) click to toggle source
# File lib/smtp_lw/client/messages.rb, line 4
def list_messages(status, start_date, end_date, options = {})
  options = paginate(options)
  res = get(
    'messages/',
    options.merge(status: status, start_date: start_date, end_date: end_date)
  )
  res.body
end
send_message(subject, body, from, to, options = {}) click to toggle source
# File lib/smtp_lw/client/messages.rb, line 18
def send_message(subject, body, from, to, options = {})
  res = post(
    'messages',
    options.merge(subject: subject, body: body, from: from, to: to)
  )
  res.body
end

Private Instance Methods

paginate(options) click to toggle source
# File lib/smtp_lw/client/messages.rb, line 28
def paginate(options)
  page = options[:page] || 1
  per = options[:per] || (@per_page || SmtpLw.per_page)
  options.merge(page: page, per: per)
end