Class: Loqate::Email::Gateway
- Inherits:
-
Object
- Object
- Loqate::Email::Gateway
- Includes:
- Result::Mixin
- Defined in:
- lib/loqate/email/gateway.rb
Overview
Validates the existence of email addresses.
Constant Summary collapse
- BATCH_VALIDATE_ENDPOINT =
'/EmailValidation/Batch/Validate/v1.20/json3.ws'.freeze
- VALIDATE_ENDPOINT =
'/EmailValidation/Interactive/Validate/v2.00/json3.ws'.freeze
Constants included from Result::Mixin
Result::Mixin::Failure, Result::Mixin::Success
Instance Method Summary collapse
-
#batch_validate(options) ⇒ Result
Verifies up to 100 emails per batch.
-
#batch_validate!(options) ⇒ Array<BatchEmailValidation>
Verifies up to 100 emails per batch.
-
#initialize(client) ⇒ Gateway
constructor
Creates an email gateway.
-
#validate(options) ⇒ Result
Verifies the existence of an email address.
-
#validate!(options) ⇒ EmailValidation
Verifies the existence of an email address.
Methods included from Result::Mixin
#Failure, #Success, #unwrap_result_or_raise
Constructor Details
#initialize(client) ⇒ Gateway
Creates an email gateway.
22 23 24 25 26 |
# File 'lib/loqate/email/gateway.rb', line 22 def initialize(client) @client = client @mapper = Mappers::GenericMapper.new @error_mapper = Mappers::ErrorMapper.new end |
Instance Method Details
#batch_validate(options) ⇒ Result
Verifies up to 100 emails per batch.
77 78 79 80 81 82 |
# File 'lib/loqate/email/gateway.rb', line 77 def batch_validate() [:emails] = [:emails].join(',') if [:emails] response = client.get(BATCH_VALIDATE_ENDPOINT, ) response.errors? && build_error_from(response.items.first) || build_email_validations_from(response.items) end |
#batch_validate!(options) ⇒ Array<BatchEmailValidation>
Verifies up to 100 emails per batch.
96 97 98 |
# File 'lib/loqate/email/gateway.rb', line 96 def batch_validate!() unwrap_result_or_raise { batch_validate() } end |
#validate(options) ⇒ Result
Verifies the existence of an email address.
41 42 43 44 45 |
# File 'lib/loqate/email/gateway.rb', line 41 def validate() response = client.get(VALIDATE_ENDPOINT, ) response.errors? && build_error_from(response.items.first) || build_email_validation_from(response.items.first) end |
#validate!(options) ⇒ EmailValidation
Verifies the existence of an email address.
62 63 64 |
# File 'lib/loqate/email/gateway.rb', line 62 def validate!() unwrap_result_or_raise { validate() } end |