Class: CakeMail::Template
- Inherits:
-
Object
- Object
- CakeMail::Template
- Defined in:
- lib/cakemail/template.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#message ⇒ Object
Returns the value of attribute message.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
-
.create(args) ⇒ Object
Creates a new template.
-
.get_list(args) ⇒ Object
Retrieves the list of template.
Instance Method Summary collapse
-
#delete ⇒ Object
Deletes a template.
-
#get_info(id = @id) ⇒ Object
Returns information about a template.
-
#initialize(id, user) ⇒ Template
constructor
A new instance of Template.
- #save ⇒ Object
-
#set_info ⇒ Object
Modifies a template.
Constructor Details
#initialize(id, user) ⇒ Template
Returns a new instance of Template.
17 18 19 20 21 |
# File 'lib/cakemail/template.rb', line 17 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.
14 15 16 |
# File 'lib/cakemail/template.rb', line 14 def client_id @client_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/cakemail/template.rb', line 14 def id @id end |
#message ⇒ Object
Returns the value of attribute message.
15 16 17 |
# File 'lib/cakemail/template.rb', line 15 def @message end |
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/cakemail/template.rb', line 15 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
15 16 17 |
# File 'lib/cakemail/template.rb', line 15 def type @type end |
Class Method Details
.create(args) ⇒ Object
Creates a new template.
Arguments :
-
options = { :user => required, :name => required, :type => optional, :message => optional }
54 55 56 57 58 59 60 61 |
# File 'lib/cakemail/template.rb', line 54 def create(args) raise ArgumentError if args.nil? or args[:user].nil? = { :name => name, :user_key => args[:user].user_key } [:type] = args[:type] unless args[:type].nil? [:message] = args[:message] unless args[:message].nil? res = args[:user].session.request("CakeMail::API::ClassTemplate", "Create", ) Template.new(res['id'].first, args[:user]) end |
.get_list(args) ⇒ Object
Retrieves the list of template.
Arguments :
-
args = { :user => required, :count => optional, :type => optional, :limit => optional, :offset => optional }
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/cakemail/template.rb', line 66 def get_list(args) raise ArgumentError if args.nil? or args[:user].nil? = { :user_key => args[:user].user_key } [:type] = args[:type] unless args[:status].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::ClassTemplate", "GetList", ) if !args[:count].nil? return res['count'] end return res['template'] end |
Instance Method Details
#delete ⇒ Object
Deletes a template.
23 24 25 26 |
# File 'lib/cakemail/template.rb', line 23 def delete @user.session.request("CakeMail::API::ClassTemplate", "Delete", { :template_id => @id, :user_key => @user.user_key }) self.freeze end |
#get_info(id = @id) ⇒ Object
Returns information about a template.
28 29 30 31 32 33 34 35 |
# File 'lib/cakemail/template.rb', line 28 def get_info(id = @id) res = @user.session.request("CakeMail::API::ClassTemplate", "GetInfo", { :template_id => id, :user_key => @user.user_key }) @id = res['id'].first @client_id = res['client_id'].first @name = res['name'].first @type = res['type'].first @message = res['message'].first end |
#save ⇒ Object
37 38 39 |
# File 'lib/cakemail/template.rb', line 37 def save self.setinfo end |
#set_info ⇒ Object
Modifies a template.
41 42 43 44 45 46 47 |
# File 'lib/cakemail/template.rb', line 41 def set_info args = { :template_id => @id, :user_key => @user.user_key } args[:name] = @name unless @name.nil? args[:message] = @message unless @message.nil? args[:type] = @type unless @type res = @user.session.request("CakeMail::API::ClassTemplate", "SetInfo", args) end |