Sha256: 9c05e2641075c4648d83aafbab4c78f6def3ab0ca9987eb3c24092ff9f1d7312

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

module Postmark
  class Bounce

    attr_reader :email, :bounced_at, :type, :details, :name, :id, :server_id, :tag

    def initialize(values = {})
      @id = values["ID"]
      @email = values["Email"]
      @bounced_at = Time.parse(values["BouncedAt"])
      @type = values["Type"]
      @name = values["Name"]
      @details = values["Details"]
      @tag = values["Tag"]
      @dump_available = values["DumpAvailable"]
      @inactive = values["Inactive"]
      @can_activate = values["CanActivate"]
    end

    def inactive?
      !!@inactive
    end

    def can_activate?
      !!@can_activate
    end

    def dump
      Postmark::HttpClient.get("bounces/#{id}/dump")["Body"]
    end

    def activate
      Bounce.new(Postmark::HttpClient.put("bounces/#{id}/activate")["Bounce"])
    end

    def dump_available?
      !!@dump_available
    end

    class << self
      def find(id)
        Bounce.new(Postmark::HttpClient.get("bounces/#{id}"))
      end

      def all(options = {})
        options[:count] ||= 30
        options[:offset] ||= 0
        Postmark::HttpClient.get("bounces", options).map { |bounce_json| Bounce.new(bounce_json) }
      end

      def tags
        Postmark::HttpClient.get("bounces/tags")
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
postmark-0.9.0 lib/postmark/bounce.rb
postmark-0.8.0 lib/postmark/bounce.rb
challengepost-postmark-0.7.3 lib/postmark/bounce.rb
challengepost-postmark-0.7.2 lib/postmark/bounce.rb
challengepost-postmark-0.7.1 lib/postmark/bounce.rb
postmark-0.7.1 lib/postmark/bounce.rb
postmark-0.7.0 lib/postmark/bounce.rb