Class: Campaigning::Template
- Inherits:
-
Object
- Object
- Campaigning::Template
- Includes:
- ModuleMixin
- Defined in:
- lib/campaigning/soap/generated/default.rb,
lib/campaigning/template.rb
Overview
/Template
templateID - SOAP::SOAPString
name - SOAP::SOAPString
previewURL - SOAP::SOAPString
screenshotURL - SOAP::SOAPString
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#previewURL ⇒ Object
Returns the value of attribute previewURL.
-
#screenshotURL ⇒ Object
Returns the value of attribute screenshotURL.
-
#templateID ⇒ Object
Returns the value of attribute templateID.
Class Method Summary collapse
-
.create!(params) ⇒ Object
Creates a new template for a client.
-
.delete!(template_id, opts = {}) ⇒ Object
Deletes a template.
Instance Method Summary collapse
-
#delete! ⇒ Object
Deletes a template.
-
#details ⇒ Object
Gets the details of a template.
-
#initialize(templateID = nil, name = nil, previewURL = nil, screenshotURL = nil) ⇒ Template
constructor
A new instance of Template.
-
#update!(params) ⇒ Object
Updates an existing template.
Methods included from ModuleMixin
Constructor Details
#initialize(templateID = nil, name = nil, previewURL = nil, screenshotURL = nil) ⇒ Template
Returns a new instance of Template.
14 15 16 17 18 19 20 |
# File 'lib/campaigning/template.rb', line 14 def initialize(templateID = nil, name = nil, previewURL = nil, screenshotURL = nil, opts = {}) @apiKey = opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY @templateID = templateID @name = name @previewURL = previewURL @screenshotURL = screenshotURL end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/campaigning/template.rb', line 10 def name @name end |
#previewURL ⇒ Object
Returns the value of attribute previewURL.
11 12 13 |
# File 'lib/campaigning/template.rb', line 11 def previewURL @previewURL end |
#screenshotURL ⇒ Object
Returns the value of attribute screenshotURL.
12 13 14 |
# File 'lib/campaigning/template.rb', line 12 def screenshotURL @screenshotURL end |
#templateID ⇒ Object
Returns the value of attribute templateID.
9 10 11 |
# File 'lib/campaigning/template.rb', line 9 def templateID @templateID end |
Class Method Details
.create!(params) ⇒ Object
Creates a new template for a client.
Available params argument are:
* :clientID - The ID of the client who will owner of the list.
* :templateName - The name of the template. Maximum of 30 characters (will be truncated to 30 characters if longer).
* :htmlPageURL - The URL of the HTML page you have created for the template.
* :zipFileURL - Optional URL of a zip file containing any other files required by the template.
* :screenshotURL - Optional URL of a screenshot of the template. Must be in jpeg format and at least 218 pixels wide.
* :apiKey - optional API key to use to make request. Will use CAMPAIGN_MONITOR_API_KEY if not set.
Return:
Success: Upon a successful call, this method will return a Campaigning::Template object representing the newly created template. The object returned isn’t filled with previewURL and screenShotURL once the CampaignMonitor API generate a new value for that and doesn’t return it on te create! method. In order to get a complete filled object call the Template.details method.
Error: An Exception containing the cause of the error will be raised.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/campaigning/template.rb', line 39 def self.create!(params) response = @@soap.createTemplate( :apiKey => params[:apiKey] || CAMPAIGN_MONITOR_API_KEY, :clientID => params[:clientID], :templateName => params[:templateName], :hTMLPageURL => params[:htmlPageURL], :zipFileURL => params[:zipFileURL], :screenshotURL => params[:screenshotURL] ) Template.new( handle_response(response.template_CreateResult), params[:templateName], nil, nil, :apiKey=> params[:apiKey] ) end |
.delete!(template_id, opts = {}) ⇒ Object
Deletes a template.
Aviable opts arguments are:
* :apiKey - optional API key to use to make request. Will use CAMPAIGN_MONITOR_API_KEY if not set.
Return:
Success: Upon a successful call, this method will return a Campaigning::Result object wich consists of a code
and message
fields containing a successful message.
Error: An Exception containing the cause of the error will be raised.
118 119 120 121 |
# File 'lib/campaigning/template.rb', line 118 def self.delete!(template_id, opts={}) response = @@soap.deleteTemplate(:apiKey => opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY, :templateID => template_id) handle_response response.template_DeleteResult end |
Instance Method Details
#delete! ⇒ Object
Deletes a template.
Return:
Success: Upon a successful call, this method will return a Campaigning::Result object wich consists of a code
and message
fields containing a successful message.
Error: An Exception containing the cause of the error will be raised.
100 101 102 103 104 |
# File 'lib/campaigning/template.rb', line 100 def delete! response = Template.delete!(@templateID, :apiKey=> @apiKey) self.templateID, self.name = nil, nil response end |
#details ⇒ Object
Gets the details of a template.
Return:
Success: Upon a successful call, this method will return a Template object, which consists of the template ID, the template name, a preview URL and a screenshot URL.
Error: An Exception containing the cause of the error will be raised.
59 60 61 62 |
# File 'lib/campaigning/template.rb', line 59 def details response = @@soap.getTemplateDetail(:apiKey => @apiKey, :templateID => @templateID) handle_response response.template_GetDetailResult end |
#update!(params) ⇒ Object
Updates an existing template.
Available params argument are:
* :templateID - The ID of the template to be updated.
* :templateName - The name of the template. Maximum of 30 characters (will be truncated to 30 characters if longer).
* :htmlPageURL - The URL of the HTML page you have created for the template.
* :zipFileURL - Optional URL of a zip file containing any other files required by the template.
* :screenshotURL - Optional URL of a screenshot of the template. Must be in jpeg format and at least 218 pixels wide.
* :apiKey - optional API key to use to make request. Will use CAMPAIGN_MONITOR_API_KEY if not set.
Return:
Success: Upon a successful call, this method will return a Campaigning::Result object wich consists of a code
and message
fields containing a successful message.
Error: An Exception containing the cause of the error will be raised.
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/campaigning/template.rb', line 79 def update!(params) response = @@soap.updateTemplate( :apiKey => params[:apiKey] || CAMPAIGN_MONITOR_API_KEY, :templateID => @templateID, :templateName => params[:templateName], :hTMLPageURL => params[:htmlPageURL], :zipFileURL => params[:zipFileURL], :screenshotURL => params[:screenshotURL] ) handle_response response.template_UpdateResult end |