Class: SurgeAPI::Resources::PhoneNumbers

Inherits:
Object
  • Object
show all
Defined in:
lib/surge_api/resources/phone_numbers.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ PhoneNumbers

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PhoneNumbers.

Parameters:



73
74
75
# File 'lib/surge_api/resources/phone_numbers.rb', line 73

def initialize(client:)
  @client = client
end

Instance Method Details

#list(account_id, after: nil, before: nil, request_options: {}) ⇒ SurgeAPI::Internal::Cursor<SurgeAPI::Models::PhoneNumber>

Some parameter documentations has been truncated, see Models::PhoneNumberListParams for more details.

List all phone numbers for an account with cursor-based pagination.

Parameters:

  • account_id (String)

    The account ID to list phone numbers for.

  • after (String)

    Cursor for forward pagination. Use the next_cursor from a previous response.

  • before (String)

    Cursor for backward pagination. Use the previous_cursor from a previous response

  • request_options (SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/surge_api/resources/phone_numbers.rb', line 24

def list(, params = {})
  parsed, options = SurgeAPI::PhoneNumberListParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["accounts/%1$s/phone_numbers", ],
    query: parsed,
    page: SurgeAPI::Internal::Cursor,
    model: SurgeAPI::PhoneNumber,
    options: options
  )
end

#purchase(account_id, area_code: nil, latitude: nil, longitude: nil, type: nil, request_options: {}) ⇒ SurgeAPI::Models::PhoneNumber

Some parameter documentations has been truncated, see Models::PhoneNumberPurchaseParams for more details.

Purchase a new phone number for the account. You can specify search criteria or let the system select a random number.

Parameters:

  • account_id (String)

    The account for which the phone number should be created.

  • area_code (String)

    The desired area code for this phone number. If provided without type, the type

  • latitude (Float)

    Latitude to search for nearby phone numbers. Must be used with longitude. If pro

  • longitude (Float)

    Longitude to search for nearby phone numbers. Must be used with latitude. If pro

  • type (Symbol, SurgeAPI::Models::PhoneNumberPurchaseParams::Type)

    Whether the phone number is local or toll-free. Can be omitted if area_code or l

  • request_options (SurgeAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



59
60
61
62
63
64
65
66
67
68
# File 'lib/surge_api/resources/phone_numbers.rb', line 59

def purchase(, params = {})
  parsed, options = SurgeAPI::PhoneNumberPurchaseParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["accounts/%1$s/phone_numbers", ],
    body: parsed,
    model: SurgeAPI::PhoneNumber,
    options: options
  )
end