Class: Telnyx::Resources::ExternalConnections::PhoneNumbers

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

Overview

External Connections operations

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:



104
105
106
# File 'lib/telnyx/resources/external_connections/phone_numbers.rb', line 104

def initialize(client:)
  @client = client
end

Instance Method Details

#list(id, filter: nil, page_number: nil, page_size: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::ExternalConnections::ExternalConnectionPhoneNumber>

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

Returns a list of all active phone numbers associated with the given external connection.

Parameters:

Returns:

See Also:



88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/telnyx/resources/external_connections/phone_numbers.rb', line 88

def list(id, params = {})
  parsed, options = Telnyx::ExternalConnections::PhoneNumberListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["external_connections/%1$s/phone_numbers", id],
    query: query.transform_keys(page_number: "page[number]", page_size: "page[size]"),
    page: Telnyx::Internal::DefaultFlatPagination,
    model: Telnyx::ExternalConnections::ExternalConnectionPhoneNumber,
    options: options
  )
end

#retrieve(phone_number_id, id:, request_options: {}) ⇒ Telnyx::Models::ExternalConnections::PhoneNumberRetrieveResponse

Return the details of a phone number associated with the given external connection.

Parameters:

  • phone_number_id (String)

    A phone number’s ID via the Telnyx API

  • id (String)

    Identifies the resource.

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

Returns:

See Also:



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

def retrieve(phone_number_id, params)
  parsed, options = Telnyx::ExternalConnections::PhoneNumberRetrieveParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["external_connections/%1$s/phone_numbers/%2$s", id, phone_number_id],
    model: Telnyx::Models::ExternalConnections::PhoneNumberRetrieveResponse,
    options: options
  )
end

#update(phone_number_id, id:, location_id: nil, request_options: {}) ⇒ Telnyx::Models::ExternalConnections::PhoneNumberUpdateResponse

Asynchronously update settings of the phone number associated with the given external connection.

Parameters:

  • phone_number_id (String)

    Path param: A phone number’s ID via the Telnyx API

  • id (String)

    Path param: Identifies the resource.

  • location_id (String)

    Body param: Identifies the location to assign the phone number to.

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

Returns:

See Also:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/telnyx/resources/external_connections/phone_numbers.rb', line 52

def update(phone_number_id, params)
  parsed, options = Telnyx::ExternalConnections::PhoneNumberUpdateParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :patch,
    path: ["external_connections/%1$s/phone_numbers/%2$s", id, phone_number_id],
    body: parsed,
    model: Telnyx::Models::ExternalConnections::PhoneNumberUpdateResponse,
    options: options
  )
end