Class: Mailersend::EmailVerification

Inherits:
Object
  • Object
show all
Defined in:
lib/mailersend/email_verification/email_verification.rb

Overview

Email verification endpoint from MailerSend API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client = Mailersend::Client.new) ⇒ EmailVerification

Returns a new instance of EmailVerification.



11
12
13
14
15
16
# File 'lib/mailersend/email_verification/email_verification.rb', line 11

def initialize(client = Mailersend::Client.new)
  @client = client
  @page = page
  @limit = limit
  @email_verification_id = email_verification_id
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



6
7
8
# File 'lib/mailersend/email_verification/email_verification.rb', line 6

def client
  @client
end

#email_verification_idObject

Returns the value of attribute email_verification_id.



6
7
8
# File 'lib/mailersend/email_verification/email_verification.rb', line 6

def email_verification_id
  @email_verification_id
end

#limitObject

Returns the value of attribute limit.



6
7
8
# File 'lib/mailersend/email_verification/email_verification.rb', line 6

def limit
  @limit
end

#pageObject

Returns the value of attribute page.



6
7
8
# File 'lib/mailersend/email_verification/email_verification.rb', line 6

def page
  @page
end

Instance Method Details

#create_a_list(name: nil, emails: nil) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/mailersend/email_verification/email_verification.rb', line 38

def create_a_list(name: nil, emails: nil)
  hash = {
    'name' => name,
    'emails' => emails
  }
  client.http.post("#{MAILERSEND_API_URL}/email-verification", json: hash.compact)
end

#get_list_results(email_verification_id:) ⇒ Object



50
51
52
# File 'lib/mailersend/email_verification/email_verification.rb', line 50

def get_list_results(email_verification_id:)
  client.http.get("#{MAILERSEND_API_URL}/email-verification/#{email_verification_id}/results")
end

#get_single_list(email_verification_id:) ⇒ Object



34
35
36
# File 'lib/mailersend/email_verification/email_verification.rb', line 34

def get_single_list(email_verification_id:)
  client.http.get("#{MAILERSEND_API_URL}/email-verification/#{email_verification_id}")
end

#list(page: nil, limit: nil) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/mailersend/email_verification/email_verification.rb', line 25

def list(page: nil, limit: nil)
  hash = {
    'page' => page,
    'limit' => limit
  }
  client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/email-verification',
                                   query: URI.encode_www_form(hash)))
end

#verify_a_list(email_verification_id:) ⇒ Object



46
47
48
# File 'lib/mailersend/email_verification/email_verification.rb', line 46

def verify_a_list(email_verification_id:)
  client.http.get("#{MAILERSEND_API_URL}/email-verification/#{email_verification_id}/verify")
end

#verify_an_email(email: nil) ⇒ Object



18
19
20
21
22
23
# File 'lib/mailersend/email_verification/email_verification.rb', line 18

def verify_an_email(email: nil)
  hash = {
    'email' => email
  }
  client.http.post("#{MAILERSEND_API_URL}/email-verification/verify", json: hash.compact)
end