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 of the Credential resource to update.



251
252
253
254
255
256
257
258
259
260
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 251

def initialize(version, sid)
    super(version)
    

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

    
end

Instance Method Details

#deleteBoolean

Delete the CredentialInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



264
265
266
267
268
269
270
271
272
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 264

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the CredentialInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 277

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      credential_instance = CredentialInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      CredentialInstanceMetadata.new(@version, credential_instance, response.headers, response.status_code)
end

#fetchCredentialInstance

Fetch the CredentialInstance

Returns:



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 296

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    CredentialInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#fetch_with_metadataCredentialInstance

Fetch the CredentialInstanceMetadata

Returns:



315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 315

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    credential_instance = CredentialInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    CredentialInstanceMetadata.new(
        @version,
        credential_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



435
436
437
438
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 435

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

#to_sObject

Provide a user friendly representation



428
429
430
431
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 428

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)

    A descriptive string that you create to describe the resource. It can be up to 64 characters long.

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

    The URL encoded representation of the certificate. For example, ‘—–BEGIN CERTIFICATE—– MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.….A== —–END CERTIFICATE—–`

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

    The URL encoded representation of the private key. For example, ‘—–BEGIN RSA PRIVATE KEY—– MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG… —–END RSA PRIVATE KEY—–`

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

    Whether to send the credential to sandbox APNs. Can be true to send to sandbox APNs or false to send to production.

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

    The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.

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

    The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging.

Returns:



346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 346

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,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    CredentialInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

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

Update the CredentialInstanceMetadata

Parameters:

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

    A descriptive string that you create to describe the resource. It can be up to 64 characters long.

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

    The URL encoded representation of the certificate. For example, ‘—–BEGIN CERTIFICATE—– MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEF.….A== —–END CERTIFICATE—–`

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

    The URL encoded representation of the private key. For example, ‘—–BEGIN RSA PRIVATE KEY—– MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fG… —–END RSA PRIVATE KEY—–`

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

    Whether to send the credential to sandbox APNs. Can be true to send to sandbox APNs or false to send to production.

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

    The API key for the project that was obtained from the Google Developer console for your GCM Service application credential.

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

    The **Server key** of your project from the Firebase console, found under Settings / Cloud messaging.

Returns:



387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 387

def (
  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,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    credential_instance = CredentialInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    CredentialInstanceMetadata.new(
        @version,
        credential_instance,
        response.headers,
        response.status_code
    )
end