Sha256: 3194834e21c2907ffea4e984c774aa86f5af4b5d5f3d6ea5285b0bde9f0f6dde

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module Mailersend
  # Email verification endpoint from MailerSend API.
  class EmailVerification
    attr_accessor :client,
                  :page,
                  :limit,
                  :email_verification_id

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

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

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

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

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mailersend-ruby-1.4.0 lib/mailersend/email_verification/email_verification.rb
mailersend-ruby-1.3.2 lib/mailersend/email_verification/email_verification.rb
mailersend-ruby-1.3.1 lib/mailersend/email_verification/email_verification.rb
mailersend-ruby-1.3.0 lib/mailersend/email_verification/email_verification.rb