Class: Readiness::Mailgun::Bounces

Inherits:
Client
  • Object
show all
Defined in:
lib/support_readiness/mailgun/bounces.rb

Overview

Defines the class Bounces within the module Readiness::Mailgun.

Author:

  • Jason Colyer

Since:

  • 1.0.12

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Client

auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries

Constructor Details

#initialize(object = {}) ⇒ Bounces

Creates a new Readiness::Mailgun::Bounces instance

Examples:

require 'support_readiness'
Readiness::Mailgun::Bounces.new

Parameters:

Author:

  • Jason Colyer

Since:

  • 1.0.12



24
25
26
27
28
29
# File 'lib/support_readiness/mailgun/bounces.rb', line 24

def initialize(object = {})
  @address = object['address']
  @code = object['code']
  @error = object['error']
  @created_at = object['created_at']
end

Instance Attribute Details

#addressObject

Since:

  • 1.0.12



13
14
15
# File 'lib/support_readiness/mailgun/bounces.rb', line 13

def address
  @address
end

#codeObject

Since:

  • 1.0.12



13
14
15
# File 'lib/support_readiness/mailgun/bounces.rb', line 13

def code
  @code
end

#created_atObject

Since:

  • 1.0.12



13
14
15
# File 'lib/support_readiness/mailgun/bounces.rb', line 13

def created_at
  @created_at
end

#errorObject

Since:

  • 1.0.12



13
14
15
# File 'lib/support_readiness/mailgun/bounces.rb', line 13

def error
  @error
end

Class Method Details

.delete!(client, bounce) ⇒ Boolean

Deletes a suppression within Mailgun. This will exit on error

Examples:

require 'support_readiness'
config = Readiness::Mailgun::Configuration.new
config.domain = 'test.gitlab.com'
config.token = 'abc123'
client = Readiness::Mailgun::Client.new(config)
bounce = Readiness::Mailgun::Bounces.find!(client, 'test@example.com')
pp Readiness::Mailgun::Bounces.delete!(client, bounce)
# => true

Parameters:

Returns:

  • (Boolean)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.12



96
97
98
99
100
# File 'lib/support_readiness/mailgun/bounces.rb', line 96

def self.delete!(client, bounce)
  response = client.connection.delete "#{client.domain}/bounces/#{CGI.escape(bounce.address)}"
  handle_request_error(1, 'Mailgun', response.status,  { action: 'delete', id: "#{client.domain}/bounces/#{CGI.escape(email)}" }) unless response.status == 200
  true
end

.find(client, email) ⇒ Object

Locates a suppression within Mailgun. This will not exit on error (except Authentication errors)

Examples:

require 'support_readiness'
config = Readiness::Mailgun::Configuration.new
config.domain = 'test.gitlab.com'
config.token = 'abc123'
client = Readiness::Mailgun::Client.new(config)
bounce = Readiness::Mailgun::Bounces.find(client, 'test@example.com')
pp bounce.code
# => "550"

Parameters:

  • client (Object)

    An instance of Client

  • email (String)

    The email to look for

Returns:

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.12



49
50
51
52
53
# File 'lib/support_readiness/mailgun/bounces.rb', line 49

def self.find(client, email)
  response = client.connection.get "#{client.domain}/bounces/#{CGI.escape(email)}"
  handle_request_error(0, 'Mailgun', response.status,  { action: 'get', id: "#{client.domain}/bounces/#{CGI.escape(email)}" }) unless response.status == 200
  Bounces.new Oj.load(response.body)
end

.find!(client, email) ⇒ Object

Locates a suppression within Mailgun. This will exit on error

Examples:

require 'support_readiness'
config = Readiness::Mailgun::Configuration.new
config.domain = 'test.gitlab.com'
config.token = 'abc123'
client = Readiness::Mailgun::Client.new(config)
bounce = Readiness::Mailgun::Bounces.find!(client, 'test@example.com')
pp bounce.code
# => "550"

Parameters:

  • client (Object)

    An instance of Client

  • email (String)

    The email to look for

Returns:

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.12



73
74
75
76
77
# File 'lib/support_readiness/mailgun/bounces.rb', line 73

def self.find!(client, email)
  response = client.connection.get "#{client.domain}/bounces/#{CGI.escape(email)}"
  handle_request_error(1, 'Mailgun', response.status,  { action: 'get', id: "#{client.domain}/bounces/#{CGI.escape(email)}" }) unless response.status == 200
  Bounces.new Oj.load(response.body)
end