Class: CakeMail::Campaign
- Inherits:
-
Object
- Object
- CakeMail::Campaign
- Defined in:
- lib/cakemail/campaign.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#closed_on ⇒ Object
readonly
Returns the value of attribute closed_on.
-
#created_on ⇒ Object
readonly
Returns the value of attribute created_on.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#status ⇒ Object
Returns the value of attribute status.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
-
.create(name, user) ⇒ Object
Creates a new campaign.
-
.get_list(args) ⇒ Object
Retrieves the list of campaigns.
Instance Method Summary collapse
-
#delete ⇒ Object
Deletes a campaign.
-
#get_info(id = @id) ⇒ Object
Returns information about a campaign.
-
#initialize(id, user) ⇒ Campaign
constructor
A new instance of Campaign.
-
#mailing(id) ⇒ Object
Retreives a mailing by id.
-
#mailing_new(name) ⇒ Object
Creates a new mailing.
- #save ⇒ Object
-
#set_info ⇒ Object
Modifies a campaign.
Constructor Details
#initialize(id, user) ⇒ Campaign
Returns a new instance of Campaign.
21 22 23 24 25 |
# File 'lib/cakemail/campaign.rb', line 21 def initialize(id, user) @user = user @id = id get_info end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
18 19 20 |
# File 'lib/cakemail/campaign.rb', line 18 def client_id @client_id end |
#closed_on ⇒ Object (readonly)
Returns the value of attribute closed_on.
18 19 20 |
# File 'lib/cakemail/campaign.rb', line 18 def closed_on @closed_on end |
#created_on ⇒ Object (readonly)
Returns the value of attribute created_on.
18 19 20 |
# File 'lib/cakemail/campaign.rb', line 18 def created_on @created_on end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
18 19 20 |
# File 'lib/cakemail/campaign.rb', line 18 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
19 20 21 |
# File 'lib/cakemail/campaign.rb', line 19 def name @name end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
18 19 20 |
# File 'lib/cakemail/campaign.rb', line 18 def session @session end |
#status ⇒ Object
Returns the value of attribute status.
19 20 21 |
# File 'lib/cakemail/campaign.rb', line 19 def status @status end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
18 19 20 |
# File 'lib/cakemail/campaign.rb', line 18 def user @user end |
Class Method Details
.create(name, user) ⇒ Object
Creates a new campaign.
63 64 65 66 |
# File 'lib/cakemail/campaign.rb', line 63 def create(name, user) res = user.session.request("CakeMail::API::ClassCampaign", "Create", { :name => name, :user_key => user.user_key }) Campaign.new(res['id'].first, user) end |
.get_list(args) ⇒ Object
Retrieves the list of campaigns.
Arguments :
-
args = { :user => required, :limit => optional, :offset => optional, :status => optional }
71 72 73 74 75 76 77 78 79 |
# File 'lib/cakemail/campaign.rb', line 71 def get_list(args) raise ArgumentError if args.nil? or args[:user].nil? = { :user_key => args[:user].user_key } [:limit] = args[:limit] unless args[:limit].nil? [:offset] = args[:offset] unless args[:offset].nil? [:status] = args[:status] unless args[:status].nil? res = args[:user].session.request("CakeMail::API::ClassCampaign", "GetList", ) res['campaign'] end |
Instance Method Details
#delete ⇒ Object
Deletes a campaign.
27 28 29 30 |
# File 'lib/cakemail/campaign.rb', line 27 def delete @user.session.request("CakeMail::API::ClassCampaign", "Delete", { :campaign_id => @id, :user_key => @user.user_key }) self.freeze end |
#get_info(id = @id) ⇒ Object
Returns information about a campaign.
32 33 34 35 36 37 38 39 40 |
# File 'lib/cakemail/campaign.rb', line 32 def get_info(id = @id) res = @user.session.request("CakeMail::API::ClassCampaign", "GetInfo", { :campaign_id => id, :user_key => @user.user_key }) @client_id = res['client_id'].first @closed_on = res['closed_on'].first @created_on = res['created_on'].first @id = res['id'].first @name = res['name'].first @status = res['status'].first end |
#mailing(id) ⇒ Object
Retreives a mailing by id.
42 43 44 |
# File 'lib/cakemail/campaign.rb', line 42 def mailing(id) return CakeMail::Mailing.new(self, id) end |
#mailing_new(name) ⇒ Object
Creates a new mailing.
46 47 48 |
# File 'lib/cakemail/campaign.rb', line 46 def mailing_new(name) return CakeMail::Mailing.create(self, name) end |
#save ⇒ Object
50 51 52 |
# File 'lib/cakemail/campaign.rb', line 50 def save self.setinfo end |
#set_info ⇒ Object
Modifies a campaign.
54 55 56 57 58 59 |
# File 'lib/cakemail/campaign.rb', line 54 def set_info args = { :campaign_id => id, :user_key => @user.user_key } args[:name] = @name unless @name.nil? args[:status] = @status unless @status.nil? res = @user.session.request("CakeMail::API::ClassCampaign", "SetInfo", args) end |