Class: Vonage::Numbers

Inherits:
Namespace
  • Object
show all
Defined in:
lib/vonage/numbers.rb

Defined Under Namespace

Classes: ListResponse, Response

Instance Method Summary collapse

Instance Method Details

#buy(params) ⇒ Response

Request to purchase a specific inbound number.

Examples:

response = client.numbers.buy(country: 'GB', msisdn: '447700900000')

Parameters:

  • params (Hash)

Options Hash (params):

  • :country (required, String)

    The two character country code in ISO 3166-1 alpha-2 format.

  • :msisdn (required, String)

    An available inbound virtual number.

  • :target_api_key (String)

    If you'd like to perform an action on a subaccount, provide the api_key of that account here. If you'd like to perform an action on your own account, you do not need to provide this field.

Returns:

See Also:



129
130
131
132
133
134
135
136
# File 'lib/vonage/numbers.rb', line 129

def buy(params)
  request(
    "/number/buy",
    params: params,
    type: Post,
    response_class: Response
  )
end

#cancel(params) ⇒ Response

Cancel your subscription for a specific inbound number.

Examples:

response = client.numbers.cancel(country: 'GB', msisdn: '447700900000')

Parameters:

  • params (Hash)

Options Hash (params):

  • :country (required, String)

    The two character country code in ISO 3166-1 alpha-2 format.

  • :msisdn (required, String)

    An available inbound virtual number.

  • :target_api_key (String)

    If you'd like to perform an action on a subaccount, provide the api_key of that account here. If you'd like to perform an action on your own account, you do not need to provide this field.

Returns:

See Also:



159
160
161
162
163
164
165
166
# File 'lib/vonage/numbers.rb', line 159

def cancel(params)
  request(
    "/number/cancel",
    params: params,
    type: Post,
    response_class: Response
  )
end

#list(params = nil) ⇒ ListResponse

Retrieve all the inbound numbers associated with your Vonage account.

Examples:

response = client.numbers.list
response.each do |item|
  puts "#{item.msisdn} #{item.country} #{item.type}"
end

Parameters:

  • params (Hash) (defaults to: nil)

Options Hash (params):

  • :application_id (String)

    The application that you want to return the numbers for.

  • :has_application (Boolean)

    Set this optional field to true to restrict your results to numbers associated with an application (any application). Set to false to find all numbers not associated with any application. Omit the field to avoid filtering on whether or not the number is assigned to an application.

  • :country (String)

    The two character country code to filter on (in ISO 3166-1 alpha-2 format).

  • :pattern (String)

    The number pattern you want to search for. Use in conjunction with :search_pattern.

  • :search_pattern (Integer)

    The strategy you want to use for matching:

    • 0 - Search for numbers that start with :pattern
    • 1 - Search for numbers that contain :pattern
    • 2 - Search for numbers that end with :pattern
  • :size (Integer)

    Page size.

  • :index (Integer)

    Page index.

  • :auto_advance (Boolean)

    Set this to true to auto-advance through all the pages in the record and collect all the data. The default is false.

Returns:

See Also:



56
57
58
# File 'lib/vonage/numbers.rb', line 56

def list(params = nil)
  request("/account/numbers", params: params, response_class: ListResponse)
end

#search(params) ⇒ ListResponse

Retrieve inbound numbers that are available for the specified country.

Examples:

response = client.numbers.search(country: 'GB')
response.each do |item|
  puts "#{item.msisdn} #{item.type} #{item.cost}"
end

Parameters:

  • params (Hash)

Options Hash (params):

  • :country (required, String)

    The two character country code in ISO 3166-1 alpha-2 format.

  • :type (String)

    Set this parameter to filter the type of number, such as mobile or landline.

  • :pattern (String)

    The number pattern you want to search for. Use in conjunction with :search_pattern.

  • :search_pattern (Integer)

    The strategy you want to use for matching:

    • 0 - Search for numbers that start with :pattern
    • 1 - Search for numbers that contain :pattern
    • 2 - Search for numbers that end with :pattern
  • :features (String)

    Available features are SMS and VOICE. To look for numbers that support both, use a comma-separated value: SMS,VOICE.

  • :size (Integer)

    Page size.

  • :index (Integer)

    Page index.

  • :auto_advance (Boolean)

    Set this to true to auto-advance through all the pages in the record and collect all the data. The default is false.

Returns:

See Also:



104
105
106
# File 'lib/vonage/numbers.rb', line 104

def search(params)
  request("/number/search", params: params, response_class: ListResponse)
end

#update(params) ⇒ Response

Change the behaviour of a number that you own.

Examples:

params = {
  country: 'GB',
  msisdn: '447700900000',
  voice_callback_type: 'app',
  voice_callback_value: application_id
}

response = client.numbers.update(params)

Parameters:

  • params (Hash)

Options Hash (params):

  • :country (required, String)

    The two character country code in ISO 3166-1 alpha-2 format.

  • :msisdn (required, String)

    An available inbound virtual number.

  • :mo_http_url (String)

    An URL-encoded URI to the webhook endpoint that handles inbound messages. Your webhook endpoint must be active before you make this request. Vonage makes a GET request to the endpoint and checks that it returns a 200 OK response. Set this parameter's value to an empty string to remove the webhook.

  • :mo_smpp_sys_type (String)

    The associated system type for your SMPP client.

  • :voice_callback_type (String)

    Specify whether inbound voice calls on your number are handled by your Application configuration, or forwarded to a SIP or a telephone number. Must be used with the :voice_callback_value option.

  • :voice_callback_value (String)

    A SIP URI, telephone number or Application ID. Must be used with the :voice_callback_type option.

  • :voice_status_callback (String)

    A webhook URI for Vonage to send a request to when a call ends.

Returns:

See Also:



212
213
214
215
216
217
218
219
# File 'lib/vonage/numbers.rb', line 212

def update(params)
  request(
    "/number/update",
    params: camelcase(params),
    type: Post,
    response_class: Response
  )
end