Class: Contactology::Campaign
- Extended by:
- API
- Defined in:
- lib/contactology/campaign.rb,
lib/contactology/campaign/preview.rb
Overview
Campaigns represent mailing objects on Contactology. These objects may be “standard,” meaning that they go out to a List, or “transactional,” meaning that they’re generated per recipient and used multiple times.
Direct Known Subclasses
Contactology::Campaigns::Standard, Contactology::Campaigns::Transactional
Defined Under Namespace
Classes: Preview
Class Method Summary collapse
-
.create(attributes, options = {}) ⇒ Object
Public: Creates a new Campaign on Contactology.
-
.find(id, options = {}) ⇒ Object
Public: Load the campaign details for a given Contactology Campaign ID.
- .find_by_name(name, options = {}) ⇒ Object
Instance Method Summary collapse
-
#destroy(options = {}) ⇒ Object
Public: Removes the Campaign from Contactology.
- #preview(options = {}) ⇒ Object
-
#save(options = {}) ⇒ Object
Private: This method should be overridden by subclasses of Campaign.
-
#save!(options = {}) ⇒ Object
Public: Creates the instance on Contactology or raises an exception.
Methods included from API
Methods inherited from Stash
Class Method Details
.create(attributes, options = {}) ⇒ Object
Public: Creates a new Campaign on Contactology. This method should not be directly called, but instead called through the Standard or Transactional campaign classes.
Returns a campaign instance when successful. Returns false when unsuccessful.
54 55 56 57 |
# File 'lib/contactology/campaign.rb', line 54 def self.create(attributes, = {}) campaign = new(attributes) campaign.save() ? campaign : false end |
.find(id, options = {}) ⇒ Object
Public: Load the campaign details for a given Contactology Campaign ID.
Returns a Contactology::Campaign instance when found. Returns nil for an unrecognized ID or network error.
65 66 67 68 69 70 71 72 |
# File 'lib/contactology/campaign.rb', line 65 def self.find(id, = {}) query('Campaign_Get_Info', .merge({ 'campaignId' => id, :on_success => Proc.new { |response| Campaign.new(response) if response.kind_of?(Hash) } })) end |
.find_by_name(name, options = {}) ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/contactology/campaign.rb', line 74 def self.find_by_name(name, = {}) query('Campaign_Find', .merge({ 'searchParameters' => { 'campaignName' => name }, :on_success => Proc.new { |response| Campaign.new(response.values.first) unless response.nil? } })) end |
Instance Method Details
#destroy(options = {}) ⇒ Object
Public: Removes the Campaign from Contactology.
Returns true when successful. Returns false when unsuccessful or for a network error.
92 93 94 95 96 97 98 99 |
# File 'lib/contactology/campaign.rb', line 92 def destroy( = {}) self.class.query('Campaign_Delete', .merge({ 'campaignId' => id, :on_timeout => false, :on_error => false, :on_success => Proc.new { |response| response } })) end |
#preview(options = {}) ⇒ Object
120 121 122 123 124 125 126 127 |
# File 'lib/contactology/campaign.rb', line 120 def preview( = {}) self.class.query('Campaign_Preview', .merge({ 'campaignId' => id, :on_error => false, :on_timeout => false, :on_success => Proc.new { |response| Preview.new(response) } })) end |
#save(options = {}) ⇒ Object
Private: This method should be overridden by subclasses of Campaign.
Raises NotImplementedError.
106 107 108 |
# File 'lib/contactology/campaign.rb', line 106 def save( = {}) raise NotImplementedError end |
#save!(options = {}) ⇒ Object
Public: Creates the instance on Contactology or raises an exception.
Returns the campaign instance when successful. Raises InvalidObjectError when unsuccessful.
116 117 118 |
# File 'lib/contactology/campaign.rb', line 116 def save!( = {}) save() || raise(InvalidObjectError) end |