class Twilio::REST::Messaging::V1::ServiceList

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

Public Class Methods

new(version) click to toggle source

Initialize the ServiceList @param [Version] version Version that contains the resource @return [ServiceList] ServiceList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/messaging/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(friendly_name: nil, inbound_request_url: :unset, inbound_method: :unset, fallback_url: :unset, fallback_method: :unset, status_callback: :unset, sticky_sender: :unset, mms_converter: :unset, smart_encoding: :unset, scan_message_content: :unset, fallback_to_long_code: :unset, area_code_geomatch: :unset, validity_period: :unset, synchronous_validation: :unset, use_inbound_webhook_on_number: :unset) click to toggle source

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] inbound_request_url The URL we call using `inbound_method` when

a message is received by any phone number or short code in the Service. When
this property is `null`, receiving inbound messages is disabled. All messages
sent to the Twilio phone number or short code will not be logged and received on
the Account. If the `use_inbound_webhook_on_number` field is enabled then the
webhook url defined on the phone number will override the `inbound_request_url`
defined for the Messaging Service.

@param [String] inbound_method The HTTP method we should use to call

`inbound_request_url`. Can be `GET` or `POST` and the default is `POST`.

@param [String] fallback_url The URL that we call using `fallback_method` if an

error occurs while retrieving or executing the TwiML from the Inbound Request
URL. If the `use_inbound_webhook_on_number` field is enabled then the webhook
url defined on the phone number will override the `fallback_url` defined for the
Messaging Service.

@param [String] fallback_method The HTTP method we should use to call

`fallback_url`. Can be: `GET` or `POST`.

@param [String] status_callback The URL we should call to {pass status

updates}[https://www.twilio.com/docs/sms/api/message-resource#message-status-values]
about message delivery.

@param [Boolean] sticky_sender Whether to enable {Sticky

Sender}[https://www.twilio.com/docs/sms/services#sticky-sender] on the Service
instance.

@param [Boolean] mms_converter Whether to enable the {MMS

Converter}[https://www.twilio.com/docs/sms/services#mms-converter] for messages
sent through the Service instance.

@param [Boolean] smart_encoding Whether to enable {Smart

Encoding}[https://www.twilio.com/docs/sms/services#smart-encoding] for messages
sent through the Service instance.

@param [service.ScanMessageContent] scan_message_content Reserved. @param [Boolean] fallback_to_long_code Whether to enable {Fallback to Long

Code}[https://www.twilio.com/docs/sms/services#fallback-to-long-code] for
messages sent through the Service instance.

@param [Boolean] area_code_geomatch Whether to enable {Area Code

Geomatch}[https://www.twilio.com/docs/sms/services#area-code-geomatch] on the
Service Instance.

@param [String] validity_period How long, in seconds, messages sent from the

Service are valid. Can be an integer from `1` to `14,400`.

@param [Boolean] synchronous_validation Reserved. @param [Boolean] use_inbound_webhook_on_number A boolean value that indicates

either the webhook url configured on the phone number will be used or
`inbound_request_url`/`fallback_url` url will be called when a message is
received from the phone number. If this field is enabled then the webhook url
defined on the phone number will override the
`inbound_request_url`/`fallback_url` defined for the Messaging Service.

@return [ServiceInstance] Created ServiceInstance

   # File lib/twilio-ruby/rest/messaging/v1/service.rb
77 def create(friendly_name: nil, inbound_request_url: :unset, inbound_method: :unset, fallback_url: :unset, fallback_method: :unset, status_callback: :unset, sticky_sender: :unset, mms_converter: :unset, smart_encoding: :unset, scan_message_content: :unset, fallback_to_long_code: :unset, area_code_geomatch: :unset, validity_period: :unset, synchronous_validation: :unset, use_inbound_webhook_on_number: :unset)
78   data = Twilio::Values.of({
79       'FriendlyName' => friendly_name,
80       'InboundRequestUrl' => inbound_request_url,
81       'InboundMethod' => inbound_method,
82       'FallbackUrl' => fallback_url,
83       'FallbackMethod' => fallback_method,
84       'StatusCallback' => status_callback,
85       'StickySender' => sticky_sender,
86       'MmsConverter' => mms_converter,
87       'SmartEncoding' => smart_encoding,
88       'ScanMessageContent' => scan_message_content,
89       'FallbackToLongCode' => fallback_to_long_code,
90       'AreaCodeGeomatch' => area_code_geomatch,
91       'ValidityPeriod' => validity_period,
92       'SynchronousValidation' => synchronous_validation,
93       'UseInboundWebhookOnNumber' => use_inbound_webhook_on_number,
94   })
95 
96   payload = @version.create('POST', @uri, data: data)
97 
98   ServiceInstance.new(@version, payload, )
99 end
each() { |x| ... } click to toggle source

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/messaging/v1/service.rb
139 def each
140   limits = @version.read_limits
141 
142   page = self.page(page_size: limits[:page_size], )
143 
144   @version.stream(page,
145                   limit: limits[:limit],
146                   page_limit: limits[:page_limit]).each {|x| yield x}
147 end
get_page(target_url) click to toggle source

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/messaging/v1/service.rb
173 def get_page(target_url)
174   response = @version.domain.request(
175       'GET',
176       target_url
177   )
178   ServicePage.new(@version, response, @solution)
179 end
list(limit: nil, page_size: nil) click to toggle source

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 [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/messaging/v1/service.rb
112 def list(limit: nil, page_size: nil)
113   self.stream(limit: limit, page_size: page_size).entries
114 end
page(page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of ServiceInstance 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 ServiceInstance

    # File lib/twilio-ruby/rest/messaging/v1/service.rb
156 def page(page_token: :unset, page_number: :unset, page_size: :unset)
157   params = Twilio::Values.of({
158       'PageToken' => page_token,
159       'Page' => page_number,
160       'PageSize' => page_size,
161   })
162 
163   response = @version.page('GET', @uri, params: params)
164 
165   ServicePage.new(@version, response, @solution)
166 end
stream(limit: nil, page_size: nil) click to toggle source

Streams ServiceInstance 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/messaging/v1/service.rb
127 def stream(limit: nil, page_size: nil)
128   limits = @version.read_limits(limit, page_size)
129 
130   page = self.page(page_size: limits[:page_size], )
131 
132   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
133 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/messaging/v1/service.rb
183 def to_s
184   '#<Twilio.Messaging.V1.ServiceList>'
185 end