Class: Mailgun::Bounce

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

Overview

Interface to manage bounce lists Refer - documentation.mailgun.net/api-bounces.html for optional params to pass

Instance Method Summary collapse

Constructor Details

#initialize(mailgun, domain) ⇒ Bounce

Used internally, called from Mailgun::Base



7
8
9
10
# File 'lib/mailgun/bounce.rb', line 7

def initialize(mailgun, domain)
  @mailgun = mailgun
  @domain  = domain
end

Instance Method Details

#add(email, options = {}) ⇒ Object

Creates a bounce for an email address

Parameters:

  • email (String)

    email address to bounce

  • options (Hash) (defaults to: {})

    options to populate to mailgun bounce creation

Options Hash (options):

  • code (Object) — default: 550
    Integer

    Error code

  • error (Object) — default: ''
    String

    Error description



38
39
40
# File 'lib/mailgun/bounce.rb', line 38

def add(email, options={})
  Mailgun.submit :post, bounce_url, {:address => email}.merge(options)
end

#destroy(email) ⇒ Object

Cleans the bounces for an email address



43
44
45
# File 'lib/mailgun/bounce.rb', line 43

def destroy(email)
  Mailgun.submit :delete, bounce_url(email)  
end

#find(email) ⇒ Object

Find bounce events for an email address



26
27
28
# File 'lib/mailgun/bounce.rb', line 26

def find(email)
  Mailgun.submit :get, bounce_url(email)
end

#list(options = {}) ⇒ Object

List all bounces for a given domain

Parameters:

  • options (Hash) (defaults to: {})

    options to populate to mailgun find

Options Hash (options):

  • limit (Object) — default: 100
    Integer

    limit of results

  • skip (Object) — default: 0
    Integer

    number of results to skip



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

def list(options={})
  Mailgun.submit(:get, bounce_url, options)["items"] || []
end