Class: Twilio::REST::Chat::V1::CredentialContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/chat/v1/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



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

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



247
248
249
# File 'lib/twilio-ruby/rest/chat/v1/credential.rb', line 247

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

#fetchCredentialInstance

Fetch a CredentialInstance

Returns:



198
199
200
201
202
203
204
205
206
207
208
# File 'lib/twilio-ruby/rest/chat/v1/credential.rb', line 198

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



253
254
255
256
# File 'lib/twilio-ruby/rest/chat/v1/credential.rb', line 253

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Chat.V1.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)

    Friendly name for stored credential

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

    URL encoded representation of the

    certificate, e.g. ‘—–BEGIN CERTIFICATE—–MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.….A==—–END CERTIFICATE—–`

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

    URL encoded representation of the private

    key, e.g. ‘—–BEGIN RSA PRIVATE KEY—–MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieRn.—–END RSA PRIVATE KEY—–`

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

    use this credential for sending to

    production or sandbox APNs (string ‘true` or `false`)

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

    This is the “API key” for project from Google

    Developer console for your GCM Service application credential

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

    The secret

Returns:



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/twilio-ruby/rest/chat/v1/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