class Twilio::REST::Notify::V1::ServiceContext::BindingList
PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
Public Class Methods
Initialize the BindingList
@param [Version] version Version
that contains the resource @param [String] service_sid The SID of the
{Service}[https://www.twilio.com/docs/notify/api/service-resource] the resource is associated with.
@return [BindingList] BindingList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/notify/v1/service/binding.rb 24 def initialize(version, service_sid: nil) 25 super(version) 26 27 # Path Solution 28 @solution = {service_sid: service_sid} 29 @uri = "/Services/#{@solution[:service_sid]}/Bindings" 30 end
Public Instance Methods
Create the BindingInstance
@param [String] identity The `identity` value that uniquely identifies the new
resource's {User}[https://www.twilio.com/docs/chat/rest/user-resource] within the {Service}[https://www.twilio.com/docs/notify/api/service-resource]. Up to 20 Bindings can be created for the same Identity in a given Service.
@param [binding.BindingType] binding_type The transport technology to use for
the Binding. Can be: `apn`, `fcm`, `gcm`, `sms`, or `facebook-messenger`.
@param [String] address The channel-specific address. For APNS, the device
token. For FCM and GCM, the registration token. For SMS, a phone number in E.164 format. For Facebook Messenger, the Messenger ID of the user or a phone number in E.164 format.
@param [Array] tag A tag that can be used to select the Bindings to
notify. Repeat this parameter to specify more than one tag, up to a total of 20 tags.
@param [String] notification_protocol_version The protocol version to use to
send the notification. This defaults to the value of `default_xxxx_notification_protocol_version` for the protocol in the {Service}[https://www.twilio.com/docs/notify/api/service-resource]. The current version is `"3"` for `apn`, `fcm`, and `gcm` type Bindings. The parameter is not applicable to `sms` and `facebook-messenger` type Bindings as the data format is fixed.
@param [String] credential_sid The SID of the
{Credential}[https://www.twilio.com/docs/notify/api/credential-resource] resource to be used to send notifications to this Binding. If present, this overrides the Credential specified in the Service resource. Applies to only `apn`, `fcm`, and `gcm` type Bindings.
@param [String] endpoint Deprecated. @return [BindingInstance] Created BindingInstance
# File lib/twilio-ruby/rest/notify/v1/service/binding.rb 61 def create(identity: nil, binding_type: nil, address: nil, tag: :unset, notification_protocol_version: :unset, credential_sid: :unset, endpoint: :unset) 62 data = Twilio::Values.of({ 63 'Identity' => identity, 64 'BindingType' => binding_type, 65 'Address' => address, 66 'Tag' => Twilio.serialize_list(tag) { |e| e }, 67 'NotificationProtocolVersion' => notification_protocol_version, 68 'CredentialSid' => credential_sid, 69 'Endpoint' => endpoint, 70 }) 71 72 payload = @version.create('POST', @uri, data: data) 73 74 BindingInstance.new(@version, payload, service_sid: @solution[:service_sid], ) 75 end
When passed a block, yields BindingInstance
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/binding.rb 148 def each 149 limits = @version.read_limits 150 151 page = self.page(page_size: limits[:page_size], ) 152 153 @version.stream(page, 154 limit: limits[:limit], 155 page_limit: limits[:page_limit]).each {|x| yield x} 156 end
Retrieve a single page of BindingInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of BindingInstance
# File lib/twilio-ruby/rest/notify/v1/service/binding.rb 196 def get_page(target_url) 197 response = @version.domain.request( 198 'GET', 199 target_url 200 ) 201 BindingPage.new(@version, response, @solution) 202 end
Lists BindingInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Date] start_date Only include usage that has occurred on or after this
date. Specify the date in GMT and format as `YYYY-MM-DD`.
@param [Date] end_date Only include usage that occurred on or before this date.
Specify the date in GMT and format as `YYYY-MM-DD`.
@param [Array] identity The
{User}[https://www.twilio.com/docs/chat/rest/user-resource]'s `identity` value of the resources to read.
@param [Array] tag Only list Bindings that have all of the specified
Tags. The following implicit tags are available: `all`, `apn`, `fcm`, `gcm`, `sms`, `facebook-messenger`. Up to 5 tags are allowed.
@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/binding.rb 98 def list(start_date: :unset, end_date: :unset, identity: :unset, tag: :unset, limit: nil, page_size: nil) 99 self.stream( 100 start_date: start_date, 101 end_date: end_date, 102 identity: identity, 103 tag: tag, 104 limit: limit, 105 page_size: page_size 106 ).entries 107 end
Retrieve a single page of BindingInstance
records from the API. Request
is executed immediately. @param [Date] start_date Only include usage that has occurred on or after this
date. Specify the date in GMT and format as `YYYY-MM-DD`.
@param [Date] end_date Only include usage that occurred on or before this date.
Specify the date in GMT and format as `YYYY-MM-DD`.
@param [Array] identity The
{User}[https://www.twilio.com/docs/chat/rest/user-resource]'s `identity` value of the resources to read.
@param [Array] tag Only list Bindings that have all of the specified
Tags. The following implicit tags are available: `all`, `apn`, `fcm`, `gcm`, `sms`, `facebook-messenger`. Up to 5 tags are allowed.
@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 BindingInstance
# File lib/twilio-ruby/rest/notify/v1/service/binding.rb 175 def page(start_date: :unset, end_date: :unset, identity: :unset, tag: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 176 params = Twilio::Values.of({ 177 'StartDate' => Twilio.serialize_iso8601_date(start_date), 178 'EndDate' => Twilio.serialize_iso8601_date(end_date), 179 'Identity' => Twilio.serialize_list(identity) { |e| e }, 180 'Tag' => Twilio.serialize_list(tag) { |e| e }, 181 'PageToken' => page_token, 182 'Page' => page_number, 183 'PageSize' => page_size, 184 }) 185 186 response = @version.page('GET', @uri, params: params) 187 188 BindingPage.new(@version, response, @solution) 189 end
Streams BindingInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Date] start_date Only include usage that has occurred on or after this
date. Specify the date in GMT and format as `YYYY-MM-DD`.
@param [Date] end_date Only include usage that occurred on or before this date.
Specify the date in GMT and format as `YYYY-MM-DD`.
@param [Array] identity The
{User}[https://www.twilio.com/docs/chat/rest/user-resource]'s `identity` value of the resources to read.
@param [Array] tag Only list Bindings that have all of the specified
Tags. The following implicit tags are available: `all`, `apn`, `fcm`, `gcm`, `sms`, `facebook-messenger`. Up to 5 tags are allowed.
@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/binding.rb 130 def stream(start_date: :unset, end_date: :unset, identity: :unset, tag: :unset, limit: nil, page_size: nil) 131 limits = @version.read_limits(limit, page_size) 132 133 page = self.page( 134 start_date: start_date, 135 end_date: end_date, 136 identity: identity, 137 tag: tag, 138 page_size: limits[:page_size], 139 ) 140 141 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 142 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/notify/v1/service/binding.rb 206 def to_s 207 '#<Twilio.Notify.V1.BindingList>' 208 end