Class: MailchimpMarketing::TemplatesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/MailchimpMarketing/api/templates_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_clientObject

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 = {}) ⇒ TemplateInstance

Create a new template Create a new template for the account. Only [Classic templates](mailchimp.com/help/types-of-templates/) are supported.

Parameters:

  • body (defaults to: {})
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (TemplateInstance)

291
292
293
294
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 291

def create(body = {}, opts = {})
  data, _status_code, _headers = create_with_http_info(body, opts)
  data
end

#create_with_http_info(body, opts = {}) ⇒ Array<(TemplateInstance, Fixnum, Hash)>

Create a new template Create a new template for the account. Only [Classic templates](mailchimp.com/help/types-of-templates/) are supported.

Parameters:

  • body
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(TemplateInstance, Fixnum, Hash)>)

    TemplateInstance data, response status code and response headers


301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 301

def create_with_http_info(body, opts = {})
  # resource path
  local_var_path = '/templates'

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/problem+json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(body)
  auth_names = ['basicAuth']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'TemplateInstance')
  return data, status_code, headers
end

#delete_template(template_id = {}, opts = {}) ⇒ nil

Delete a specific template Delete a specific template.

Parameters:

  • template_id (defaults to: {})

    The unique id for the template.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)

27
28
29
30
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 27

def delete_template(template_id = {}, opts = {})
  delete_template_with_http_info(template_id, opts)
  nil
end

#delete_template_with_http_info(template_id, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Delete a specific template Delete a specific template.

Parameters:

  • template_id

    The unique id for the template.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Fixnum, Hash)>)

    nil, response status code and response headers


37
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
64
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 37

def delete_template_with_http_info(template_id, opts = {})
  # resource path
  local_var_path = '/templates/{template_id}'.sub('{' + 'template_id' + '}', template_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/problem+json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['basicAuth']
  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  return data, status_code, headers
end

#get_default_content_for_template(template_id = {}, opts = {}) ⇒ TemplateDefaultContent

Get the default content for a template Get the sections that you can edit in a template, including each section's default content.

Parameters:

  • template_id (defaults to: {})

    The unique id for the template.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :fields (Array<String>)

    A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation.

  • :exclude_fields (Array<String>)

    A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation.

Returns:

  • (TemplateDefaultContent)

197
198
199
200
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 197

def get_default_content_for_template(template_id = {}, opts = {})
  data, _status_code, _headers = get_default_content_for_template_with_http_info(template_id, opts)
  data
end

#get_default_content_for_template_with_http_info(template_id, opts = {}) ⇒ Array<(TemplateDefaultContent, Fixnum, Hash)>

Get the default content for a template Get the sections that you can edit in a template, including each section&#39;s default content.

Parameters:

  • template_id

    The unique id for the template.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :fields (Array<String>)

    A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation.

  • :exclude_fields (Array<String>)

    A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation.

Returns:

  • (Array<(TemplateDefaultContent, Fixnum, Hash)>)

    TemplateDefaultContent data, response status code and response headers


209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 209

def get_default_content_for_template_with_http_info(template_id, opts = {})
  # resource path
  local_var_path = '/templates/{template_id}/default-content'.sub('{' + 'template_id' + '}', template_id.to_s)

  # query parameters
  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?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/problem+json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['basicAuth']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'TemplateDefaultContent')
  return data, status_code, headers
end

#get_template(template_id = {}, opts = {}) ⇒ TemplateInstance

Get information about a specific template Get information about a specific template.

Parameters:

  • template_id (defaults to: {})

    The unique id for the template.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :fields (Array<String>)

    A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation.

  • :exclude_fields (Array<String>)

    A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation.

Returns:

  • (TemplateInstance)

147
148
149
150
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 147

def get_template(template_id = {}, opts = {})
  data, _status_code, _headers = get_template_with_http_info(template_id, opts)
  data
end

#get_template_with_http_info(template_id, opts = {}) ⇒ Array<(TemplateInstance, Fixnum, Hash)>

Get information about a specific template Get information about a specific template.

Parameters:

  • template_id

    The unique id for the template.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :fields (Array<String>)

    A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation.

  • :exclude_fields (Array<String>)

    A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation.

Returns:

  • (Array<(TemplateInstance, Fixnum, Hash)>)

    TemplateInstance data, response status code and response headers


159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 159

def get_template_with_http_info(template_id, opts = {})
  # resource path
  local_var_path = '/templates/{template_id}'.sub('{' + 'template_id' + '}', template_id.to_s)

  # query parameters
  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?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/problem+json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['basicAuth']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'TemplateInstance')
  return data, status_code, headers
end

#list(opts = {}) ⇒ Templates

Get all templates Get a list of an account's available templates.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :fields (Array<String>)

    A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation.

  • :exclude_fields (Array<String>)

    A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation.

  • :count (Integer)

    The number of records to return. [Default value](/developer/guides/get-started-with-mailchimp-api-3/#Parameters) is *10*. [Maximum value](/developer/guides/get-started-with-mailchimp-api-3/#Parameters) is *1000* (default to 10)

  • :offset (Integer)

    The number of records from a collection to skip. Iterating over large collections with this parameter can be slow. [Default value](/developer/guides/get-started-with-mailchimp-api-3/#Parameters) is *0*. (default to 0)

  • :created_by (String)

    The Mailchimp account user who created the template.

  • :since_created_at (String)

    Restrict the response to templates created after the set date. We recommend [ISO 8601](en.wikipedia.org/wiki/ISO_8601) time format: 2015-10-21T15:41:36+00:00.

  • :before_created_at (String)

    Restrict the response to templates created before the set date. We recommend [ISO 8601](en.wikipedia.org/wiki/ISO_8601) time format: 2015-10-21T15:41:36+00:00.

  • :type (String)

    Limit results based on template type.

  • :category (String)

    Limit results based on category.

  • :folder_id (String)

    The unique folder id.

  • :sort_field (String)

    Returns user templates sorted by the specified field.

Returns:

  • (Templates)

80
81
82
83
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 80

def list(opts = {})
  data, _status_code, _headers = list_with_http_info(opts)
  data
end

#list_with_http_info(opts = {}) ⇒ Array<(Templates, Fixnum, Hash)>

Get all templates Get a list of an account&#39;s available templates.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :fields (Array<String>)

    A comma-separated list of fields to return. Reference parameters of sub-objects with dot notation.

  • :exclude_fields (Array<String>)

    A comma-separated list of fields to exclude. Reference parameters of sub-objects with dot notation.

  • :count (Integer)

    The number of records to return. [Default value](/developer/guides/get-started-with-mailchimp-api-3/#Parameters) is *10*. [Maximum value](/developer/guides/get-started-with-mailchimp-api-3/#Parameters) is *1000*

  • :offset (Integer)

    The number of records from a collection to skip. Iterating over large collections with this parameter can be slow. [Default value](/developer/guides/get-started-with-mailchimp-api-3/#Parameters) is *0*.

  • :created_by (String)

    The Mailchimp account user who created the template.

  • :since_created_at (String)

    Restrict the response to templates created after the set date. We recommend [ISO 8601](en.wikipedia.org/wiki/ISO_8601) time format: 2015-10-21T15:41:36+00:00.

  • :before_created_at (String)

    Restrict the response to templates created before the set date. We recommend [ISO 8601](en.wikipedia.org/wiki/ISO_8601) time format: 2015-10-21T15:41:36+00:00.

  • :type (String)

    Limit results based on template type.

  • :category (String)

    Limit results based on category.

  • :folder_id (String)

    The unique folder id.

  • :sort_field (String)

    Returns user templates sorted by the specified field.

Returns:

  • (Array<(Templates, Fixnum, Hash)>)

    Templates data, response status code and response headers


100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 100

def list_with_http_info(opts = {})
  # resource path
  local_var_path = '/templates'

  # query parameters
  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_created_at'] = opts[:'since_created_at'] if !opts[:'since_created_at'].nil?
  query_params[:'before_created_at'] = opts[:'before_created_at'] if !opts[:'before_created_at'].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?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/problem+json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['basicAuth']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'Templates')
  return data, status_code, headers
end

#update_template(template_id = {}, body = {}, opts = {}) ⇒ TemplateInstance

Update an existing template Update the name, HTML, or `folder_id` of an existing template.

Parameters:

  • template_id (defaults to: {})

    The unique id for the template.

  • body (defaults to: {})
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (TemplateInstance)

246
247
248
249
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 246

def update_template(template_id = {}, body = {}, opts = {})
  data, _status_code, _headers = update_template_with_http_info(template_id, body, opts)
  data
end

#update_template_with_http_info(template_id, body, opts = {}) ⇒ Array<(TemplateInstance, Fixnum, Hash)>

Update an existing template Update the name, HTML, or &#x60;folder_id&#x60; of an existing template.

Parameters:

  • template_id

    The unique id for the template.

  • body
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(TemplateInstance, Fixnum, Hash)>)

    TemplateInstance data, response status code and response headers


257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/MailchimpMarketing/api/templates_api.rb', line 257

def update_template_with_http_info(template_id, body, opts = {})
  # resource path
  local_var_path = '/templates/{template_id}'.sub('{' + 'template_id' + '}', template_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/problem+json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(body)
  auth_names = ['basicAuth']
  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'TemplateInstance')
  return data, status_code, headers
end