1// Copyright 2019 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// Code generated by gapic-generator. DO NOT EDIT.
16
17package dialogflow_test
18
19import (
20	"context"
21	"io"
22
23	dialogflow "cloud.google.com/go/dialogflow/apiv2"
24	dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2"
25)
26
27func ExampleNewSessionsClient() {
28	ctx := context.Background()
29	c, err := dialogflow.NewSessionsClient(ctx)
30	if err != nil {
31		// TODO: Handle error.
32	}
33	// TODO: Use client.
34	_ = c
35}
36
37func ExampleSessionsClient_DetectIntent() {
38	ctx := context.Background()
39	c, err := dialogflow.NewSessionsClient(ctx)
40	if err != nil {
41		// TODO: Handle error.
42	}
43
44	req := &dialogflowpb.DetectIntentRequest{
45		// TODO: Fill request struct fields.
46	}
47	resp, err := c.DetectIntent(ctx, req)
48	if err != nil {
49		// TODO: Handle error.
50	}
51	// TODO: Use resp.
52	_ = resp
53}
54
55func ExampleSessionsClient_StreamingDetectIntent() {
56	ctx := context.Background()
57	c, err := dialogflow.NewSessionsClient(ctx)
58	if err != nil {
59		// TODO: Handle error.
60	}
61	stream, err := c.StreamingDetectIntent(ctx)
62	if err != nil {
63		// TODO: Handle error.
64	}
65	go func() {
66		reqs := []*dialogflowpb.StreamingDetectIntentRequest{
67			// TODO: Create requests.
68		}
69		for _, req := range reqs {
70			if err := stream.Send(req); err != nil {
71				// TODO: Handle error.
72			}
73		}
74		stream.CloseSend()
75	}()
76	for {
77		resp, err := stream.Recv()
78		if err == io.EOF {
79			break
80		}
81		if err != nil {
82			// TODO: handle error.
83		}
84		// TODO: Use resp.
85		_ = resp
86	}
87}
88