Class: Telnyx::Resources::PhoneNumbers

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/phone_numbers.rb,
lib/telnyx/resources/phone_numbers/jobs.rb,
lib/telnyx/resources/phone_numbers/voice.rb,
lib/telnyx/resources/phone_numbers/actions.rb,
lib/telnyx/resources/phone_numbers/messaging.rb,
lib/telnyx/resources/phone_numbers/voicemail.rb,
lib/telnyx/resources/phone_numbers/csv_downloads.rb,
sig/telnyx/resources/phone_numbers.rbs,
sig/telnyx/resources/phone_numbers/jobs.rbs,
sig/telnyx/resources/phone_numbers/voice.rbs,
sig/telnyx/resources/phone_numbers/actions.rbs,
sig/telnyx/resources/phone_numbers/messaging.rbs,
sig/telnyx/resources/phone_numbers/voicemail.rbs,
sig/telnyx/resources/phone_numbers/csv_downloads.rbs

Overview

Configure your phone numbers

Defined Under Namespace

Classes: Actions, CsvDownloads, Jobs, Messaging, Voice, Voicemail

Instance Attribute Summary collapse

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:



190
191
192
193
194
195
196
197
198
# File 'lib/telnyx/resources/phone_numbers.rb', line 190

def initialize(client:)
  @client = client
  @actions = Telnyx::Resources::PhoneNumbers::Actions.new(client: client)
  @csv_downloads = Telnyx::Resources::PhoneNumbers::CsvDownloads.new(client: client)
  @jobs = Telnyx::Resources::PhoneNumbers::Jobs.new(client: client)
  @messaging = Telnyx::Resources::PhoneNumbers::Messaging.new(client: client)
  @voice = Telnyx::Resources::PhoneNumbers::Voice.new(client: client)
  @voicemail = Telnyx::Resources::PhoneNumbers::Voicemail.new(client: client)
end

Instance Attribute Details

#actionsTelnyx::Resources::PhoneNumbers::Actions (readonly)

Configure your phone numbers



9
10
11
# File 'lib/telnyx/resources/phone_numbers.rb', line 9

def actions
  @actions
end

#csv_downloadsTelnyx::Resources::PhoneNumbers::CsvDownloads (readonly)



12
13
14
# File 'lib/telnyx/resources/phone_numbers.rb', line 12

def csv_downloads
  @csv_downloads
end

#jobsTelnyx::Resources::PhoneNumbers::Jobs (readonly)

Background jobs performed over a batch of phone numbers



16
17
18
# File 'lib/telnyx/resources/phone_numbers.rb', line 16

def jobs
  @jobs
end

#messagingTelnyx::Resources::PhoneNumbers::Messaging (readonly)

Configure your phone numbers



20
21
22
# File 'lib/telnyx/resources/phone_numbers.rb', line 20

def messaging
  @messaging
end

#voiceTelnyx::Resources::PhoneNumbers::Voice (readonly)

Configure your phone numbers



24
25
26
# File 'lib/telnyx/resources/phone_numbers.rb', line 24

def voice
  @voice
end

#voicemailTelnyx::Resources::PhoneNumbers::Voicemail (readonly)

Voicemail API



28
29
30
# File 'lib/telnyx/resources/phone_numbers.rb', line 28

def voicemail
  @voicemail
end

Instance Method Details

#delete(id, request_options: {}) ⇒ Telnyx::Models::PhoneNumberDeleteResponse

Deletes the specified phone number from the account. The response contains the phone number's final deleted representation.

Parameters:

  • id (String)

    Identifies the resource.

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

Returns:

See Also:



140
141
142
143
144
145
146
147
# File 'lib/telnyx/resources/phone_numbers.rb', line 140

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["phone_numbers/%1$s", id],
    model: Telnyx::Models::PhoneNumberDeleteResponse,
    options: params[:request_options]
  )
end

#list(filter: nil, handle_messaging_profile_error: nil, page_number: nil, page_size: nil, sort: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::NumbersPhoneNumberDetailed>

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

Returns phone numbers associated with the account. Results support pagination, sorting, and filters for number attributes, status, source, connections, billing groups, emergency addresses, tags, and customer references.

Parameters:

Returns:

See Also:



115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/telnyx/resources/phone_numbers.rb', line 115

def list(params = {})
  parsed, options = Telnyx::PhoneNumberListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "phone_numbers",
    query: query.transform_keys(page_number: "page[number]", page_size: "page[size]"),
    page: Telnyx::Internal::DefaultFlatPagination,
    model: Telnyx::NumbersPhoneNumberDetailed,
    options: options
  )
end

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

Returns the detailed configuration and current state of the phone number identified by id.

Parameters:

  • id (String)

    Identifies the resource.

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

Returns:

See Also:



42
43
44
45
46
47
48
49
# File 'lib/telnyx/resources/phone_numbers.rb', line 42

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["phone_numbers/%1$s", id],
    model: Telnyx::Models::PhoneNumberRetrieveResponse,
    options: params[:request_options]
  )
end

#slim_list(filter: nil, include_connection: nil, include_tags: nil, page_number: nil, page_size: nil, sort: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::PhoneNumberSlimListResponse>

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

List phone numbers, This endpoint is a lighter version of the /phone_numbers endpoint having higher performance and rate limit.

Parameters:

Returns:

See Also:



174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/telnyx/resources/phone_numbers.rb', line 174

def slim_list(params = {})
  parsed, options = Telnyx::PhoneNumberSlimListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "phone_numbers/slim",
    query: query.transform_keys(page_number: "page[number]", page_size: "page[size]"),
    page: Telnyx::Internal::DefaultFlatPagination,
    model: Telnyx::Models::PhoneNumberSlimListResponse,
    options: options
  )
end

#update(phone_number_id, address_id: nil, billing_group_id: nil, connection_id: nil, customer_reference: nil, external_pin: nil, hd_voice_enabled: nil, tags: nil, request_options: {}) ⇒ Telnyx::Models::PhoneNumberUpdateResponse

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

Updates the configurable settings of the specified phone number. The response contains the complete updated phone-number representation.

Parameters:

  • phone_number_id (String)

    Identifies the resource.

  • address_id (String)

    Identifies the address associated with the phone number.

  • billing_group_id (String)

    Identifies the billing group associated with the phone number.

  • connection_id (String)

    Identifies the connection associated with the phone number.

  • customer_reference (String)

    A customer reference string for customer look ups.

  • external_pin (String)

    If someone attempts to port your phone number away from Telnyx and your phone nu

  • hd_voice_enabled (Boolean)

    Indicates whether HD voice is enabled for this number.

  • tags (Array<String>)

    A list of user-assigned tags to help organize phone numbers.

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

Returns:

See Also:



80
81
82
83
84
85
86
87
88
89
# File 'lib/telnyx/resources/phone_numbers.rb', line 80

def update(phone_number_id, params = {})
  parsed, options = Telnyx::PhoneNumberUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["phone_numbers/%1$s", phone_number_id],
    body: parsed,
    model: Telnyx::Models::PhoneNumberUpdateResponse,
    options: options
  )
end