class Twilio::REST::Notify::V1::CredentialList
PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
Public Class Methods
Initialize the CredentialList
@param [Version] version Version
that contains the resource @return [CredentialList] CredentialList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/notify/v1/credential.rb 20 def initialize(version) 21 super(version) 22 23 # Path Solution 24 @solution = {} 25 @uri = "/Credentials" 26 end
Public Instance Methods
Create the CredentialInstance
@param [credential.PushService] type The Credential type. Can be: `gcm`, `fcm`,
or `apn`.
@param [String] friendly_name A descriptive string that you create to describe
the resource. It can be up to 64 characters long.
@param [String] certificate [APN only] The URL-encoded representation of the
certificate. Strip everything outside of the headers, e.g. `-----BEGIN CERTIFICATE-----MIIFnTCCBIWgAwIBAgIIAjy9H849+E8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV.....A==-----END CERTIFICATE-----`
@param [String] private_key [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-----`
@param [Boolean] sandbox [APN only] Whether to send the credential to sandbox
APNs. Can be `true` to send to sandbox APNs or `false` to send to production.
@param [String] api_key [GCM only] The `Server key` of your project from
Firebase console under Settings / Cloud messaging.
@param [String] secret [FCM only] The `Server key` of your project from Firebase
console under Settings / Cloud messaging.
@return [CredentialInstance] Created CredentialInstance
# File lib/twilio-ruby/rest/notify/v1/credential.rb 130 def create(type: nil, friendly_name: :unset, certificate: :unset, private_key: :unset, sandbox: :unset, api_key: :unset, secret: :unset) 131 data = Twilio::Values.of({ 132 'Type' => type, 133 'FriendlyName' => friendly_name, 134 'Certificate' => certificate, 135 'PrivateKey' => private_key, 136 'Sandbox' => sandbox, 137 'ApiKey' => api_key, 138 'Secret' => secret, 139 }) 140 141 payload = @version.create('POST', @uri, data: data) 142 143 CredentialInstance.new(@version, payload, ) 144 end
When passed a block, yields CredentialInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/notify/v1/credential.rb 66 def each 67 limits = @version.read_limits 68 69 page = self.page(page_size: limits[:page_size], ) 70 71 @version.stream(page, 72 limit: limits[:limit], 73 page_limit: limits[:page_limit]).each {|x| yield x} 74 end
Retrieve a single page of CredentialInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of CredentialInstance
# File lib/twilio-ruby/rest/notify/v1/credential.rb 100 def get_page(target_url) 101 response = @version.domain.request( 102 'GET', 103 target_url 104 ) 105 CredentialPage.new(@version, response, @solution) 106 end
Lists CredentialInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Integer] limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
@param [Integer] page_size Number of records to fetch per request, when
not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)
@return [Array] Array of up to limit results
# File lib/twilio-ruby/rest/notify/v1/credential.rb 39 def list(limit: nil, page_size: nil) 40 self.stream(limit: limit, page_size: page_size).entries 41 end
Retrieve a single page of CredentialInstance
records from the API. Request
is executed immediately. @param [String] page_token PageToken provided by the API @param [Integer] page_number Page
Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page
of CredentialInstance
# File lib/twilio-ruby/rest/notify/v1/credential.rb 83 def page(page_token: :unset, page_number: :unset, page_size: :unset) 84 params = Twilio::Values.of({ 85 'PageToken' => page_token, 86 'Page' => page_number, 87 'PageSize' => page_size, 88 }) 89 90 response = @version.page('GET', @uri, params: params) 91 92 CredentialPage.new(@version, response, @solution) 93 end
Streams CredentialInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Integer] limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit.
@param [Integer] page_size Number of records to fetch per request, when
not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)
@return [Enumerable] Enumerable that will yield up to limit results
# File lib/twilio-ruby/rest/notify/v1/credential.rb 54 def stream(limit: nil, page_size: nil) 55 limits = @version.read_limits(limit, page_size) 56 57 page = self.page(page_size: limits[:page_size], ) 58 59 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 60 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/notify/v1/credential.rb 148 def to_s 149 '#<Twilio.Notify.V1.CredentialList>' 150 end