Sha256: 7c477c38c9f21c118ae1227bdf18e0014176ef8a30f1a0f4032e7d95220ab2d5

Contents?: true

Size: 631 Bytes

Versions: 3

Compression:

Stored size: 631 Bytes

Contents

module Mailkick
  class Service

    def fetch_opt_outs
      opt_outs.each do |api_data|
        email = api_data[:email]
        time = api_data[:time]

        opt_out = Mailkick::OptOut.where(email: email).order("updated_at desc").first
        if !opt_out or (time > opt_out.updated_at and !opt_out.active)
          Mailkick::OptOut.create! do |o|
            o.email = email
            o.user = Mailkick.user_method if Mailkick.user_method.call(email)
            o.reason = api_data[:reason]
            o.created_at = time
            o.updated_at = time
          end
        end
      end
      true
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mailkick-0.0.3 lib/mailkick/service.rb
mailkick-0.0.2 lib/mailkick/service.rb
mailkick-0.0.1 lib/mailkick/service.rb