Class: CakeMail::Trigger
- Inherits:
-
Object
- Object
- CakeMail::Trigger
- Defined in:
- lib/cakemail/trigger.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#delay ⇒ Object
Returns the value of attribute delay.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#html_message ⇒ Object
Returns the value of attribute html_message.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent_id ⇒ Object
Returns the value of attribute parent_id.
-
#send_to ⇒ Object
Returns the value of attribute send_to.
-
#sender_email ⇒ Object
Returns the value of attribute sender_email.
-
#sender_name ⇒ Object
Returns the value of attribute sender_name.
-
#status ⇒ Object
Returns the value of attribute status.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#text_message ⇒ Object
Returns the value of attribute text_message.
Class Method Summary collapse
-
.create(args) ⇒ Object
Creates a trigger.
-
.get_list(args) ⇒ Object
Retrieves the list of triggers.
Instance Method Summary collapse
-
#get_info(id = @id) ⇒ Object
Returns information about a trigger.
-
#initialize(id, user) ⇒ Trigger
constructor
A new instance of Trigger.
- #save ⇒ Object
-
#set_info ⇒ Object
Returns information about a trigger.
Constructor Details
#initialize(id, user) ⇒ Trigger
Returns a new instance of Trigger.
18 19 20 21 22 |
# File 'lib/cakemail/trigger.rb', line 18 def initialize(id, user) @user = user @id = id get_info end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
15 16 17 |
# File 'lib/cakemail/trigger.rb', line 15 def action @action end |
#delay ⇒ Object
Returns the value of attribute delay.
15 16 17 |
# File 'lib/cakemail/trigger.rb', line 15 def delay @delay end |
#encoding ⇒ Object
Returns the value of attribute encoding.
15 16 17 |
# File 'lib/cakemail/trigger.rb', line 15 def encoding @encoding end |
#html_message ⇒ Object
Returns the value of attribute html_message.
15 16 17 |
# File 'lib/cakemail/trigger.rb', line 15 def @html_message end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/cakemail/trigger.rb', line 14 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/cakemail/trigger.rb', line 15 def name @name end |
#parent_id ⇒ Object
Returns the value of attribute parent_id.
15 16 17 |
# File 'lib/cakemail/trigger.rb', line 15 def parent_id @parent_id end |
#send_to ⇒ Object
Returns the value of attribute send_to.
15 16 17 |
# File 'lib/cakemail/trigger.rb', line 15 def send_to @send_to end |
#sender_email ⇒ Object
Returns the value of attribute sender_email.
15 16 17 |
# File 'lib/cakemail/trigger.rb', line 15 def sender_email @sender_email end |
#sender_name ⇒ Object
Returns the value of attribute sender_name.
15 16 17 |
# File 'lib/cakemail/trigger.rb', line 15 def sender_name @sender_name end |
#status ⇒ Object
Returns the value of attribute status.
15 16 17 |
# File 'lib/cakemail/trigger.rb', line 15 def status @status end |
#subject ⇒ Object
Returns the value of attribute subject.
15 16 17 |
# File 'lib/cakemail/trigger.rb', line 15 def subject @subject end |
#text_message ⇒ Object
Returns the value of attribute text_message.
15 16 17 |
# File 'lib/cakemail/trigger.rb', line 15 def @text_message end |
Class Method Details
.create(args) ⇒ Object
Creates a trigger.
Arguments :
-
args = { :user => required, :name => required, :list_id => required, :encoding => optional, :description => optional }
68 69 70 71 72 73 74 75 |
# File 'lib/cakemail/trigger.rb', line 68 def create(args) raise ArgumentError if args.nil? or args[:user].nil? or args[:name].nil? or args[:list_id] = { :list_id => args[:list_id], :name => args[:name], :user_key => args[:user].user_key } [:encoding] = args[:encoding] unless args[:encoding].nil? [:description] = args[:description] unless args[:description].nil? res = args[:user].session.request("CakeMail::API::ClassTrigger", "Create", ) Trigger.new(res['id'].first, args[:user]) end |
.get_list(args) ⇒ Object
Retrieves the list of triggers.
-
args = { :user => required, :status => optional, :action => optional, :list_id => optional, :parent_id => optional, :limit => optional, :offset => optional, :count => optional }
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/cakemail/trigger.rb', line 80 def get_list(args) raise ArgumentError if args.nil? or args[:user].nil? = { :user_key => args[:user].user_key } [:status] = args[:status] unless args[:status].nil? [:action] = args[:action] unless args[:action].nil? [:list_id] = args[:list_id] unless args[:list_id].nil? [:parent_id] = args[:parent_id] unless args[:parent_id].nil? [:limit] = args[:limit] unless args[:limit].nil? [:offset] = args[:offset] unless args[:offset].nil? [:count] = args[:count] unless args[:count].nil? res = args[:user].session.request("CakeMail::API::ClassTrigger", "GetList", ) if !args[:count].nil? return res['count'].first end return res['trigger'] end |
Instance Method Details
#get_info(id = @id) ⇒ Object
Returns information about a trigger.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cakemail/trigger.rb', line 24 def get_info(id = @id) res = @user.session.request("CakeMail::API::ClassTrigger", "GetInfo", { :trigger_id => id, :user_key => @user.user_key }) @id = res['id'].first @status = res['status'].first @encoding = res['encoding'].first @action = res['action'].first @name = res['name'].first @description = res['description'].first @delay = res['delay'].first @parent_id = res['list_id'].first @send_to = res['send_to'].first @subject = res['subject'].first @sender_name = res['sender_name'].first @sender_email = res['sender_email'].first @html_message = res['html_message'].first @text_message = res['text_message'].first end |
#save ⇒ Object
42 43 44 |
# File 'lib/cakemail/trigger.rb', line 42 def save self.setinfo end |
#set_info ⇒ Object
Returns information about a trigger.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cakemail/trigger.rb', line 46 def set_info args = { :trigger_id => id, :user_key => @user.user_key } args[:status] = status unless status.nil? args[:encoding] = encoding unless encoding.nil? args[:action] = action unless action.nil? args[:name] = name unless name.nil? args[:description] = description unless description.nil? args[:delay] = delay unless delay.nil? args[:parent_id] = parent_id unless parent_id.nil? args[:send_to] = send_to unless send_to.nil? args[:subject] = subject unless subject.nil? args[:sender_name] = sender_name unless sender_name.nil? args[:html_message] = unless .nil? args[:text_message] = unless .nil? res = @user.session.request("CakeMail::API::ClassTrigger", "SetInfo", args) end |