lib/google/cloud/dialogflow/v2/sessions/client.rb in google-cloud-dialogflow-v2-0.11.4 vs lib/google/cloud/dialogflow/v2/sessions/client.rb in google-cloud-dialogflow-v2-0.11.5
- old
+ new
@@ -242,10 +242,25 @@
#
# @return [::Google::Cloud::Dialogflow::V2::DetectIntentResponse]
#
# @raise [::Google::Cloud::Error] if the RPC is aborted.
#
+ # @example Basic example
+ # require "google/cloud/dialogflow/v2"
+ #
+ # # Create a client object. The client can be reused for multiple calls.
+ # client = Google::Cloud::Dialogflow::V2::Sessions::Client.new
+ #
+ # # Create a request. To set request fields, pass in keyword arguments.
+ # request = Google::Cloud::Dialogflow::V2::DetectIntentRequest.new
+ #
+ # # Call the detect_intent method.
+ # result = client.detect_intent request
+ #
+ # # The returned object is of type Google::Cloud::Dialogflow::V2::DetectIntentResponse.
+ # p result
+ #
def detect_intent request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::DetectIntentRequest
@@ -259,13 +274,15 @@
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
lib_name: @config.lib_name, lib_version: @config.lib_version,
gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
- header_params = {
- "session" => request.session
- }
+ header_params = {}
+ if request.session
+ header_params["session"] = request.session
+ end
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
metadata[:"x-goog-request-params"] ||= request_params_header
options.apply_defaults timeout: @config.rpcs.detect_intent.timeout,
metadata: metadata,
@@ -309,9 +326,33 @@
# @yieldparam operation [::GRPC::ActiveCall::Operation]
#
# @return [::Enumerable<::Google::Cloud::Dialogflow::V2::StreamingDetectIntentResponse>]
#
# @raise [::Google::Cloud::Error] if the RPC is aborted.
+ #
+ # @example Basic example
+ # require "google/cloud/dialogflow/v2"
+ #
+ # # Create a client object. The client can be reused for multiple calls.
+ # client = Google::Cloud::Dialogflow::V2::Sessions::Client.new
+ #
+ # # Create an input stream
+ # input = Gapic::StreamInput.new
+ #
+ # # Call the streaming_detect_intent method to start streaming.
+ # output = client.streaming_detect_intent input
+ #
+ # # Send requests on the stream. For each request, pass in keyword
+ # # arguments to set fields. Be sure to close the stream when done.
+ # input << Google::Cloud::Dialogflow::V2::StreamingDetectIntentRequest.new
+ # input << Google::Cloud::Dialogflow::V2::StreamingDetectIntentRequest.new
+ # input.close
+ #
+ # # Handle streamed responses. These may be interleaved with inputs.
+ # # Each response is of type ::Google::Cloud::Dialogflow::V2::StreamingDetectIntentResponse.
+ # output.each do |response|
+ # p response
+ # end
#
def streaming_detect_intent request, options = nil
unless request.is_a? ::Enumerable
raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
request = request.to_enum