Class: Tomba::Phone

Inherits:
Service show all
Defined in:
lib/tomba/services/phone.rb

Overview

Phone service for phone number lookup and validation.

Provides methods to find and validate phone numbers.

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from Tomba::Service

Instance Method Details

#finder(params, webhook_url: nil) ⇒ Hash

Phone Finder

Finds a phone number using search parameters.

Parameters:

  • params (Hash)

    search parameters (e.g., email, domain)

  • webhook_url (String, nil) (defaults to: nil)

    webhook URL for async notifications

Returns:

  • (Hash)

    API response containing phone number data

Raises:

See Also:



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tomba/services/phone.rb', line 19

def finder(params, webhook_url: nil)
  raise Tomba::Exception, 'Missing required parameter: "params"' if params.nil? || params.empty?

  path = '/phone-finder'

  params[:webhook_url] = webhook_url unless webhook_url.nil?

  @client.call('get', path, {
                 'content-type' => 'application/json'
               }, params)
end

#validator(phone, country_code: nil) ⇒ Hash

Phone Validator

Validates a phone number and returns detailed information about it.

Parameters:

  • phone (String)

    the phone number to validate

  • country_code (String, nil) (defaults to: nil)

    optional ISO country code (e.g., "US")

Returns:

  • (Hash)

    API response containing validation results

Raises:

See Also:



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/tomba/services/phone.rb', line 40

def validator(phone, country_code: nil)
  raise Tomba::Exception, 'Missing required parameter: "phone"' if phone.nil?

  path = '/phone-validator'

  params = { phone: phone }
  params[:country_code] = country_code unless country_code.nil?

  @client.call('get', path, {
                 'content-type' => 'application/json'
               }, params)
end