Class: MailchimpAPI::Segment

Inherits:
Base
  • Object
show all
Extended by:
MailchimpAPI::Support::Countable
Includes:
MailchimpAPI::Support::PatchUpdate
Defined in:
lib/mailchimp_api/resources/segment.rb

Instance Method Summary collapse

Methods included from MailchimpAPI::Support::Countable

count

Methods inherited from Base

activate_session, exists?, headers, reset_session, #to_h

Instance Method Details

#members(params = {}) ⇒ Object

The path to get segment members is ‘/3.0/lists/:list_id/segments/:segment_id/members’ Unfortunately, ActiveResource does not support nested resources, only single parent resources:

github.com/rails/activeresource/blob/4accda8bc03ceae0ad626f8cec0b4751e89a58ad/lib/active_resource/associations.rb#L151

Using a has_many, there is no way to include the ‘list_id`, so we just create our own members method.



19
20
21
# File 'lib/mailchimp_api/resources/segment.rb', line 19

def members(params = {})
  @members ||= MailchimpAPI::SegmentMember.find(:all, params: { segment_id: id }.deep_merge(prefix_options).deep_merge(params))
end