Module: MailchimpAPI::Audience::InterestCategories::APIs

Includes:
Pagination::ListEachItemHelper
Included in:
MailchimpAPI::Audience::InterestCategories, MailchimpAPI::Audience::InterestCategories
Defined in:
lib/mailchimp-api/resources/audience/interest_categories.rb

Overview

Module with endpoints for InterestCategories

Instance Method Summary collapse

Instance Method Details

#create(list_id, query: nil, body: nil, headers: nil) ⇒ Response

Create a new interest category

Examples:

Create a checkbox interest category

interest_categories.create('list123', body: {
  title: 'Favorite Products',
  type: 'checkboxes'
})

Parameters:

  • list_id (String)

    The ID of the Mailchimp list

  • query (Hash) (defaults to: nil)

    Optional query parameters

  • body (Hash) (defaults to: nil)

    Interest category attributes

  • headers (Hash) (defaults to: nil)

    Optional request headers

Options Hash (body:):

  • :title (String)

    The title of the interest category

  • :type (String)

    The type of interest category (checkboxes, dropdown, radio, hidden)

Returns:

  • (Response)

    API response containing the created interest category



38
39
40
41
# File 'lib/mailchimp-api/resources/audience/interest_categories.rb', line 38

def create(list_id, query: nil, body: nil, headers: nil)
  path = "/lists/#{list_id}/interest-categories"
  client.post(path, query: query, body: body, headers: headers)
end

#delete(list_id, interest_category_id, query: nil, body: nil, headers: nil) ⇒ Response

Delete an interest category

Examples:

Delete an interest category

interest_categories.delete('list123', 'category456')

Parameters:

  • list_id (String)

    The ID of the Mailchimp list

  • interest_category_id (String)

    The ID of the interest category to delete

  • query (Hash) (defaults to: nil)

    Optional query parameters

  • body (Hash) (defaults to: nil)

    Optional request body

  • headers (Hash) (defaults to: nil)

    Optional request headers

Returns:



66
67
68
69
# File 'lib/mailchimp-api/resources/audience/interest_categories.rb', line 66

def delete(list_id, interest_category_id, query: nil, body: nil, headers: nil)
  path = "/lists/#{list_id}/interest-categories/#{interest_category_id}"
  client.delete(path, query: query, body: body, headers: headers)
end

#each(list_id, query: nil, body: nil, headers: nil) {|Hash| ... } ⇒ Object

Iterate through all interest categories for a list

Examples:

Iterate through interest categories

interest_categories.each('list123') do |category|
  puts category[:title]
end

Parameters:

  • list_id (String)

    The ID of the Mailchimp list

  • query (Hash) (defaults to: nil)

    Optional query parameters

  • body (Hash) (defaults to: nil)

    Optional request body

  • headers (Hash) (defaults to: nil)

    Optional request headers

Yields:

  • (Hash)

    Each interest category



97
98
99
# File 'lib/mailchimp-api/resources/audience/interest_categories.rb', line 97

def each(list_id, query: nil, body: nil, headers: nil, &block)
  list_each_item(:categories, list_id, query: query, body: body, headers: headers, &block)
end

#list(list_id, query: nil, body: nil, headers: nil) ⇒ Response

List interest categories for a specific list

Examples:

Get interest categories for a list

interest_categories.list('list123')

Parameters:

  • list_id (String)

    The ID of the Mailchimp list

  • query (Hash) (defaults to: nil)

    Optional query parameters

  • body (Hash) (defaults to: nil)

    Optional request body

  • headers (Hash) (defaults to: nil)

    Optional request headers

Returns:

  • (Response)

    API response containing interest categories



20
21
22
23
# File 'lib/mailchimp-api/resources/audience/interest_categories.rb', line 20

def list(list_id, query: nil, body: nil, headers: nil)
  path = "/lists/#{list_id}/interest-categories"
  client.get(path, query: query, body: body, headers: headers)
end

#show(list_id, interest_category_id, query: nil, body: nil, headers: nil) ⇒ Response

Show details for a specific interest category

Examples:

Get details for an interest category

interest_categories.show('list123', 'category456')

Parameters:

  • list_id (String)

    The ID of the Mailchimp list

  • interest_category_id (String)

    The ID of the interest category

  • query (Hash) (defaults to: nil)

    Optional query parameters

  • body (Hash) (defaults to: nil)

    Optional request body

  • headers (Hash) (defaults to: nil)

    Optional request headers

Returns:

  • (Response)

    API response containing interest category details



52
53
54
55
# File 'lib/mailchimp-api/resources/audience/interest_categories.rb', line 52

def show(list_id, interest_category_id, query: nil, body: nil, headers: nil)
  path = "/lists/#{list_id}/interest-categories/#{interest_category_id}"
  client.get(path, query: query, body: body, headers: headers)
end

#update(list_id, interest_category_id, query: nil, body: nil, headers: nil) ⇒ Response

Update an interest category

Examples:

Update an interest category title

interest_categories.update('list123', 'category456', body: {
  title: 'Updated Category Name'
})

Parameters:

  • list_id (String)

    The ID of the Mailchimp list

  • interest_category_id (String)

    The ID of the interest category to update

  • query (Hash) (defaults to: nil)

    Optional query parameters

  • body (Hash) (defaults to: nil)

    Updated interest category attributes

  • headers (Hash) (defaults to: nil)

    Optional request headers

Returns:

  • (Response)

    API response containing updated interest category



82
83
84
85
# File 'lib/mailchimp-api/resources/audience/interest_categories.rb', line 82

def update(list_id, interest_category_id, query: nil, body: nil, headers: nil)
  path = "/lists/#{list_id}/interest-categories/#{interest_category_id}"
  client.patch(path, query: query, body: body, headers: headers)
end