Class: Campaign
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Campaign
- Defined in:
- app/models/campaign.rb
Instance Method Summary collapse
- #google_analytics ⇒ Object
- #schedule_for(datetime) ⇒ Object
- #scheduled? ⇒ Boolean
- #send_now ⇒ Object
- #send_test_to(*emails) ⇒ Object
- #sent ⇒ Object
- #sent? ⇒ Boolean
- #unschedule ⇒ Object
Instance Method Details
#google_analytics ⇒ Object
53 54 55 |
# File 'app/models/campaign.rb', line 53 def google_analytics RefinerySetting.find_or_set Refinery::Mailchimp::API::GoogleAnalyticsSetting[:name], Refinery::Mailchimp::API::GoogleAnalyticsSetting[:default] end |
#schedule_for(datetime) ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/models/campaign.rb', line 37 def schedule_for(datetime) success = Refinery::Mailchimp::API.new.campaign_schedule mailchimp_campaign_id, datetime.utc.strftime("%Y-%m-%d %H:%M:%S") self.update_attribute :scheduled_at, datetime if success success rescue Hominid::APIError false end |
#scheduled? ⇒ Boolean
15 16 17 |
# File 'app/models/campaign.rb', line 15 def scheduled? !!scheduled_at && scheduled_at > Time.now end |
#send_now ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/models/campaign.rb', line 29 def send_now success = Refinery::Mailchimp::API.new.campaign_send_now mailchimp_campaign_id self.update_attribute :sent_at, Time.now if success success rescue Hominid::APIError false end |
#send_test_to(*emails) ⇒ Object
23 24 25 26 27 |
# File 'app/models/campaign.rb', line 23 def send_test_to(*emails) Refinery::Mailchimp::API.new.campaign_send_test mailchimp_campaign_id, emails rescue Hominid::APIError false end |
#sent ⇒ Object
19 20 21 |
# File 'app/models/campaign.rb', line 19 def sent sent_at || scheduled_at end |
#sent? ⇒ Boolean
11 12 13 |
# File 'app/models/campaign.rb', line 11 def sent? !!sent_at || !!scheduled_at && scheduled_at <= Time.now end |