Class: Twilio::REST::Notify::V1::CredentialContext

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

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ CredentialContext

Initialize the CredentialContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The Twilio-provided string that uniquely identifies the Credential resource to update.



171
172
173
174
175
176
177
178
179
# File 'lib/twilio-ruby/rest/notify/v1/credential.rb', line 171

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



183
184
185
186
# File 'lib/twilio-ruby/rest/notify/v1/credential.rb', line 183

def delete

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

#fetchCredentialInstance

Fetch the CredentialInstance

Returns:



191
192
193
194
195
196
197
198
199
# File 'lib/twilio-ruby/rest/notify/v1/credential.rb', line 191

def fetch

    payload = @version.fetch('GET', @uri)
    CredentialInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#to_sObject

Provide a user friendly representation



239
240
241
242
# File 'lib/twilio-ruby/rest/notify/v1/credential.rb', line 239

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

    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. Strip everything outside of the headers, e.g. ‘—–BEGIN CERTIFICATE—–MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.….A==—–END CERTIFICATE—–`

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

    The URL-encoded representation of the private key. Strip everything outside of the headers, e.g. ‘—–BEGIN RSA PRIVATE KEY—–MIIEpQIBAAKCAQEAuyf/lNrH9ck8DmNyo3fGgvCI1l9s+cmBY3WIz+cUDqmxiieR\\n.—–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 ‘Server key` of your project from Firebase console under Settings / Cloud messaging.

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

    The ‘Server key` of your project from Firebase console under Settings / Cloud messaging.

Returns:



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/twilio-ruby/rest/notify/v1/credential.rb', line 210

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