Class: Capuchin::Scheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/capuchin/scheduler.rb

Instance Method Summary collapse

Constructor Details

#initialize(email, options, api = Capuchin::MailChimp.new) ⇒ Scheduler

Returns a new instance of Scheduler.



3
4
5
6
7
8
# File 'lib/capuchin/scheduler.rb', line 3

def initialize(email, options, api = Capuchin::MailChimp.new)
  @email = email
  @options = options

  @api = api
end

Instance Method Details

#scheduleObject



10
11
12
13
14
15
16
17
18
# File 'lib/capuchin/scheduler.rb', line 10

def schedule
  result = @api.schedule(@email, list_id, template_id, from_name, from_email, delivery_time)

  if result['complete']
    "#{@email.subject} was scheduled to be sent."
  else
    raise "Something went wrong!"
  end
end