Class: Telnyx::Resources::Dir::PhoneNumbers

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

Overview

Associate phone numbers with a verified DIR so calls from those numbers carry the DIR’s display identity.

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:



105
106
107
# File 'lib/telnyx/resources/dir/phone_numbers.rb', line 105

def initialize(client:)
  @client = client
end

Instance Method Details

#add(dir_id, documents:, phone_numbers:, request_options: {}) ⇒ Telnyx::Models::Dir::PhoneNumberAddResponse

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

Register phone numbers under a DIR. The enterprise is resolved server-side from the DIR id. Same body, failure modes, and batch semantics whichever path form you use.

Pricing: This is a billable action. See telnyx.com/pricing/numbers for current pricing.

Parameters:

  • dir_id (String)

    The DIR id. Lowercase UUID.

  • documents (Array<Telnyx::Models::Dir::PhoneNumberAddParams::Document>)

    Supporting documents covering this batch. At least one entry with ‘document_type

  • phone_numbers (Array<String>)

    1–15 phone numbers in E.164 format. 10-digit US numbers are auto-prefixed with ‘

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

Returns:

See Also:



66
67
68
69
70
71
72
73
74
75
# File 'lib/telnyx/resources/dir/phone_numbers.rb', line 66

def add(dir_id, params)
  parsed, options = Telnyx::Dir::PhoneNumberAddParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["dir/%1$s/phone_numbers", dir_id],
    body: parsed,
    model: Telnyx::Models::Dir::PhoneNumberAddResponse,
    options: options
  )
end

#list(dir_id, page_number: nil, page_size: nil, status: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::Dir::PhoneNumberListResponse>

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

List the phone numbers registered under a DIR. The enterprise is resolved server-side from the DIR id.

Parameters:

  • dir_id (String)

    The DIR id. Lowercase UUID.

  • page_number (Integer)

    1-based page number. Out-of-range values return an empty page with correct meta.

  • page_size (Integer)

    Items per page. Maximum 250; values above are clamped to 250.

  • status (Symbol, Telnyx::Models::Dir::PhoneNumberListParams::Status)

    Filter by phone-number status.

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

Returns:

See Also:



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/telnyx/resources/dir/phone_numbers.rb', line 30

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

#remove(dir_id, phone_numbers:, request_options: {}) ⇒ Telnyx::Models::Dir::PhoneNumberRemoveResponse

Deregister phone numbers from a DIR. The enterprise is resolved server-side from the DIR id. Returns a partial-success envelope.

Parameters:

  • dir_id (String)

    The DIR id. Lowercase UUID.

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

Returns:

See Also:



91
92
93
94
95
96
97
98
99
100
# File 'lib/telnyx/resources/dir/phone_numbers.rb', line 91

def remove(dir_id, params)
  parsed, options = Telnyx::Dir::PhoneNumberRemoveParams.dump_request(params)
  @client.request(
    method: :delete,
    path: ["dir/%1$s/phone_numbers", dir_id],
    body: parsed,
    model: Telnyx::Models::Dir::PhoneNumberRemoveResponse,
    options: options
  )
end