Class: Postmark::Bounce

Inherits:
Object
  • Object
show all
Defined in:
lib/postmark/bounce.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values = {}) ⇒ Bounce

Returns a new instance of Bounce.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/postmark/bounce.rb', line 6

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

Instance Attribute Details

#bounced_atObject (readonly)

Returns the value of attribute bounced_at.



4
5
6
# File 'lib/postmark/bounce.rb', line 4

def bounced_at
  @bounced_at
end

#detailsObject (readonly)

Returns the value of attribute details.



4
5
6
# File 'lib/postmark/bounce.rb', line 4

def details
  @details
end

#emailObject (readonly)

Returns the value of attribute email.



4
5
6
# File 'lib/postmark/bounce.rb', line 4

def email
  @email
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/postmark/bounce.rb', line 4

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/postmark/bounce.rb', line 4

def name
  @name
end

#server_idObject (readonly)

Returns the value of attribute server_id.



4
5
6
# File 'lib/postmark/bounce.rb', line 4

def server_id
  @server_id
end

#tagObject (readonly)

Returns the value of attribute tag.



4
5
6
# File 'lib/postmark/bounce.rb', line 4

def tag
  @tag
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/postmark/bounce.rb', line 4

def type
  @type
end

Class Method Details

.all(options = {}) ⇒ Object



44
45
46
47
48
# File 'lib/postmark/bounce.rb', line 44

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

.find(id) ⇒ Object



40
41
42
# File 'lib/postmark/bounce.rb', line 40

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

.tagsObject



50
51
52
# File 'lib/postmark/bounce.rb', line 50

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

Instance Method Details

#activateObject



31
32
33
# File 'lib/postmark/bounce.rb', line 31

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

#can_activate?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/postmark/bounce.rb', line 23

def can_activate?
  !!@can_activate
end

#dumpObject



27
28
29
# File 'lib/postmark/bounce.rb', line 27

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

#dump_available?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/postmark/bounce.rb', line 35

def dump_available?
  !!@dump_available
end

#inactive?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/postmark/bounce.rb', line 19

def inactive?
  !!@inactive
end