Class: PhoneValidator::Client
- Inherits:
-
Object
- Object
- PhoneValidator::Client
- Includes:
- HTTParty
- Defined in:
- lib/genderapi-phone-validator/client.rb
Overview
Ruby SDK for Phone Number Validation & Formatter API from www.genderapi.io
This SDK allows you to:
- Validate international phone numbers
- Detect number type (mobile, landline, VoIP, etc.)
- Retrieve region and country
- Format numbers to E.164 or national format
Learn more: www.genderapi.io
Instance Method Summary collapse
-
#initialize(api_key:, base_url: nil) ⇒ Client
constructor
Initialize the PhoneValidator client.
-
#validate(number:, address: "") ⇒ Hash
Validate and format a phone number.
Constructor Details
#initialize(api_key:, base_url: nil) ⇒ Client
Initialize the PhoneValidator client.
28 29 30 31 32 33 34 35 |
# File 'lib/genderapi-phone-validator/client.rb', line 28 def initialize(api_key:, base_url: nil) @api_key = api_key self.class.base_uri(base_url) if base_url @headers = { "Authorization" => "Bearer #{@api_key}", "Content-Type" => "application/json" } end |
Instance Method Details
#validate(number:, address: "") ⇒ Hash
Validate and format a phone number.
45 46 47 48 49 50 51 52 |
# File 'lib/genderapi-phone-validator/client.rb', line 45 def validate(number:, address: "") payload = { number: number, address: address } _post_request("/api/phone", payload) end |