Sha256: 5b83fd8650701c52129b66dd895f360ad12c4e89c952eec9f6539c5ee98ac074

Contents?: true

Size: 734 Bytes

Versions: 2

Compression:

Stored size: 734 Bytes

Contents

module CatarseMonkeymail::ProjectConcern
  extend ActiveSupport::Concern

  included do
    def mailchimp
      @mailchimp ||= ::CatarseMonkeymail::MailchimpApi.start
    end

    def subscribe_owner_to_success_list
      subscribe_to_list ::CatarseSettings[:mailchimp_successful_projects_list]
    end

    def subscribe_owner_to_failed_list
      subscribe_to_list ::CatarseSettings[:mailchimp_failed_projects_list]
    end

    private

    def subscribe_to_list list_id
      mailchimp.list.subscribe list_id, { email: self.user.email }, subscriber_args
    end

    def subscriber_args
      {
        fname: self.user.name,
        city: self.user.address_city,
        state: self.user.address_state
      }
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
catarse_monkeymail-0.0.2 app/models/catarse_monkeymail/project_concern.rb
catarse_monkeymail-0.0.1 app/models/catarse_monkeymail/project_concern.rb