lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb in twilio-ruby-5.0.0.rc18 vs lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb in twilio-ruby-5.0.0.rc19

- old
+ new

@@ -1,10 +1,10 @@ ## # This code was generated by # \ / _ _ _| _ _ # | (_)\/(_)(_|\/| |(/_ v1.0.0 -# / / +# / / module Twilio module REST class Taskrouter < Domain class V1 < Version @@ -17,19 +17,19 @@ # @param [String] workspace_sid The workspace_sid # @param [String] worker_sid The worker_sid # @return [ReservationList] ReservationList def initialize(version, workspace_sid: nil, worker_sid: nil) super(version) - + # Path Solution @solution = { workspace_sid: workspace_sid, worker_sid: worker_sid } @uri = "/Workspaces/#{@solution[:workspace_sid]}/Workers/#{@solution[:worker_sid]}/Reservations" end - + ## # Lists ReservationInstance records from the API as a list. # Unlike stream(), this operation is eager and will load `limit` records into # memory before returning. # @param [reservation.Status] reservation_status The reservation_status @@ -45,11 +45,11 @@ reservation_status: reservation_status, limit: limit, page_size: page_size ).entries end - + ## # Streams ReservationInstance records from the API as an Enumerable. # This operation lazily loads records as efficiently as possible until the limit # is reached. # @param [reservation.Status] reservation_status The reservation_status @@ -60,19 +60,19 @@ # 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 def stream(reservation_status: nil, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) - + page = self.page( reservation_status: reservation_status, page_size: limits[:page_size], ) - + @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end - + ## # When passed a block, yields ReservationInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit # is reached. # @param [reservation.Status] reservation_status The reservation_status @@ -82,20 +82,20 @@ # 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) def each limits = @version.read_limits - + page = self.page( page_size: limits[:page_size], ) - + @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]).each {|x| yield x} end - + ## # Retrieve a single page of ReservationInstance records from the API. # Request is executed immediately. # @param [reservation.Status] reservation_status The reservation_status # @param [String] page_token PageToken provided by the API @@ -114,18 +114,18 @@ @uri, params ) return ReservationPage.new(@version, response, @solution) end - + ## # Provide a user friendly representation def to_s '#<Twilio.Taskrouter.V1.ReservationList>' end end - + class ReservationPage < Page ## # Initialize the ReservationPage # @param [Version] version Version that contains the resource # @param [Response] response Response from the API @@ -133,15 +133,15 @@ # @param [String] workspace_sid The workspace_sid # @param [String] worker_sid The worker_sid # @return [ReservationPage] ReservationPage def initialize(version, response, solution) super(version, response) - + # Path Solution @solution = solution end - + ## # Build an instance of ReservationInstance # @param [Hash] payload Payload response from the API # @return [ReservationInstance] ReservationInstance def get_instance(payload) @@ -150,59 +150,59 @@ payload, workspace_sid: @solution[:workspace_sid], worker_sid: @solution[:worker_sid], ) end - + ## # Provide a user friendly representation def to_s '<Twilio.Taskrouter.V1.ReservationPage>' end end - + class ReservationContext < InstanceContext ## # Initialize the ReservationContext # @param [Version] version Version that contains the resource # @param [String] workspace_sid The workspace_sid # @param [String] worker_sid The worker_sid # @param [String] sid The sid # @return [ReservationContext] ReservationContext def initialize(version, workspace_sid, worker_sid, sid) super(version) - + # Path Solution @solution = { workspace_sid: workspace_sid, worker_sid: worker_sid, sid: sid, } @uri = "/Workspaces/#{@solution[:workspace_sid]}/Workers/#{@solution[:worker_sid]}/Reservations/#{@solution[:sid]}" end - + ## # Fetch a ReservationInstance # @return [ReservationInstance] Fetched ReservationInstance def fetch params = {} - + payload = @version.fetch( 'GET', @uri, params, ) - + return ReservationInstance.new( @version, payload, workspace_sid: @solution[:workspace_sid], worker_sid: @solution[:worker_sid], sid: @solution[:sid], ) end - + ## # Update the ReservationInstance # @param [reservation.Status] reservation_status The reservation_status # @param [String] worker_activity_sid The worker_activity_sid # @param [String] instruction The instruction @@ -244,34 +244,34 @@ 'CallAccept' => call_accept, 'RedirectCallSid' => redirect_call_sid, 'RedirectAccept' => redirect_accept, 'RedirectUrl' => redirect_url, } - + payload = @version.update( 'POST', @uri, data: data, ) - + return ReservationInstance.new( @version, payload, workspace_sid: @solution[:workspace_sid], worker_sid: @solution[:worker_sid], sid: @solution[:sid], ) end - + ## # Provide a user friendly representation def to_s context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Taskrouter.V1.ReservationContext #{context}>" end end - + class ReservationInstance < InstanceResource ## # Initialize the ReservationInstance # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio @@ -279,11 +279,11 @@ # @param [String] worker_sid The worker_sid # @param [String] sid The sid # @return [ReservationInstance] ReservationInstance def initialize(version, payload, workspace_sid: nil, worker_sid: nil, sid: nil) super(version) - + # Marshaled Properties @properties = { 'account_sid' => payload['account_sid'], 'date_created' => Twilio.deserialize_iso8601(payload['date_created']), 'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']), @@ -291,21 +291,23 @@ 'sid' => payload['sid'], 'task_sid' => payload['task_sid'], 'worker_name' => payload['worker_name'], 'worker_sid' => payload['worker_sid'], 'workspace_sid' => payload['workspace_sid'], + 'url' => payload['url'], + 'links' => payload['links'], } - + # Context @instance_context = nil @params = { 'workspace_sid' => workspace_sid, 'worker_sid' => worker_sid, '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 # @param [Version] version Version that contains the resource # @return [ReservationContext] ReservationContext for this ReservationInstance @@ -318,54 +320,62 @@ @params['sid'], ) end @instance_context end - + def account_sid @properties['account_sid'] end - + def date_created @properties['date_created'] end - + def date_updated @properties['date_updated'] end - + def reservation_status @properties['reservation_status'] end - + def sid @properties['sid'] end - + def task_sid @properties['task_sid'] end - + def worker_name @properties['worker_name'] end - + def worker_sid @properties['worker_sid'] end - + def workspace_sid @properties['workspace_sid'] end - + + def url + @properties['url'] + end + + def links + @properties['links'] + end + ## # Fetch a ReservationInstance # @return [ReservationInstance] Fetched ReservationInstance def fetch context.fetch end - + ## # Update the ReservationInstance # @param [reservation.Status] reservation_status The reservation_status # @param [String] worker_activity_sid The worker_activity_sid # @param [String] instruction The instruction @@ -408,10 +418,10 @@ redirect_call_sid: redirect_call_sid, redirect_accept: redirect_accept, redirect_url: redirect_url, ) end - + ## # Provide a user friendly representation def to_s values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") "<Twilio.Taskrouter.V1.ReservationInstance #{values}>" \ No newline at end of file