Class: Loqate::Phone::Gateway
- Inherits:
-
Object
- Object
- Loqate::Phone::Gateway
- Includes:
- Result::Mixin
- Defined in:
- lib/loqate/phone/gateway.rb
Overview
Starts a new phone number validation request.
Constant Summary collapse
- VALIDATE_ENDPOINT =
'/PhoneNumberValidation/Interactive/Validate/v2.20/json3.ws'.freeze
Constants included from Result::Mixin
Result::Mixin::Failure, Result::Mixin::Success
Instance Method Summary collapse
-
#initialize(client) ⇒ Gateway
constructor
Creates a phone gateway.
-
#validate(options) ⇒ Result
Validates phone numbers.
-
#validate!(options) ⇒ PhoneNumberValidation
Validates phone numbers.
Methods included from Result::Mixin
#Failure, #Success, #unwrap_result_or_raise
Constructor Details
#initialize(client) ⇒ Gateway
Creates a phone gateway
20 21 22 23 24 |
# File 'lib/loqate/phone/gateway.rb', line 20 def initialize(client) @client = client @mapper = Mappers::GenericMapper.new @error_mapper = Mappers::ErrorMapper.new end |
Instance Method Details
#validate(options) ⇒ Result
Validates phone numbers.
40 41 42 43 44 |
# File 'lib/loqate/phone/gateway.rb', line 40 def validate() response = client.get(VALIDATE_ENDPOINT, ) response.errors? && build_error_from(response.items.first) || build_phone_validation_from(response.items.first) end |
#validate!(options) ⇒ PhoneNumberValidation
Validates phone numbers.
62 63 64 |
# File 'lib/loqate/phone/gateway.rb', line 62 def validate!() unwrap_result_or_raise { validate() } end |