## # This code was generated by # \ / _ _ _| _ _ # | (_)\/(_)(_|\/| |(/_ v1.0.0 # / / # # frozen_string_literal: true module Twilio module REST class FlexApi < Domain class V1 < Version class InteractionList < ListResource ## # Initialize the InteractionList # @param [Version] version Version that contains the resource # @return [InteractionList] InteractionList def initialize(version) super(version) # Path Solution @solution = {} @uri = "/Interactions" end ## # Create the InteractionInstance # @param [Hash] channel The Interaction's channel. # @param [Hash] routing The Interaction's routing logic. # @return [InteractionInstance] Created InteractionInstance def create(channel: nil, routing: nil) data = Twilio::Values.of({ 'Channel' => Twilio.serialize_object(channel), 'Routing' => Twilio.serialize_object(routing), }) payload = @version.create('POST', @uri, data: data) InteractionInstance.new(@version, payload, ) end ## # Provide a user friendly representation def to_s '#' end end class InteractionPage < Page ## # Initialize the InteractionPage # @param [Version] version Version that contains the resource # @param [Response] response Response from the API # @param [Hash] solution Path solution for the resource # @return [InteractionPage] InteractionPage def initialize(version, response, solution) super(version, response) # Path Solution @solution = solution end ## # Build an instance of InteractionInstance # @param [Hash] payload Payload response from the API # @return [InteractionInstance] InteractionInstance def get_instance(payload) InteractionInstance.new(@version, payload, ) end ## # Provide a user friendly representation def to_s '' end end class InteractionContext < InstanceContext ## # Initialize the InteractionContext # @param [Version] version Version that contains the resource # @param [String] sid The SID of the Interaction resource to fetch. # @return [InteractionContext] InteractionContext def initialize(version, sid) super(version) # Path Solution @solution = {sid: sid, } @uri = "/Interactions/#{@solution[:sid]}" # Dependents @channels = nil end ## # Fetch the InteractionInstance # @return [InteractionInstance] Fetched InteractionInstance def fetch payload = @version.fetch('GET', @uri) InteractionInstance.new(@version, payload, sid: @solution[:sid], ) end ## # Access the channels # @return [InteractionChannelList] # @return [InteractionChannelContext] if sid was passed. def channels(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return InteractionChannelContext.new(@version, @solution[:sid], sid, ) end unless @channels @channels = InteractionChannelList.new(@version, interaction_sid: @solution[:sid], ) end @channels end ## # Provide a user friendly representation def to_s context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') "#" end ## # Provide a detailed, user friendly representation def inspect context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') "#" end end class InteractionInstance < InstanceResource ## # Initialize the InteractionInstance # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio # @param [String] sid The SID of the Interaction resource to fetch. # @return [InteractionInstance] InteractionInstance def initialize(version, payload, sid: nil) super(version) # Marshaled Properties @properties = { 'sid' => payload['sid'], 'channel' => payload['channel'], 'routing' => payload['routing'], 'url' => payload['url'], 'links' => payload['links'], } # Context @instance_context = nil @params = {'sid' => sid || @properties['sid'], } end ## # Generate an instance context for the instance, the context is capable of # performing various actions. All instance actions are proxied to the context # @return [InteractionContext] InteractionContext for this InteractionInstance def context unless @instance_context @instance_context = InteractionContext.new(@version, @params['sid'], ) end @instance_context end ## # @return [String] The unique string that identifies the resource def sid @properties['sid'] end ## # @return [Hash] The Interaction's channel def channel @properties['channel'] end ## # @return [Hash] The Interaction's routing logic def routing @properties['routing'] end ## # @return [String] The url def url @properties['url'] end ## # @return [String] The links def links @properties['links'] end ## # Fetch the InteractionInstance # @return [InteractionInstance] Fetched InteractionInstance def fetch context.fetch end ## # Access the channels # @return [channels] channels def channels context.channels end ## # Provide a user friendly representation def to_s values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") "" end ## # Provide a detailed, user friendly representation def inspect values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") "" end end end end end end