Module: MailchimpAPI::Audience::Interests::APIs

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

Overview

Module with endpoints for Interests APIs

Instance Method Summary collapse

Instance Method Details

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

Create a new interest

Examples:

Create a new interest

interests.create('list123', 'category456', body: {
  name: 'Product Updates'
})

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)

    Interest attributes

  • headers (Hash) (defaults to: nil)

    Optional request headers

Options Hash (body:):

  • :name (String)

    The name of the interest

Returns:

  • (Response)

    API response containing the created interest



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

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

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

Delete an interest

Examples:

Delete an interest

interests.delete('list123', 'category456', 'interest789')

Parameters:

  • list_id (String)

    The ID of the Mailchimp list

  • interest_category_id (String)

    The ID of the interest category

  • interest_id (String)

    The ID of the interest 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:



68
69
70
71
# File 'lib/mailchimp-api/resources/audience/interests.rb', line 68

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

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

Iterate through all interests in an interest category

Examples:

Iterate through interest in category

interests.each('list123') do |interest|
  puts interest[:name]
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



100
101
102
# File 'lib/mailchimp-api/resources/audience/interests.rb', line 100

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

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

List interests in a specific interest category

Examples:

Get interests in a category

interests.list('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 interests



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

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

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

Show details for a specific interest

Examples:

Get details for an interest

interests.show('list123', 'category456', 'interest789')

Parameters:

  • list_id (String)

    The ID of the Mailchimp list

  • interest_category_id (String)

    The ID of the interest category

  • interest_id (String)

    The ID of the interest

  • 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 details



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

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

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

Update an interest

Examples:

Update an interest name

interests.update('list123', 'category456', 'interest789', body: {
  name: 'Updated Interest Name'
})

Parameters:

  • list_id (String)

    The ID of the Mailchimp list

  • interest_category_id (String)

    The ID of the interest category

  • interest_id (String)

    The ID of the interest to update

  • query (Hash) (defaults to: nil)

    Optional query parameters

  • body (Hash) (defaults to: nil)

    Updated interest attributes

  • headers (Hash) (defaults to: nil)

    Optional request headers

Returns:

  • (Response)

    API response containing updated interest



85
86
87
88
# File 'lib/mailchimp-api/resources/audience/interests.rb', line 85

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