Class: SchedulerBookingMailer

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/scheduler_booking_mailer.rb

Overview

ActionMailer: scheduler booking.

Instance Method Summary collapse

Methods inherited from ApplicationMailer

#null_mail

Instance Method Details

#cancellation(booking) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/mailers/scheduler_booking_mailer.rb', line 57

def cancellation(booking)
  @booking = booking
  @employee = booking.employee
  @booking_page = booking.scheduler_booking_page

  attach_ical(booking, method: :cancel)

  mail(
    from: "#{@employee.full_name} <#{@employee.email}>",
    to: booking.guest_email,
    subject: "Cancelled: #{@booking_page.name} with #{@employee.full_name}"
  )
end

#confirmation(booking) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/mailers/scheduler_booking_mailer.rb', line 11

def confirmation(booking)
  @booking = booking
  @employee = booking.employee
  @booking_page = booking.scheduler_booking_page

  attach_ical(booking, method: :request)

  mail(
    from: "#{@employee.full_name} <#{@employee.email}>",
    to: booking.guest_email,
    subject: "Confirmed: #{@booking_page.name} with #{@employee.full_name}"
  )
end

#default_url_optionsObject



7
8
9
# File 'app/mailers/scheduler_booking_mailer.rb', line 7

def default_url_options
  { host: WEB_HOSTNAME, protocol: 'https' }
end

#reminder(booking, hours_before:) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/mailers/scheduler_booking_mailer.rb', line 25

def reminder(booking, hours_before:)
  @booking = booking
  @employee = booking.employee
  @booking_page = booking.scheduler_booking_page
  @hours_before = hours_before

  attach_ical(booking, method: :publish)

  time_label = hours_before == 24 ? 'tomorrow' : 'in 1 hour'
  mail(
    from: "#{@employee.full_name} <#{@employee.email}>",
    to: booking.guest_email,
    subject: "Reminder: #{@booking_page.name} with #{@employee.full_name} #{time_label}"
  )
end

#reschedule(booking, old_starts_at:, old_timezone:) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/mailers/scheduler_booking_mailer.rb', line 41

def reschedule(booking, old_starts_at:, old_timezone:)
  @booking = booking
  @employee = booking.employee
  @booking_page = booking.scheduler_booking_page
  @old_starts_at = old_starts_at.in_time_zone(old_timezone)
  @old_timezone = old_timezone

  attach_ical(booking, method: :request)

  mail(
    from: "#{@employee.full_name} <#{@employee.email}>",
    to: booking.guest_email,
    subject: "Rescheduled: #{@booking_page.name} with #{@employee.full_name}"
  )
end