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



187
188
189
190
191
192
193
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 187

def initialize(version, sid)
  super(version)

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

Instance Method Details

#delete ⇒ Boolean

Delete the CredentialInstance

Returns:

  • (Boolean) —

    true if delete succeeds, false otherwise



243
244
245
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 243

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

#fetch ⇒ CredentialInstance

Fetch the CredentialInstance

Returns:



198
199
200
201
202
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 198

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

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

#inspect ⇒ Object

Provide a detailed, user friendly representation



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

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

#to_s ⇒ Object

Provide a user friendly representation



249
250
251
252
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 249

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:



225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/twilio-ruby/rest/chat/v2/credential.rb', line 225

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