Class: Office::LeadActionTemplate

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/office/lead_action_template.rb

Constant Summary collapse

KIND_UNSUBSCRIBE_TEMPLATE =
'kind-unsubscribe-template'
KIND_UNSUBSCRIBE_CAMPAIGN =
'kind-unsubscribe-campaign'
KINDS =
[ KIND_UNSUBSCRIBE_TEMPLATE, KIND_UNSUBSCRIBE_CAMPAIGN ]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.listObject



41
42
43
# File 'lib/office/lead_action_template.rb', line 41

def self.list
  [ [nil,nil] ] + all.map { |i| [ i.slug, i.id.to_s ] }
end

Instance Method Details

#to_sObject



23
24
25
# File 'lib/office/lead_action_template.rb', line 23

def to_s
  "OLAT:#{slug}"
end

#unsubscribe_from_campaignObject



27
28
# File 'lib/office/lead_action_template.rb', line 27

def unsubscribe_from_campaign
end

#unsubscribe_from_templateObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/office/lead_action_template.rb', line 30

def unsubscribe_from_template
  template = EmailTemplate.find( ctx[:template_id] )
  subject  = "Lead #{lead.full_name} unsubscribed from template #{template.slug}"
  out      = Mailer.notify( '[email protected]', subject )
  Rails.env.production? ? out.deliver_later : out.deliver_now
  Office::Unsubscribe.create({
    lead_id: lead_id,
    template_id: config_json['template_id'],
  })
end