## # This code was generated by # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ # # Twilio - Intelligence # This is the public Twilio REST API. # # NOTE: This class is auto generated by OpenAPI Generator. # https://openapi-generator.tech # Do not edit the class manually. # module Twilio module REST class Intelligence < IntelligenceBase class V2 < Version class TranscriptList < ListResource ## # Initialize the TranscriptList # @param [Version] version Version that contains the resource # @return [TranscriptList] TranscriptList def initialize(version) super(version) # Path Solution @solution = { } @uri = "/Transcripts" end ## # Create the TranscriptInstance # @param [String] service_sid The unique SID identifier of the Service. # @param [Object] channel JSON object describing Media Channel including Source and Participants # @param [String] customer_key Used to store client provided metadata. Maximum of 64 double-byte UTF8 characters. # @param [Time] media_start_time The date that this Transcript's media was started, given in ISO 8601 format. # @return [TranscriptInstance] Created TranscriptInstance def create( service_sid: nil, channel: nil, customer_key: :unset, media_start_time: :unset ) data = Twilio::Values.of({ 'ServiceSid' => service_sid, 'Channel' => Twilio.serialize_object(channel), 'CustomerKey' => customer_key, 'MediaStartTime' => Twilio.serialize_iso8601_datetime(media_start_time), }) payload = @version.create('POST', @uri, data: data) TranscriptInstance.new( @version, payload, ) end ## # Lists TranscriptInstance records from the API as a list. # Unlike stream(), this operation is eager and will load `limit` records into # memory before returning. # @param [String] service_sid The unique SID identifier of the Service. # @param [String] before_start_time Filter by before StartTime. # @param [String] after_start_time Filter by after StartTime. # @param [String] before_date_created Filter by before DateCreated. # @param [String] after_date_created Filter by after DateCreated. # @param [String] status Filter by status. # @param [String] language_code Filter by Language Code. # @param [String] source_sid Filter by SourceSid. # @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 def list(service_sid: :unset, before_start_time: :unset, after_start_time: :unset, before_date_created: :unset, after_date_created: :unset, status: :unset, language_code: :unset, source_sid: :unset, limit: nil, page_size: nil) self.stream( service_sid: service_sid, before_start_time: before_start_time, after_start_time: after_start_time, before_date_created: before_date_created, after_date_created: after_date_created, status: status, language_code: language_code, source_sid: source_sid, limit: limit, page_size: page_size ).entries end ## # Streams Instance records from the API as an Enumerable. # This operation lazily loads records as efficiently as possible until the limit # is reached. # @param [String] service_sid The unique SID identifier of the Service. # @param [String] before_start_time Filter by before StartTime. # @param [String] after_start_time Filter by after StartTime. # @param [String] before_date_created Filter by before DateCreated. # @param [String] after_date_created Filter by after DateCreated. # @param [String] status Filter by status. # @param [String] language_code Filter by Language Code. # @param [String] source_sid Filter by SourceSid. # @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 def stream(service_sid: :unset, before_start_time: :unset, after_start_time: :unset, before_date_created: :unset, after_date_created: :unset, status: :unset, language_code: :unset, source_sid: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page( service_sid: service_sid, before_start_time: before_start_time, after_start_time: after_start_time, before_date_created: before_date_created, after_date_created: after_date_created, status: status, language_code: language_code, source_sid: source_sid, page_size: limits[:page_size], ) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end ## # When passed a block, yields TranscriptInstance records from the API. # This operation lazily loads records as efficiently as possible until the limit # is reached. 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 TranscriptInstance records from the API. # Request is executed immediately. # @param [String] service_sid The unique SID identifier of the Service. # @param [String] before_start_time Filter by before StartTime. # @param [String] after_start_time Filter by after StartTime. # @param [String] before_date_created Filter by before DateCreated. # @param [String] after_date_created Filter by after DateCreated. # @param [String] status Filter by status. # @param [String] language_code Filter by Language Code. # @param [String] source_sid Filter by SourceSid. # @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 TranscriptInstance def page(service_sid: :unset, before_start_time: :unset, after_start_time: :unset, before_date_created: :unset, after_date_created: :unset, status: :unset, language_code: :unset, source_sid: :unset, page_token: :unset, page_number: :unset, page_size: :unset) params = Twilio::Values.of({ 'ServiceSid' => service_sid, 'BeforeStartTime' => before_start_time, 'AfterStartTime' => after_start_time, 'BeforeDateCreated' => before_date_created, 'AfterDateCreated' => after_date_created, 'Status' => status, 'LanguageCode' => language_code, 'SourceSid' => source_sid, 'PageToken' => page_token, 'Page' => page_number, 'PageSize' => page_size, }) response = @version.page('GET', @uri, params: params) TranscriptPage.new(@version, response, @solution) end ## # Retrieve a single page of TranscriptInstance records from the API. # Request is executed immediately. # @param [String] target_url API-generated URL for the requested results page # @return [Page] Page of TranscriptInstance def get_page(target_url) response = @version.domain.request( 'GET', target_url ) TranscriptPage.new(@version, response, @solution) end # Provide a user friendly representation def to_s '#' end end ## #PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. class TranscriptContext < InstanceContext ## # Initialize the TranscriptContext # @param [Version] version Version that contains the resource # @param [String] sid A 34 character string that uniquely identifies this Transcript. # @return [TranscriptContext] TranscriptContext def initialize(version, sid) super(version) # Path Solution @solution = { sid: sid, } @uri = "/Transcripts/#{@solution[:sid]}" # Dependents @sentences = nil @operator_results = nil @media = nil end ## # Delete the TranscriptInstance # @return [Boolean] True if delete succeeds, false otherwise def delete @version.delete('DELETE', @uri) end ## # Fetch the TranscriptInstance # @param [Boolean] redacted Grant access to PII Redacted/Unredacted Transcript. The default is `true` to access redacted Transcript. # @return [TranscriptInstance] Fetched TranscriptInstance def fetch( redacted: :unset ) params = Twilio::Values.of({ 'Redacted' => redacted, }) payload = @version.fetch('GET', @uri, params: params) TranscriptInstance.new( @version, payload, sid: @solution[:sid], ) end ## # Access the sentences # @return [SentenceList] # @return [SentenceContext] def sentences unless @sentences @sentences = SentenceList.new( @version, transcript_sid: @solution[:sid], ) end @sentences end ## # Access the operator_results # @return [OperatorResultList] # @return [OperatorResultContext] if sid was passed. def operator_results(operator_sid=:unset) raise ArgumentError, 'operator_sid cannot be nil' if operator_sid.nil? if operator_sid != :unset return OperatorResultContext.new(@version, @solution[:sid],operator_sid ) end unless @operator_results @operator_results = OperatorResultList.new( @version, transcript_sid: @solution[:sid], ) end @operator_results end ## # Access the media # @return [MediaList] # @return [MediaContext] def media MediaContext.new( @version, @solution[:sid] ) 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 TranscriptPage < Page ## # Initialize the TranscriptPage # @param [Version] version Version that contains the resource # @param [Response] response Response from the API # @param [Hash] solution Path solution for the resource # @return [TranscriptPage] TranscriptPage def initialize(version, response, solution) super(version, response) # Path Solution @solution = solution end ## # Build an instance of TranscriptInstance # @param [Hash] payload Payload response from the API # @return [TranscriptInstance] TranscriptInstance def get_instance(payload) TranscriptInstance.new(@version, payload) end ## # Provide a user friendly representation def to_s '' end end class TranscriptInstance < InstanceResource ## # Initialize the TranscriptInstance # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio # @param [String] account_sid The SID of the # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Transcript # resource. # @param [String] sid The SID of the Call resource to fetch. # @return [TranscriptInstance] TranscriptInstance def initialize(version, payload , sid: nil) super(version) # Marshaled Properties @properties = { 'account_sid' => payload['account_sid'], 'service_sid' => payload['service_sid'], 'sid' => payload['sid'], 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), 'status' => payload['status'], 'channel' => payload['channel'], 'data_logging' => payload['data_logging'], 'language_code' => payload['language_code'], 'customer_key' => payload['customer_key'], 'media_start_time' => Twilio.deserialize_iso8601_datetime(payload['media_start_time']), 'duration' => payload['duration'] == nil ? payload['duration'] : payload['duration'].to_i, 'url' => payload['url'], 'redaction' => payload['redaction'], '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 [TranscriptContext] CallContext for this CallInstance def context unless @instance_context @instance_context = TranscriptContext.new(@version , @params['sid']) end @instance_context end ## # @return [String] The unique SID identifier of the Account. def account_sid @properties['account_sid'] end ## # @return [String] The unique SID identifier of the Service. def service_sid @properties['service_sid'] end ## # @return [String] A 34 character string that uniquely identifies this Transcript. def sid @properties['sid'] end ## # @return [Time] The date that this Transcript was created, given in ISO 8601 format. def date_created @properties['date_created'] end ## # @return [Time] The date that this Transcript was updated, given in ISO 8601 format. def date_updated @properties['date_updated'] end ## # @return [Status] def status @properties['status'] end ## # @return [Hash] Media Channel describing Transcript Source and Participant Mapping def channel @properties['channel'] end ## # @return [Boolean] Data logging allows Twilio to improve the quality of the speech recognition through using customer data to refine its speech recognition models. def data_logging @properties['data_logging'] end ## # @return [String] The default language code of the audio. def language_code @properties['language_code'] end ## # @return [String] def customer_key @properties['customer_key'] end ## # @return [Time] The date that this Transcript's media was started, given in ISO 8601 format. def media_start_time @properties['media_start_time'] end ## # @return [String] The duration of this Transcript's source def duration @properties['duration'] end ## # @return [String] The URL of this resource. def url @properties['url'] end ## # @return [Boolean] If the transcript has been redacted, a redacted alternative of the transcript will be available. def redaction @properties['redaction'] end ## # @return [Hash] def links @properties['links'] end ## # Delete the TranscriptInstance # @return [Boolean] True if delete succeeds, false otherwise def delete context.delete end ## # Fetch the TranscriptInstance # @param [Boolean] redacted Grant access to PII Redacted/Unredacted Transcript. The default is `true` to access redacted Transcript. # @return [TranscriptInstance] Fetched TranscriptInstance def fetch( redacted: :unset ) context.fetch( redacted: redacted, ) end ## # Access the sentences # @return [sentences] sentences def sentences context.sentences end ## # Access the operator_results # @return [operator_results] operator_results def operator_results context.operator_results end ## # Access the media # @return [media] media def media context.media 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