Class: MailchimpMarketing::TemplatesApi
- Inherits:
-
Object
- Object
- MailchimpMarketing::TemplatesApi
- Defined in:
- lib/MailchimpMarketing/api/templates_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#create(body, opts = {}) ⇒ Object
Add template.
-
#delete_template(template_id, opts = {}) ⇒ Object
Delete template.
-
#get_default_content_for_template(template_id, opts = {}) ⇒ Object
View default content.
-
#get_template(template_id, opts = {}) ⇒ Object
Get template info.
-
#initialize(api_client) ⇒ TemplatesApi
constructor
A new instance of TemplatesApi.
-
#list(opts = {}) ⇒ Object
List templates.
-
#update_template(template_id, body, opts = {}) ⇒ Object
Update template.
Constructor Details
#initialize(api_client) ⇒ TemplatesApi
Returns a new instance of TemplatesApi.
19 20 21 |
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 19 def initialize(api_client) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#create(body, opts = {}) ⇒ Object
Add template
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 113 def create(body, opts = {}) fail ArgumentError, "Missing required param: 'body'" if body.nil? query_params = {} post_body = @api_client.object_to_http_body(body) local_var_path = '/templates' data = @api_client.call_api(:POST, local_var_path, :query_params => query_params, :body => post_body) return data end |
#delete_template(template_id, opts = {}) ⇒ Object
Delete template
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 24 def delete_template(template_id, opts = {}) fail ArgumentError, "Missing required param: 'template_id'" if template_id.nil? query_params = {} post_body = nil local_var_path = '/templates/{template_id}'.sub('{' + 'template_id' + '}', template_id.to_s) data = @api_client.call_api(:DELETE, local_var_path, :query_params => query_params, :body => post_body) return data end |
#get_default_content_for_template(template_id, opts = {}) ⇒ Object
View default content
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 82 def get_default_content_for_template(template_id, opts = {}) fail ArgumentError, "Missing required param: 'template_id'" if template_id.nil? query_params = {} query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil? query_params[:'exclude_fields'] = @api_client.build_collection_param(opts[:'exclude_fields'], :csv) if !opts[:'exclude_fields'].nil? post_body = nil local_var_path = '/templates/{template_id}/default-content'.sub('{' + 'template_id' + '}', template_id.to_s) data = @api_client.call_api(:GET, local_var_path, :query_params => query_params, :body => post_body) return data end |
#get_template(template_id, opts = {}) ⇒ Object
Get template info
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 66 def get_template(template_id, opts = {}) fail ArgumentError, "Missing required param: 'template_id'" if template_id.nil? query_params = {} query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil? query_params[:'exclude_fields'] = @api_client.build_collection_param(opts[:'exclude_fields'], :csv) if !opts[:'exclude_fields'].nil? post_body = nil local_var_path = '/templates/{template_id}'.sub('{' + 'template_id' + '}', template_id.to_s) data = @api_client.call_api(:GET, local_var_path, :query_params => query_params, :body => post_body) return data end |
#list(opts = {}) ⇒ Object
List templates
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 38 def list(opts = {}) fail ArgumentError, 'invalid value for "opts[:"count"]", must be smaller than or equal to 1000.' if !opts[:'count'].nil? && opts[:'count'] > 1000 fail ArgumentError, 'invalid value for "sort_field", must be one of date_created, date_edited, name' if opts[:'sort_field'] && !['date_created', 'date_edited', 'name'].include?(opts[:'sort_field']) fail ArgumentError, 'invalid value for "sort_dir", must be one of ASC, DESC' if opts[:'sort_dir'] && !['ASC', 'DESC'].include?(opts[:'sort_dir']) query_params = {} query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil? query_params[:'exclude_fields'] = @api_client.build_collection_param(opts[:'exclude_fields'], :csv) if !opts[:'exclude_fields'].nil? query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil? query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil? query_params[:'created_by'] = opts[:'created_by'] if !opts[:'created_by'].nil? query_params[:'since_date_created'] = opts[:'since_date_created'] if !opts[:'since_date_created'].nil? query_params[:'before_date_created'] = opts[:'before_date_created'] if !opts[:'before_date_created'].nil? query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil? query_params[:'category'] = opts[:'category'] if !opts[:'category'].nil? query_params[:'folder_id'] = opts[:'folder_id'] if !opts[:'folder_id'].nil? query_params[:'sort_field'] = opts[:'sort_field'] if !opts[:'sort_field'].nil? query_params[:'sort_dir'] = opts[:'sort_dir'] if !opts[:'sort_dir'].nil? post_body = nil local_var_path = '/templates' data = @api_client.call_api(:GET, local_var_path, :query_params => query_params, :body => post_body) return data end |
#update_template(template_id, body, opts = {}) ⇒ Object
Update template
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 98 def update_template(template_id, body, opts = {}) fail ArgumentError, "Missing required param: 'template_id'" if template_id.nil? fail ArgumentError, "Missing required param: 'body'" if body.nil? query_params = {} post_body = @api_client.object_to_http_body(body) local_var_path = '/templates/{template_id}'.sub('{' + 'template_id' + '}', template_id.to_s) data = @api_client.call_api(:PATCH, local_var_path, :query_params => query_params, :body => post_body) return data end |