Sha256: a2c6d3772b501ef4f9343e7e28afdcabc52d881226500e2a7af72ccb56af2814

Contents?: true

Size: 789 Bytes

Versions: 11

Compression:

Stored size: 789 Bytes

Contents

require 'emaildirect'
require 'json'

module EmailDirect
  # Represents a filter and associated functionality
  class Filter
    class << self
      def all
        response = EmailDirect.get '/Filters'
        Hashie::Mash.new(response)
      end
    end

    attr_reader :filter_id

    def initialize(filter_id)
      @filter_id = filter_id
    end

    def details
      response = get
      Hashie::Mash.new(response)
    end

    def members(options = {})
      response = get 'Members', options
      Hashie::Mash.new(response)
    end

    private

    def get(action = nil, options = {})
      EmailDirect.get uri_for(action), :query => options
    end

    def uri_for(action = nil)
      action = "/#{action}" if action
      "/Filters/#{filter_id}#{action}"
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
emaildirect-2.0.0 lib/emaildirect/filter.rb
emaildirect-1.3.4 lib/emaildirect/filter.rb
emaildirect-1.3.3 lib/emaildirect/filter.rb
emaildirect-1.3.2 lib/emaildirect/filter.rb
emaildirect-1.3.1 lib/emaildirect/filter.rb
emaildirect-1.3.0 lib/emaildirect/filter.rb
emaildirect-1.2.1 lib/emaildirect/filter.rb
emaildirect-1.2.0 lib/emaildirect/filter.rb
emaildirect-1.1.0 lib/emaildirect/filter.rb
emaildirect-1.0.1 lib/emaildirect/filter.rb
emaildirect-1.0.0 lib/emaildirect/filter.rb