Class: Telnyx::Resources::ShortCodes

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

Overview

Short codes

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ ShortCodes

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

Parameters:



89
90
91
# File 'lib/telnyx/resources/short_codes.rb', line 89

def initialize(client:)
  @client = client
end

Instance Method Details

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

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

List short codes

Parameters:

Returns:

See Also:



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/telnyx/resources/short_codes.rb', line 73

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

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

Retrieve a short code

Parameters:

  • id (String)

    The id of the short code

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

Returns:

See Also:



18
19
20
21
22
23
24
25
# File 'lib/telnyx/resources/short_codes.rb', line 18

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

#update(id, messaging_profile_id:, tags: nil, request_options: {}) ⇒ Telnyx::Models::ShortCodeUpdateResponse

Update the settings for a specific short code. To unbind a short code from a profile, set the ‘messaging_profile_id` to `null` or an empty string. To add or update tags, include the tags field as an array of strings.

Parameters:

  • id (String)

    The id of the short code

  • messaging_profile_id (String)

    Unique identifier for a messaging profile.

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

Returns:

See Also:



44
45
46
47
48
49
50
51
52
53
# File 'lib/telnyx/resources/short_codes.rb', line 44

def update(id, params)
  parsed, options = Telnyx::ShortCodeUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["short_codes/%1$s", id],
    body: parsed,
    model: Telnyx::Models::ShortCodeUpdateResponse,
    options: options
  )
end