Class: CommunicartMailer

Inherits:
ActionMailer::Base
  • Object
show all
Includes:
Roadie::Rails::Automatic
Defined in:
app/mailers/communicart_mailer.rb

Instance Method Summary collapse

Instance Method Details

#approval_reply_received_email(approval) ⇒ Object


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/mailers/communicart_mailer.rb', line 32

def approval_reply_received_email(approval)
  cart = approval.cart
  @approval = approval
  @cart = cart.decorate
  to_address = cart.requester.email_address
  #TODO: Add a specific 'rejection' text block for the requester

  set_attachments(cart)

  mail(
       to: to_address,
       subject: "User #{approval.user.email_address} has #{approval.status} cart ##{cart.external_id}",
       from: user_email(approval.user)
       )
end

#cart_notification_email(to_email, approval) ⇒ Object


9
10
11
12
13
# File 'app/mailers/communicart_mailer.rb', line 9

def cart_notification_email(to_email, approval)
  @approval = approval
  from_email = user_email(approval.cart.requester)
  send_cart_email(from_email, to_email, approval.cart)
end

#cart_observer_email(to_email, cart) ⇒ Object


15
16
17
18
# File 'app/mailers/communicart_mailer.rb', line 15

def cart_observer_email(to_email, cart)
  # TODO have the from_email be whomever triggered this notification
  send_cart_email(sender, to_email, cart)
end

#comment_added_email(comment, to_email) ⇒ Object


48
49
50
51
52
53
54
55
56
57
# File 'app/mailers/communicart_mailer.rb', line 48

def comment_added_email(comment, to_email)
  @comment_text = comment.comment_text
  @cart_item = comment.commentable

  mail(
       to: to_email,
       subject: "A comment has been added to cart item '#{@cart_item.description}'",
       from: user_email(comment.user)
       )
end

#proposal_created_confirmation(cart) ⇒ Object


20
21
22
23
24
25
26
27
28
29
30
# File 'app/mailers/communicart_mailer.rb', line 20

def proposal_created_confirmation(cart)
  @cart = cart.decorate
  to_address = cart.requester.email_address
  from_email = user_email(cart.requester)

  mail(
       to: to_address,
       subject: "Your request for Proposal ##{cart.id} has been sent successfully.",
       from: from_email
       )
end