class Twilio::REST::Proxy::V1::ServiceContext
PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
Public Class Methods
Initialize the ServiceContext
@param [Version] version Version
that contains the resource @param [String] sid The Twilio-provided string that uniquely identifies the
Service resource to fetch.
@return [ServiceContext] ServiceContext
Twilio::REST::InstanceContext::new
# File lib/twilio-ruby/rest/proxy/v1/service.rb 213 def initialize(version, sid) 214 super(version) 215 216 # Path Solution 217 @solution = {sid: sid, } 218 @uri = "/Services/#{@solution[:sid]}" 219 220 # Dependents 221 @sessions = nil 222 @phone_numbers = nil 223 @short_codes = nil 224 end
Public Instance Methods
Delete the ServiceInstance
@return [Boolean] true if delete succeeds, false otherwise
# File lib/twilio-ruby/rest/proxy/v1/service.rb 238 def delete 239 @version.delete('DELETE', @uri) 240 end
Fetch the ServiceInstance
@return [ServiceInstance] Fetched ServiceInstance
# File lib/twilio-ruby/rest/proxy/v1/service.rb 229 def fetch 230 payload = @version.fetch('GET', @uri) 231 232 ServiceInstance.new(@version, payload, sid: @solution[:sid], ) 233 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/proxy/v1/service.rb 363 def inspect 364 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 365 "#<Twilio.Proxy.V1.ServiceContext #{context}>" 366 end
Access the phone_numbers
@return [PhoneNumberList] @return [PhoneNumberContext] if sid was passed.
# File lib/twilio-ruby/rest/proxy/v1/service.rb 322 def phone_numbers(sid=:unset) 323 raise ArgumentError, 'sid cannot be nil' if sid.nil? 324 325 if sid != :unset 326 return PhoneNumberContext.new(@version, @solution[:sid], sid, ) 327 end 328 329 unless @phone_numbers 330 @phone_numbers = PhoneNumberList.new(@version, service_sid: @solution[:sid], ) 331 end 332 333 @phone_numbers 334 end
Access the sessions @return [SessionList] @return [SessionContext] if sid was passed.
# File lib/twilio-ruby/rest/proxy/v1/service.rb 304 def sessions(sid=:unset) 305 raise ArgumentError, 'sid cannot be nil' if sid.nil? 306 307 if sid != :unset 308 return SessionContext.new(@version, @solution[:sid], sid, ) 309 end 310 311 unless @sessions 312 @sessions = SessionList.new(@version, service_sid: @solution[:sid], ) 313 end 314 315 @sessions 316 end
Access the short_codes
@return [ShortCodeList] @return [ShortCodeContext] if sid was passed.
# File lib/twilio-ruby/rest/proxy/v1/service.rb 340 def short_codes(sid=:unset) 341 raise ArgumentError, 'sid cannot be nil' if sid.nil? 342 343 if sid != :unset 344 return ShortCodeContext.new(@version, @solution[:sid], sid, ) 345 end 346 347 unless @short_codes 348 @short_codes = ShortCodeList.new(@version, service_sid: @solution[:sid], ) 349 end 350 351 @short_codes 352 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/proxy/v1/service.rb 356 def to_s 357 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 358 "#<Twilio.Proxy.V1.ServiceContext #{context}>" 359 end
Update the ServiceInstance
@param [String] unique_name An application-defined string that uniquely
identifies the resource. This value must be 191 characters or fewer in length and be unique. **This value should not have PII.**
@param [String] default_ttl The default `ttl` value to set for Sessions created
in the Service. The TTL (time to live) is measured in seconds after the Session's last create or last Interaction. The default value of `0` indicates an unlimited Session length. You can override a Session's default TTL value by setting its `ttl` value.
@param [String] callback_url The URL we should call when the interaction status
changes.
@param [service.GeoMatchLevel] geo_match_level Where a proxy number must be
located relative to the participant identifier. Can be: `country`, `area-code`, or `extended-area-code`. The default value is `country` and more specific areas than `country` are only available in North America.
@param [service.NumberSelectionBehavior] number_selection_behavior The
preference for Proxy Number selection in the Service instance. Can be: `prefer-sticky` or `avoid-sticky` and the default is `prefer-sticky`. `prefer-sticky` means that we will try and select the same Proxy Number for a given participant if they have previous {Sessions}[https://www.twilio.com/docs/proxy/api/session], but we will not fail if that Proxy Number cannot be used. `avoid-sticky` means that we will try to use different Proxy Numbers as long as that is possible within a given pool rather than try and use a previously assigned number.
@param [String] intercept_callback_url The URL we call on each interaction. If
we receive a 403 status, we block the interaction; otherwise the interaction continues.
@param [String] out_of_session_callback_url The URL we should call when an
inbound call or SMS action occurs on a closed or non-existent Session. If your server (or a Twilio {function}[https://www.twilio.com/functions]) responds with valid {TwiML}[https://www.twilio.com/docs/voice/twiml], we will process it. This means it is possible, for example, to play a message for a call, send an automated text message response, or redirect a call to another Phone Number. See {Out-of-Session Callback Response Guide}[https://www.twilio.com/docs/proxy/out-session-callback-response-guide] for more information.
@param [String] chat_instance_sid The SID of the Chat
Service Instance managed
by Proxy Service. The Chat Service enables Proxy to forward SMS and channel messages to this chat instance. This is a one-to-one relationship.
@return [ServiceInstance] Updated ServiceInstance
# File lib/twilio-ruby/rest/proxy/v1/service.rb 283 def update(unique_name: :unset, default_ttl: :unset, callback_url: :unset, geo_match_level: :unset, number_selection_behavior: :unset, intercept_callback_url: :unset, out_of_session_callback_url: :unset, chat_instance_sid: :unset) 284 data = Twilio::Values.of({ 285 'UniqueName' => unique_name, 286 'DefaultTtl' => default_ttl, 287 'CallbackUrl' => callback_url, 288 'GeoMatchLevel' => geo_match_level, 289 'NumberSelectionBehavior' => number_selection_behavior, 290 'InterceptCallbackUrl' => intercept_callback_url, 291 'OutOfSessionCallbackUrl' => out_of_session_callback_url, 292 'ChatInstanceSid' => chat_instance_sid, 293 }) 294 295 payload = @version.update('POST', @uri, data: data) 296 297 ServiceInstance.new(@version, payload, sid: @solution[:sid], ) 298 end