Class: Twilio::REST::Chat::V2::CredentialContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/chat/v2/credential.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ CredentialContext

Initialize the CredentialContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The sid



192
193
194
195
196
197
198
199
200
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 192

def initialize(version, sid)
  super(version)

  # Path Solution
  @solution = {
      sid: sid,
  }
  @uri = "/Credentials/#{@solution[:sid]}"
end

Instance Method Details

#deleteBoolean

Deletes the CredentialInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



256
257
258
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 256

def delete
  @version.delete('delete', @uri)
end

#fetchCredentialInstance

Fetch a CredentialInstance

Returns:



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 205

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  CredentialInstance.new(
      @version,
      payload,
      sid: @solution[:sid],
  )
end

#to_sObject

Provide a user friendly representation



262
263
264
265
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 262

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Chat.V2.CredentialContext #{context}>"
end

#update(friendly_name: :unset, certificate: :unset, private_key: :unset, sandbox: :unset, api_key: :unset, secret: :unset) ⇒ CredentialInstance

Update the CredentialInstance

Parameters:

  • friendly_name (String) (defaults to: :unset)

    The friendly_name

  • certificate (String) (defaults to: :unset)

    The certificate

  • private_key (String) (defaults to: :unset)

    The private_key

  • sandbox (Boolean) (defaults to: :unset)

    The sandbox

  • api_key (String) (defaults to: :unset)

    The api_key

  • secret (String) (defaults to: :unset)

    The secret

Returns:



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 230

def update(friendly_name: :unset, certificate: :unset, private_key: :unset, sandbox: :unset, api_key: :unset, secret: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'Certificate' => certificate,
      'PrivateKey' => private_key,
      'Sandbox' => sandbox,
      'ApiKey' => api_key,
      'Secret' => secret,
  })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  CredentialInstance.new(
      @version,
      payload,
      sid: @solution[:sid],
  )
end