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

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:



185
186
187
188
189
190
191
192
193
# File 'lib/telnyx/resources/phone_numbers.rb', line 185

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

Delete a phone number

Parameters:

  • id (String)

    Identifies the resource.

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

Returns:

See Also:



135
136
137
138
139
140
141
142
# File 'lib/telnyx/resources/phone_numbers.rb', line 135

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::PhoneNumberDetailed>

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

List phone numbers

Parameters:

Returns:

See Also:



111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/telnyx/resources/phone_numbers.rb', line 111

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::PhoneNumberDetailed,
    options: options
  )
end

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

Retrieve a phone number

Parameters:

  • id (String)

    Identifies the resource.

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

Returns:

See Also:



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

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:



169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/telnyx/resources/phone_numbers.rb', line 169

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.

Update a phone number

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:



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

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