Class: Telnyx::Resources::PhoneNumbers::Jobs

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

Overview

Background jobs performed over a batch of phone numbers

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Jobs

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 Jobs.

Parameters:



171
172
173
# File 'lib/telnyx/resources/phone_numbers/jobs.rb', line 171

def initialize(client:)
  @client = client
end

Instance Method Details

#delete_batch(phone_numbers:, request_options: {}) ⇒ Telnyx::Models::PhoneNumbers::JobDeleteBatchResponse

Creates a new background job to delete a batch of numbers. At most one thousand numbers can be updated per API call.

Parameters:

Returns:

See Also:



72
73
74
75
76
77
78
79
80
81
# File 'lib/telnyx/resources/phone_numbers/jobs.rb', line 72

def delete_batch(params)
  parsed, options = Telnyx::PhoneNumbers::JobDeleteBatchParams.dump_request(params)
  @client.request(
    method: :post,
    path: "phone_numbers/jobs/delete_phone_numbers",
    body: parsed,
    model: Telnyx::Models::PhoneNumbers::JobDeleteBatchResponse,
    options: options
  )
end

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

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

Lists the phone numbers jobs

Parameters:

Returns:

See Also:



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/telnyx/resources/phone_numbers/jobs.rb', line 48

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

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

Retrieve a phone numbers job

Parameters:

  • id (String)

    Identifies the Phone Numbers Job.

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

Returns:

See Also:



19
20
21
22
23
24
25
26
# File 'lib/telnyx/resources/phone_numbers/jobs.rb', line 19

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

#update_batch(phone_numbers:, filter: nil, billing_group_id: nil, connection_id: nil, customer_reference: nil, deletion_lock_enabled: nil, external_pin: nil, hd_voice_enabled: nil, tags: nil, voice: nil, request_options: {}) ⇒ Telnyx::Models::PhoneNumbers::JobUpdateBatchResponse

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

Creates a new background job to update a batch of numbers. At most one thousand numbers can be updated per API call. At least one of the updateable fields must be submitted. IMPORTANT: You must either specify filters (using the filter parameters) or specific phone numbers (using the phone_numbers parameter in the request body). If you specify filters, ALL phone numbers that match the given filters (up to 1000 at a time) will be updated. If you want to update only specific numbers, you must use the phone_numbers parameter in the request body. When using the phone_numbers parameter, ensure you follow the correct format as shown in the example (either phone number IDs or phone numbers in E164 format).

Parameters:

  • phone_numbers (Array<String>)

    Body param: Array of phone number ids and/or phone numbers in E164 format to upd

  • filter (Telnyx::Models::PhoneNumbers::JobUpdateBatchParams::Filter)

    Query param: Consolidated filter parameter (deepObject style). Originally: filte

  • billing_group_id (String)

    Body param: Identifies the billing group associated with the phone number.

  • connection_id (String)

    Body param: Identifies the connection associated with the phone number.

  • customer_reference (String)

    Body param: A customer reference string for customer look ups.

  • deletion_lock_enabled (Boolean)

    Body param: Indicates whether to enable or disable the deletion lock on each pho

  • external_pin (String)

    Body param: If someone attempts to port your phone number away from Telnyx and y

  • hd_voice_enabled (Boolean)

    Body param: Indicates whether to enable or disable HD Voice on each phone number

  • tags (Array<String>)

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

  • voice (Telnyx::Models::PhoneNumbers::UpdateVoiceSettings)

    Body param

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

Returns:

See Also:



123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/telnyx/resources/phone_numbers/jobs.rb', line 123

def update_batch(params)
  query_params = [:filter]
  parsed, options = Telnyx::PhoneNumbers::JobUpdateBatchParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :post,
    path: "phone_numbers/jobs/update_phone_numbers",
    query: query,
    body: parsed.except(*query_params),
    model: Telnyx::Models::PhoneNumbers::JobUpdateBatchResponse,
    options: options
  )
end

#update_emergency_settings_batch(emergency_enabled:, phone_numbers:, emergency_address_id: nil, request_options: {}) ⇒ Telnyx::Models::PhoneNumbers::JobUpdateEmergencySettingsBatchResponse

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

Creates a background job to update the emergency settings of a collection of phone numbers. At most one thousand numbers can be updated per API call.

Parameters:

  • emergency_enabled (Boolean)

    Indicates whether to enable or disable emergency services on the numbers.

  • phone_numbers (Array<String>)
  • emergency_address_id (String, nil)

    Identifies the address to be used with emergency services. Required if emergency

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

Returns:

See Also:



157
158
159
160
161
162
163
164
165
166
# File 'lib/telnyx/resources/phone_numbers/jobs.rb', line 157

def update_emergency_settings_batch(params)
  parsed, options = Telnyx::PhoneNumbers::JobUpdateEmergencySettingsBatchParams.dump_request(params)
  @client.request(
    method: :post,
    path: "phone_numbers/jobs/update_emergency_settings",
    body: parsed,
    model: Telnyx::Models::PhoneNumbers::JobUpdateEmergencySettingsBatchResponse,
    options: options
  )
end