Sha256: 2f557036ee2cee6e109de65c78abf8d6044d26dd4e58b94654145af9d2f0a364

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

require 'emaildirect'
require 'json'

module EmailDirect
  # Represents an import and associated functionality
  class Import
    class << self
      def add(subscribers)
        options = { :Subscribers => Array(subscribers) }
        response = EmailDirect.post uri_for('Subscribers'), :body => options.to_json
        Hashie::Mash.new(response)
      end

      def update(subscribers)
        options = { :Subscribers => Array(subscribers) }
        response = EmailDirect.put uri_for('Subscribers'), :body => options.to_json
        Hashie::Mash.new(response)
      end

      def add_or_update(subscribers)
        options = { :Subscribers => Array(subscribers) }
        response = EmailDirect.post uri_for('AddOrUpdate'), :body => options.to_json
        Hashie::Mash.new(response)
      end

      def remove(email_addresses)
        options = { :EmailAddresses => Array(email_addresses) }
        response = EmailDirect.post uri_for('Remove'), :body => options.to_json
        Hashie::Mash.new(response)
      end

      def delete(email_addresses)
        options = { :EmailAddresses => Array(email_addresses) }
        response = EmailDirect.post uri_for('Delete'), :body => options.to_json
        Hashie::Mash.new(response)
      end

      def uri_for(action)
        "/Import/#{action}"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
emaildirect-2.0.0 lib/emaildirect/import.rb
emaildirect-1.3.4 lib/emaildirect/import.rb
emaildirect-1.3.3 lib/emaildirect/import.rb
emaildirect-1.3.2 lib/emaildirect/import.rb
emaildirect-1.3.1 lib/emaildirect/import.rb
emaildirect-1.3.0 lib/emaildirect/import.rb