Sha256: d6f8580342aaa16ceae8d1833408f8585a9c05882a3538cde5dc1a779f5b4874

Contents?: true

Size: 659 Bytes

Versions: 1

Compression:

Stored size: 659 Bytes

Contents

module CatarseMailchimp
  module API
    extend self

    def subscribe(user, list_id = MAILCHIMP_LIST_ID)
      subscribe_params = {
        id: list_id.to_s,
        batch: [ { :EMAIL => user.email } ]
      }

      mailchimp_api.list_batch_subscribe(subscribe_params)
    end

    def unsubscribe(user, list_id = MAILCHIMP_LIST_ID)
      unsubscribe_params = {
        id: list_id.to_s,
        emails: [ user.email ],
        delete_member: true,
        send_goodbye: true
      }

      mailchimp_api.list_batch_unsubscribe(unsubscribe_params)
    end

    protected

    def mailchimp_api
      Mailchimp::API.new(MAILCHIMP_API_KEY)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
catarse_mailchimp-0.0.1 lib/catarse_mailchimp/api.rb