class Twilio::REST::Notify::V1::ServiceList
PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
Public Class Methods
Initialize the ServiceList
@param [Version] version Version
that contains the resource @return [ServiceList] ServiceList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/notify/v1/service.rb 20 def initialize(version) 21 super(version) 22 23 # Path Solution 24 @solution = {} 25 @uri = "/Services" 26 end
Public Instance Methods
Create the ServiceInstance
@param [String] friendly_name A descriptive string that you create to describe
the resource. It can be up to 64 characters long.
@param [String] apn_credential_sid The SID of the
{Credential}[https://www.twilio.com/docs/notify/api/credential-resource] to use for APN Bindings.
@param [String] gcm_credential_sid The SID of the
{Credential}[https://www.twilio.com/docs/notify/api/credential-resource] to use for GCM Bindings.
@param [String] messaging_service_sid The SID of the {Messaging
Service}[https://www.twilio.com/docs/sms/send-messages#messaging-services] to use for SMS Bindings. This parameter must be set in order to send SMS notifications.
@param [String] facebook_messenger_page_id Deprecated. @param [String] default_apn_notification_protocol_version The protocol version
to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a {Binding}[https://www.twilio.com/docs/notify/api/binding-resource] resource.
@param [String] default_gcm_notification_protocol_version The protocol version
to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a {Binding}[https://www.twilio.com/docs/notify/api/binding-resource] resource.
@param [String] fcm_credential_sid The SID of the
{Credential}[https://www.twilio.com/docs/notify/api/credential-resource] to use for FCM Bindings.
@param [String] default_fcm_notification_protocol_version The protocol version
to use for sending FCM notifications. Can be overridden on a Binding by Binding basis when creating a {Binding}[https://www.twilio.com/docs/notify/api/binding-resource] resource.
@param [Boolean] log_enabled Whether to log notifications. Can be: `true` or
`false` and the default is `true`.
@param [String] alexa_skill_id Deprecated. @param [String] default_alexa_notification_protocol_version Deprecated. @param [String] delivery_callback_url URL to send delivery status callback. @param [Boolean] delivery_callback_enabled Callback configuration that enables
delivery callbacks, default false
@return [ServiceInstance] Created ServiceInstance
# File lib/twilio-ruby/rest/notify/v1/service.rb 66 def create(friendly_name: :unset, apn_credential_sid: :unset, gcm_credential_sid: :unset, messaging_service_sid: :unset, facebook_messenger_page_id: :unset, default_apn_notification_protocol_version: :unset, default_gcm_notification_protocol_version: :unset, fcm_credential_sid: :unset, default_fcm_notification_protocol_version: :unset, log_enabled: :unset, alexa_skill_id: :unset, default_alexa_notification_protocol_version: :unset, delivery_callback_url: :unset, delivery_callback_enabled: :unset) 67 data = Twilio::Values.of({ 68 'FriendlyName' => friendly_name, 69 'ApnCredentialSid' => apn_credential_sid, 70 'GcmCredentialSid' => gcm_credential_sid, 71 'MessagingServiceSid' => messaging_service_sid, 72 'FacebookMessengerPageId' => facebook_messenger_page_id, 73 'DefaultApnNotificationProtocolVersion' => default_apn_notification_protocol_version, 74 'DefaultGcmNotificationProtocolVersion' => default_gcm_notification_protocol_version, 75 'FcmCredentialSid' => fcm_credential_sid, 76 'DefaultFcmNotificationProtocolVersion' => default_fcm_notification_protocol_version, 77 'LogEnabled' => log_enabled, 78 'AlexaSkillId' => alexa_skill_id, 79 'DefaultAlexaNotificationProtocolVersion' => default_alexa_notification_protocol_version, 80 'DeliveryCallbackUrl' => delivery_callback_url, 81 'DeliveryCallbackEnabled' => delivery_callback_enabled, 82 }) 83 84 payload = @version.create('POST', @uri, data: data) 85 86 ServiceInstance.new(@version, payload, ) 87 end
When passed a block, yields ServiceInstance
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/service.rb 131 def each 132 limits = @version.read_limits 133 134 page = self.page(page_size: limits[:page_size], ) 135 136 @version.stream(page, 137 limit: limits[:limit], 138 page_limit: limits[:page_limit]).each {|x| yield x} 139 end
Retrieve a single page of ServiceInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of ServiceInstance
# File lib/twilio-ruby/rest/notify/v1/service.rb 168 def get_page(target_url) 169 response = @version.domain.request( 170 'GET', 171 target_url 172 ) 173 ServicePage.new(@version, response, @solution) 174 end
Lists ServiceInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] friendly_name The string that identifies the Service resources
to read.
@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/service.rb 102 def list(friendly_name: :unset, limit: nil, page_size: nil) 103 self.stream(friendly_name: friendly_name, limit: limit, page_size: page_size).entries 104 end
Retrieve a single page of ServiceInstance
records from the API. Request
is executed immediately. @param [String] friendly_name The string that identifies the Service resources
to read.
@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 ServiceInstance
# File lib/twilio-ruby/rest/notify/v1/service.rb 150 def page(friendly_name: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 151 params = Twilio::Values.of({ 152 'FriendlyName' => friendly_name, 153 'PageToken' => page_token, 154 'Page' => page_number, 155 'PageSize' => page_size, 156 }) 157 158 response = @version.page('GET', @uri, params: params) 159 160 ServicePage.new(@version, response, @solution) 161 end
Streams ServiceInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] friendly_name The string that identifies the Service resources
to read.
@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/service.rb 119 def stream(friendly_name: :unset, limit: nil, page_size: nil) 120 limits = @version.read_limits(limit, page_size) 121 122 page = self.page(friendly_name: friendly_name, page_size: limits[:page_size], ) 123 124 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 125 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/notify/v1/service.rb 178 def to_s 179 '#<Twilio.Notify.V1.ServiceList>' 180 end