Class: Telnyx::Resources::TelephonyCredentials

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ TelephonyCredentials

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

Parameters:



159
160
161
# File 'lib/telnyx/resources/telephony_credentials.rb', line 159

def initialize(client:)
  @client = client
end

Instance Method Details

#create(connection_id:, expires_at: nil, name: nil, tag: nil, request_options: {}) ⇒ Telnyx::Models::TelephonyCredentialCreateResponse

Create a credential.

Parameters:

  • connection_id (String)

    Identifies the Credential Connection this credential is associated with.

  • expires_at (String)

    ISO-8601 formatted date indicating when the credential will expire.

  • name (String)
  • tag (String)

    Tags a credential. A single tag can hold at maximum 1000 credentials.

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

Returns:

See Also:



23
24
25
26
27
28
29
30
31
32
# File 'lib/telnyx/resources/telephony_credentials.rb', line 23

def create(params)
  parsed, options = Telnyx::TelephonyCredentialCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "telephony_credentials",
    body: parsed,
    model: Telnyx::Models::TelephonyCredentialCreateResponse,
    options: options
  )
end

#create_token(id, request_options: {}) ⇒ String

Create an Access Token (JWT) for the credential.

Parameters:

  • id (String)

    Identifies the resource.

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

Returns:

  • (String)

See Also:



146
147
148
149
150
151
152
153
154
# File 'lib/telnyx/resources/telephony_credentials.rb', line 146

def create_token(id, params = {})
  @client.request(
    method: :post,
    path: ["telephony_credentials/%1$s/token", id],
    headers: {"accept" => "text/plain"},
    model: String,
    options: params[:request_options]
  )
end

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

Delete an existing credential.

Parameters:

  • id (String)

    Identifies the resource.

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

Returns:

See Also:



126
127
128
129
130
131
132
133
# File 'lib/telnyx/resources/telephony_credentials.rb', line 126

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

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

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

List all On-demand Credentials.

Parameters:

Returns:

See Also:



102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/telnyx/resources/telephony_credentials.rb', line 102

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

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

Get the details of an existing On-demand Credential.

Parameters:

  • id (String)

    Identifies the resource.

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

Returns:

See Also:



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

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

#update(id, connection_id: nil, expires_at: nil, name: nil, tag: nil, request_options: {}) ⇒ Telnyx::Models::TelephonyCredentialUpdateResponse

Update an existing credential.

Parameters:

  • id (String)

    Identifies the resource.

  • connection_id (String)

    Identifies the Credential Connection this credential is associated with.

  • expires_at (String)

    ISO-8601 formatted date indicating when the credential will expire.

  • name (String)
  • tag (String)

    Tags a credential. A single tag can hold at maximum 1000 credentials.

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

Returns:

See Also:



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

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