Class: PhoneValidator::Client
- Inherits:
-
Object
- Object
- PhoneValidator::Client
- Includes:
- HTTParty
- Defined in:
- lib/genderapi-phone-validator/client.rb
Overview
PhoneValidator::Client
Ruby SDK for the Phone Number Validation & Formatter API provided by GenderAPI.
This class allows you to:
- Validate international phone numbers
- Detect number type (mobile, landline, VoIP, etc.)
- Retrieve region and country metadata
- Format numbers to E.164 or national format
Instance Method Summary collapse
-
#initialize(api_key:, base_url: nil) ⇒ Client
constructor
Initializes a new client instance.
-
#validate(number:, address: "") ⇒ Hash
Validates and formats a phone number.
Constructor Details
#initialize(api_key:, base_url: nil) ⇒ Client
Initializes a new client instance.
33 34 35 36 37 38 39 40 |
# File 'lib/genderapi-phone-validator/client.rb', line 33 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
Validates and formats a phone number.
53 54 55 56 57 58 59 60 |
# File 'lib/genderapi-phone-validator/client.rb', line 53 def validate(number:, address: "") payload = { number: number, address: address } _post_request("/api/phone", payload) end |