1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 package mybusinessqanda
52
53 import (
54 "bytes"
55 "context"
56 "encoding/json"
57 "errors"
58 "fmt"
59 "io"
60 "net/http"
61 "net/url"
62 "strconv"
63 "strings"
64
65 googleapi "google.golang.org/api/googleapi"
66 internal "google.golang.org/api/internal"
67 gensupport "google.golang.org/api/internal/gensupport"
68 option "google.golang.org/api/option"
69 internaloption "google.golang.org/api/option/internaloption"
70 htransport "google.golang.org/api/transport/http"
71 )
72
73
74
75 var _ = bytes.NewBuffer
76 var _ = strconv.Itoa
77 var _ = fmt.Sprintf
78 var _ = json.NewDecoder
79 var _ = io.Copy
80 var _ = url.Parse
81 var _ = gensupport.MarshalJSON
82 var _ = googleapi.Version
83 var _ = errors.New
84 var _ = strings.Replace
85 var _ = context.Canceled
86 var _ = internaloption.WithDefaultEndpoint
87 var _ = internal.Version
88
89 const apiId = "mybusinessqanda:v1"
90 const apiName = "mybusinessqanda"
91 const apiVersion = "v1"
92 const basePath = "https://mybusinessqanda.googleapis.com/"
93 const basePathTemplate = "https://mybusinessqanda.UNIVERSE_DOMAIN/"
94 const mtlsBasePath = "https://mybusinessqanda.mtls.googleapis.com/"
95
96
97 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
98 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
99 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
100 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
101 opts = append(opts, internaloption.EnableNewAuthLibrary())
102 client, endpoint, err := htransport.NewClient(ctx, opts...)
103 if err != nil {
104 return nil, err
105 }
106 s, err := New(client)
107 if err != nil {
108 return nil, err
109 }
110 if endpoint != "" {
111 s.BasePath = endpoint
112 }
113 return s, nil
114 }
115
116
117
118
119
120
121 func New(client *http.Client) (*Service, error) {
122 if client == nil {
123 return nil, errors.New("client is nil")
124 }
125 s := &Service{client: client, BasePath: basePath}
126 s.Locations = NewLocationsService(s)
127 return s, nil
128 }
129
130 type Service struct {
131 client *http.Client
132 BasePath string
133 UserAgent string
134
135 Locations *LocationsService
136 }
137
138 func (s *Service) userAgent() string {
139 if s.UserAgent == "" {
140 return googleapi.UserAgent
141 }
142 return googleapi.UserAgent + " " + s.UserAgent
143 }
144
145 func NewLocationsService(s *Service) *LocationsService {
146 rs := &LocationsService{s: s}
147 rs.Questions = NewLocationsQuestionsService(s)
148 return rs
149 }
150
151 type LocationsService struct {
152 s *Service
153
154 Questions *LocationsQuestionsService
155 }
156
157 func NewLocationsQuestionsService(s *Service) *LocationsQuestionsService {
158 rs := &LocationsQuestionsService{s: s}
159 rs.Answers = NewLocationsQuestionsAnswersService(s)
160 return rs
161 }
162
163 type LocationsQuestionsService struct {
164 s *Service
165
166 Answers *LocationsQuestionsAnswersService
167 }
168
169 func NewLocationsQuestionsAnswersService(s *Service) *LocationsQuestionsAnswersService {
170 rs := &LocationsQuestionsAnswersService{s: s}
171 return rs
172 }
173
174 type LocationsQuestionsAnswersService struct {
175 s *Service
176 }
177
178
179 type Answer struct {
180
181
182 Author *Author `json:"author,omitempty"`
183
184
185 CreateTime string `json:"createTime,omitempty"`
186
187
188 Name string `json:"name,omitempty"`
189
190
191 Text string `json:"text,omitempty"`
192
193
194 UpdateTime string `json:"updateTime,omitempty"`
195
196 UpvoteCount int64 `json:"upvoteCount,omitempty"`
197
198
199 googleapi.ServerResponse `json:"-"`
200
201
202
203
204
205 ForceSendFields []string `json:"-"`
206
207
208
209
210 NullFields []string `json:"-"`
211 }
212
213 func (s *Answer) MarshalJSON() ([]byte, error) {
214 type NoMethod Answer
215 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
216 }
217
218
219 type Author struct {
220
221 DisplayName string `json:"displayName,omitempty"`
222
223 ProfilePhotoUri string `json:"profilePhotoUri,omitempty"`
224
225
226
227
228
229
230
231 Type string `json:"type,omitempty"`
232
233
234
235
236
237 ForceSendFields []string `json:"-"`
238
239
240
241
242 NullFields []string `json:"-"`
243 }
244
245 func (s *Author) MarshalJSON() ([]byte, error) {
246 type NoMethod Author
247 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
248 }
249
250
251
252
253
254 type Empty struct {
255
256 googleapi.ServerResponse `json:"-"`
257 }
258
259
260 type ListAnswersResponse struct {
261
262 Answers []*Answer `json:"answers,omitempty"`
263
264
265
266
267 NextPageToken string `json:"nextPageToken,omitempty"`
268
269
270 TotalSize int64 `json:"totalSize,omitempty"`
271
272
273 googleapi.ServerResponse `json:"-"`
274
275
276
277
278
279 ForceSendFields []string `json:"-"`
280
281
282
283
284 NullFields []string `json:"-"`
285 }
286
287 func (s *ListAnswersResponse) MarshalJSON() ([]byte, error) {
288 type NoMethod ListAnswersResponse
289 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
290 }
291
292
293
294 type ListQuestionsResponse struct {
295
296
297
298
299 NextPageToken string `json:"nextPageToken,omitempty"`
300
301 Questions []*Question `json:"questions,omitempty"`
302
303
304 TotalSize int64 `json:"totalSize,omitempty"`
305
306
307 googleapi.ServerResponse `json:"-"`
308
309
310
311
312
313 ForceSendFields []string `json:"-"`
314
315
316
317
318 NullFields []string `json:"-"`
319 }
320
321 func (s *ListQuestionsResponse) MarshalJSON() ([]byte, error) {
322 type NoMethod ListQuestionsResponse
323 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
324 }
325
326
327 type Question struct {
328
329 Author *Author `json:"author,omitempty"`
330
331 CreateTime string `json:"createTime,omitempty"`
332
333
334 Name string `json:"name,omitempty"`
335
336
337
338 Text string `json:"text,omitempty"`
339
340
341
342 TopAnswers []*Answer `json:"topAnswers,omitempty"`
343
344
345 TotalAnswerCount int64 `json:"totalAnswerCount,omitempty"`
346
347
348 UpdateTime string `json:"updateTime,omitempty"`
349
350 UpvoteCount int64 `json:"upvoteCount,omitempty"`
351
352
353 googleapi.ServerResponse `json:"-"`
354
355
356
357
358
359 ForceSendFields []string `json:"-"`
360
361
362
363
364 NullFields []string `json:"-"`
365 }
366
367 func (s *Question) MarshalJSON() ([]byte, error) {
368 type NoMethod Question
369 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
370 }
371
372
373 type UpsertAnswerRequest struct {
374
375 Answer *Answer `json:"answer,omitempty"`
376
377
378
379
380
381 ForceSendFields []string `json:"-"`
382
383
384
385
386 NullFields []string `json:"-"`
387 }
388
389 func (s *UpsertAnswerRequest) MarshalJSON() ([]byte, error) {
390 type NoMethod UpsertAnswerRequest
391 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
392 }
393
394 type LocationsQuestionsCreateCall struct {
395 s *Service
396 parent string
397 question *Question
398 urlParams_ gensupport.URLParams
399 ctx_ context.Context
400 header_ http.Header
401 }
402
403
404
405
406 func (r *LocationsQuestionsService) Create(parent string, question *Question) *LocationsQuestionsCreateCall {
407 c := &LocationsQuestionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
408 c.parent = parent
409 c.question = question
410 return c
411 }
412
413
414
415
416 func (c *LocationsQuestionsCreateCall) Fields(s ...googleapi.Field) *LocationsQuestionsCreateCall {
417 c.urlParams_.Set("fields", googleapi.CombineFields(s))
418 return c
419 }
420
421
422 func (c *LocationsQuestionsCreateCall) Context(ctx context.Context) *LocationsQuestionsCreateCall {
423 c.ctx_ = ctx
424 return c
425 }
426
427
428
429 func (c *LocationsQuestionsCreateCall) Header() http.Header {
430 if c.header_ == nil {
431 c.header_ = make(http.Header)
432 }
433 return c.header_
434 }
435
436 func (c *LocationsQuestionsCreateCall) doRequest(alt string) (*http.Response, error) {
437 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
438 var body io.Reader = nil
439 body, err := googleapi.WithoutDataWrapper.JSONReader(c.question)
440 if err != nil {
441 return nil, err
442 }
443 c.urlParams_.Set("alt", alt)
444 c.urlParams_.Set("prettyPrint", "false")
445 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}")
446 urls += "?" + c.urlParams_.Encode()
447 req, err := http.NewRequest("POST", urls, body)
448 if err != nil {
449 return nil, err
450 }
451 req.Header = reqHeaders
452 googleapi.Expand(req.URL, map[string]string{
453 "parent": c.parent,
454 })
455 return gensupport.SendRequest(c.ctx_, c.s.client, req)
456 }
457
458
459
460
461
462
463 func (c *LocationsQuestionsCreateCall) Do(opts ...googleapi.CallOption) (*Question, error) {
464 gensupport.SetOptions(c.urlParams_, opts...)
465 res, err := c.doRequest("json")
466 if res != nil && res.StatusCode == http.StatusNotModified {
467 if res.Body != nil {
468 res.Body.Close()
469 }
470 return nil, gensupport.WrapError(&googleapi.Error{
471 Code: res.StatusCode,
472 Header: res.Header,
473 })
474 }
475 if err != nil {
476 return nil, err
477 }
478 defer googleapi.CloseBody(res)
479 if err := googleapi.CheckResponse(res); err != nil {
480 return nil, gensupport.WrapError(err)
481 }
482 ret := &Question{
483 ServerResponse: googleapi.ServerResponse{
484 Header: res.Header,
485 HTTPStatusCode: res.StatusCode,
486 },
487 }
488 target := &ret
489 if err := gensupport.DecodeResponse(target, res); err != nil {
490 return nil, err
491 }
492 return ret, nil
493 }
494
495 type LocationsQuestionsDeleteCall struct {
496 s *Service
497 name string
498 urlParams_ gensupport.URLParams
499 ctx_ context.Context
500 header_ http.Header
501 }
502
503
504
505
506 func (r *LocationsQuestionsService) Delete(name string) *LocationsQuestionsDeleteCall {
507 c := &LocationsQuestionsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
508 c.name = name
509 return c
510 }
511
512
513
514
515 func (c *LocationsQuestionsDeleteCall) Fields(s ...googleapi.Field) *LocationsQuestionsDeleteCall {
516 c.urlParams_.Set("fields", googleapi.CombineFields(s))
517 return c
518 }
519
520
521 func (c *LocationsQuestionsDeleteCall) Context(ctx context.Context) *LocationsQuestionsDeleteCall {
522 c.ctx_ = ctx
523 return c
524 }
525
526
527
528 func (c *LocationsQuestionsDeleteCall) Header() http.Header {
529 if c.header_ == nil {
530 c.header_ = make(http.Header)
531 }
532 return c.header_
533 }
534
535 func (c *LocationsQuestionsDeleteCall) doRequest(alt string) (*http.Response, error) {
536 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
537 var body io.Reader = nil
538 c.urlParams_.Set("alt", alt)
539 c.urlParams_.Set("prettyPrint", "false")
540 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
541 urls += "?" + c.urlParams_.Encode()
542 req, err := http.NewRequest("DELETE", urls, body)
543 if err != nil {
544 return nil, err
545 }
546 req.Header = reqHeaders
547 googleapi.Expand(req.URL, map[string]string{
548 "name": c.name,
549 })
550 return gensupport.SendRequest(c.ctx_, c.s.client, req)
551 }
552
553
554
555
556
557
558 func (c *LocationsQuestionsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
559 gensupport.SetOptions(c.urlParams_, opts...)
560 res, err := c.doRequest("json")
561 if res != nil && res.StatusCode == http.StatusNotModified {
562 if res.Body != nil {
563 res.Body.Close()
564 }
565 return nil, gensupport.WrapError(&googleapi.Error{
566 Code: res.StatusCode,
567 Header: res.Header,
568 })
569 }
570 if err != nil {
571 return nil, err
572 }
573 defer googleapi.CloseBody(res)
574 if err := googleapi.CheckResponse(res); err != nil {
575 return nil, gensupport.WrapError(err)
576 }
577 ret := &Empty{
578 ServerResponse: googleapi.ServerResponse{
579 Header: res.Header,
580 HTTPStatusCode: res.StatusCode,
581 },
582 }
583 target := &ret
584 if err := gensupport.DecodeResponse(target, res); err != nil {
585 return nil, err
586 }
587 return ret, nil
588 }
589
590 type LocationsQuestionsListCall struct {
591 s *Service
592 parent string
593 urlParams_ gensupport.URLParams
594 ifNoneMatch_ string
595 ctx_ context.Context
596 header_ http.Header
597 }
598
599
600
601
602
603
604 func (r *LocationsQuestionsService) List(parent string) *LocationsQuestionsListCall {
605 c := &LocationsQuestionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
606 c.parent = parent
607 return c
608 }
609
610
611
612
613 func (c *LocationsQuestionsListCall) AnswersPerQuestion(answersPerQuestion int64) *LocationsQuestionsListCall {
614 c.urlParams_.Set("answersPerQuestion", fmt.Sprint(answersPerQuestion))
615 return c
616 }
617
618
619
620
621 func (c *LocationsQuestionsListCall) Filter(filter string) *LocationsQuestionsListCall {
622 c.urlParams_.Set("filter", filter)
623 return c
624 }
625
626
627
628
629
630 func (c *LocationsQuestionsListCall) OrderBy(orderBy string) *LocationsQuestionsListCall {
631 c.urlParams_.Set("orderBy", orderBy)
632 return c
633 }
634
635
636
637 func (c *LocationsQuestionsListCall) PageSize(pageSize int64) *LocationsQuestionsListCall {
638 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
639 return c
640 }
641
642
643
644 func (c *LocationsQuestionsListCall) PageToken(pageToken string) *LocationsQuestionsListCall {
645 c.urlParams_.Set("pageToken", pageToken)
646 return c
647 }
648
649
650
651
652 func (c *LocationsQuestionsListCall) Fields(s ...googleapi.Field) *LocationsQuestionsListCall {
653 c.urlParams_.Set("fields", googleapi.CombineFields(s))
654 return c
655 }
656
657
658
659
660 func (c *LocationsQuestionsListCall) IfNoneMatch(entityTag string) *LocationsQuestionsListCall {
661 c.ifNoneMatch_ = entityTag
662 return c
663 }
664
665
666 func (c *LocationsQuestionsListCall) Context(ctx context.Context) *LocationsQuestionsListCall {
667 c.ctx_ = ctx
668 return c
669 }
670
671
672
673 func (c *LocationsQuestionsListCall) Header() http.Header {
674 if c.header_ == nil {
675 c.header_ = make(http.Header)
676 }
677 return c.header_
678 }
679
680 func (c *LocationsQuestionsListCall) doRequest(alt string) (*http.Response, error) {
681 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
682 if c.ifNoneMatch_ != "" {
683 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
684 }
685 var body io.Reader = nil
686 c.urlParams_.Set("alt", alt)
687 c.urlParams_.Set("prettyPrint", "false")
688 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}")
689 urls += "?" + c.urlParams_.Encode()
690 req, err := http.NewRequest("GET", urls, body)
691 if err != nil {
692 return nil, err
693 }
694 req.Header = reqHeaders
695 googleapi.Expand(req.URL, map[string]string{
696 "parent": c.parent,
697 })
698 return gensupport.SendRequest(c.ctx_, c.s.client, req)
699 }
700
701
702
703
704
705
706
707 func (c *LocationsQuestionsListCall) Do(opts ...googleapi.CallOption) (*ListQuestionsResponse, error) {
708 gensupport.SetOptions(c.urlParams_, opts...)
709 res, err := c.doRequest("json")
710 if res != nil && res.StatusCode == http.StatusNotModified {
711 if res.Body != nil {
712 res.Body.Close()
713 }
714 return nil, gensupport.WrapError(&googleapi.Error{
715 Code: res.StatusCode,
716 Header: res.Header,
717 })
718 }
719 if err != nil {
720 return nil, err
721 }
722 defer googleapi.CloseBody(res)
723 if err := googleapi.CheckResponse(res); err != nil {
724 return nil, gensupport.WrapError(err)
725 }
726 ret := &ListQuestionsResponse{
727 ServerResponse: googleapi.ServerResponse{
728 Header: res.Header,
729 HTTPStatusCode: res.StatusCode,
730 },
731 }
732 target := &ret
733 if err := gensupport.DecodeResponse(target, res); err != nil {
734 return nil, err
735 }
736 return ret, nil
737 }
738
739
740
741
742 func (c *LocationsQuestionsListCall) Pages(ctx context.Context, f func(*ListQuestionsResponse) error) error {
743 c.ctx_ = ctx
744 defer c.PageToken(c.urlParams_.Get("pageToken"))
745 for {
746 x, err := c.Do()
747 if err != nil {
748 return err
749 }
750 if err := f(x); err != nil {
751 return err
752 }
753 if x.NextPageToken == "" {
754 return nil
755 }
756 c.PageToken(x.NextPageToken)
757 }
758 }
759
760 type LocationsQuestionsPatchCall struct {
761 s *Service
762 name string
763 question *Question
764 urlParams_ gensupport.URLParams
765 ctx_ context.Context
766 header_ http.Header
767 }
768
769
770
771
772
773 func (r *LocationsQuestionsService) Patch(name string, question *Question) *LocationsQuestionsPatchCall {
774 c := &LocationsQuestionsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
775 c.name = name
776 c.question = question
777 return c
778 }
779
780
781
782 func (c *LocationsQuestionsPatchCall) UpdateMask(updateMask string) *LocationsQuestionsPatchCall {
783 c.urlParams_.Set("updateMask", updateMask)
784 return c
785 }
786
787
788
789
790 func (c *LocationsQuestionsPatchCall) Fields(s ...googleapi.Field) *LocationsQuestionsPatchCall {
791 c.urlParams_.Set("fields", googleapi.CombineFields(s))
792 return c
793 }
794
795
796 func (c *LocationsQuestionsPatchCall) Context(ctx context.Context) *LocationsQuestionsPatchCall {
797 c.ctx_ = ctx
798 return c
799 }
800
801
802
803 func (c *LocationsQuestionsPatchCall) Header() http.Header {
804 if c.header_ == nil {
805 c.header_ = make(http.Header)
806 }
807 return c.header_
808 }
809
810 func (c *LocationsQuestionsPatchCall) doRequest(alt string) (*http.Response, error) {
811 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
812 var body io.Reader = nil
813 body, err := googleapi.WithoutDataWrapper.JSONReader(c.question)
814 if err != nil {
815 return nil, err
816 }
817 c.urlParams_.Set("alt", alt)
818 c.urlParams_.Set("prettyPrint", "false")
819 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
820 urls += "?" + c.urlParams_.Encode()
821 req, err := http.NewRequest("PATCH", urls, body)
822 if err != nil {
823 return nil, err
824 }
825 req.Header = reqHeaders
826 googleapi.Expand(req.URL, map[string]string{
827 "name": c.name,
828 })
829 return gensupport.SendRequest(c.ctx_, c.s.client, req)
830 }
831
832
833
834
835
836
837 func (c *LocationsQuestionsPatchCall) Do(opts ...googleapi.CallOption) (*Question, error) {
838 gensupport.SetOptions(c.urlParams_, opts...)
839 res, err := c.doRequest("json")
840 if res != nil && res.StatusCode == http.StatusNotModified {
841 if res.Body != nil {
842 res.Body.Close()
843 }
844 return nil, gensupport.WrapError(&googleapi.Error{
845 Code: res.StatusCode,
846 Header: res.Header,
847 })
848 }
849 if err != nil {
850 return nil, err
851 }
852 defer googleapi.CloseBody(res)
853 if err := googleapi.CheckResponse(res); err != nil {
854 return nil, gensupport.WrapError(err)
855 }
856 ret := &Question{
857 ServerResponse: googleapi.ServerResponse{
858 Header: res.Header,
859 HTTPStatusCode: res.StatusCode,
860 },
861 }
862 target := &ret
863 if err := gensupport.DecodeResponse(target, res); err != nil {
864 return nil, err
865 }
866 return ret, nil
867 }
868
869 type LocationsQuestionsAnswersDeleteCall struct {
870 s *Service
871 name string
872 urlParams_ gensupport.URLParams
873 ctx_ context.Context
874 header_ http.Header
875 }
876
877
878
879
880 func (r *LocationsQuestionsAnswersService) Delete(name string) *LocationsQuestionsAnswersDeleteCall {
881 c := &LocationsQuestionsAnswersDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
882 c.name = name
883 return c
884 }
885
886
887
888
889 func (c *LocationsQuestionsAnswersDeleteCall) Fields(s ...googleapi.Field) *LocationsQuestionsAnswersDeleteCall {
890 c.urlParams_.Set("fields", googleapi.CombineFields(s))
891 return c
892 }
893
894
895 func (c *LocationsQuestionsAnswersDeleteCall) Context(ctx context.Context) *LocationsQuestionsAnswersDeleteCall {
896 c.ctx_ = ctx
897 return c
898 }
899
900
901
902 func (c *LocationsQuestionsAnswersDeleteCall) Header() http.Header {
903 if c.header_ == nil {
904 c.header_ = make(http.Header)
905 }
906 return c.header_
907 }
908
909 func (c *LocationsQuestionsAnswersDeleteCall) doRequest(alt string) (*http.Response, error) {
910 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
911 var body io.Reader = nil
912 c.urlParams_.Set("alt", alt)
913 c.urlParams_.Set("prettyPrint", "false")
914 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}/answers:delete")
915 urls += "?" + c.urlParams_.Encode()
916 req, err := http.NewRequest("DELETE", urls, body)
917 if err != nil {
918 return nil, err
919 }
920 req.Header = reqHeaders
921 googleapi.Expand(req.URL, map[string]string{
922 "name": c.name,
923 })
924 return gensupport.SendRequest(c.ctx_, c.s.client, req)
925 }
926
927
928
929
930
931
932 func (c *LocationsQuestionsAnswersDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
933 gensupport.SetOptions(c.urlParams_, opts...)
934 res, err := c.doRequest("json")
935 if res != nil && res.StatusCode == http.StatusNotModified {
936 if res.Body != nil {
937 res.Body.Close()
938 }
939 return nil, gensupport.WrapError(&googleapi.Error{
940 Code: res.StatusCode,
941 Header: res.Header,
942 })
943 }
944 if err != nil {
945 return nil, err
946 }
947 defer googleapi.CloseBody(res)
948 if err := googleapi.CheckResponse(res); err != nil {
949 return nil, gensupport.WrapError(err)
950 }
951 ret := &Empty{
952 ServerResponse: googleapi.ServerResponse{
953 Header: res.Header,
954 HTTPStatusCode: res.StatusCode,
955 },
956 }
957 target := &ret
958 if err := gensupport.DecodeResponse(target, res); err != nil {
959 return nil, err
960 }
961 return ret, nil
962 }
963
964 type LocationsQuestionsAnswersListCall struct {
965 s *Service
966 parent string
967 urlParams_ gensupport.URLParams
968 ifNoneMatch_ string
969 ctx_ context.Context
970 header_ http.Header
971 }
972
973
974
975
976 func (r *LocationsQuestionsAnswersService) List(parent string) *LocationsQuestionsAnswersListCall {
977 c := &LocationsQuestionsAnswersListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
978 c.parent = parent
979 return c
980 }
981
982
983
984
985
986 func (c *LocationsQuestionsAnswersListCall) OrderBy(orderBy string) *LocationsQuestionsAnswersListCall {
987 c.urlParams_.Set("orderBy", orderBy)
988 return c
989 }
990
991
992
993 func (c *LocationsQuestionsAnswersListCall) PageSize(pageSize int64) *LocationsQuestionsAnswersListCall {
994 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
995 return c
996 }
997
998
999
1000 func (c *LocationsQuestionsAnswersListCall) PageToken(pageToken string) *LocationsQuestionsAnswersListCall {
1001 c.urlParams_.Set("pageToken", pageToken)
1002 return c
1003 }
1004
1005
1006
1007
1008 func (c *LocationsQuestionsAnswersListCall) Fields(s ...googleapi.Field) *LocationsQuestionsAnswersListCall {
1009 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1010 return c
1011 }
1012
1013
1014
1015
1016 func (c *LocationsQuestionsAnswersListCall) IfNoneMatch(entityTag string) *LocationsQuestionsAnswersListCall {
1017 c.ifNoneMatch_ = entityTag
1018 return c
1019 }
1020
1021
1022 func (c *LocationsQuestionsAnswersListCall) Context(ctx context.Context) *LocationsQuestionsAnswersListCall {
1023 c.ctx_ = ctx
1024 return c
1025 }
1026
1027
1028
1029 func (c *LocationsQuestionsAnswersListCall) Header() http.Header {
1030 if c.header_ == nil {
1031 c.header_ = make(http.Header)
1032 }
1033 return c.header_
1034 }
1035
1036 func (c *LocationsQuestionsAnswersListCall) doRequest(alt string) (*http.Response, error) {
1037 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1038 if c.ifNoneMatch_ != "" {
1039 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1040 }
1041 var body io.Reader = nil
1042 c.urlParams_.Set("alt", alt)
1043 c.urlParams_.Set("prettyPrint", "false")
1044 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/answers")
1045 urls += "?" + c.urlParams_.Encode()
1046 req, err := http.NewRequest("GET", urls, body)
1047 if err != nil {
1048 return nil, err
1049 }
1050 req.Header = reqHeaders
1051 googleapi.Expand(req.URL, map[string]string{
1052 "parent": c.parent,
1053 })
1054 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1055 }
1056
1057
1058
1059
1060
1061
1062
1063 func (c *LocationsQuestionsAnswersListCall) Do(opts ...googleapi.CallOption) (*ListAnswersResponse, error) {
1064 gensupport.SetOptions(c.urlParams_, opts...)
1065 res, err := c.doRequest("json")
1066 if res != nil && res.StatusCode == http.StatusNotModified {
1067 if res.Body != nil {
1068 res.Body.Close()
1069 }
1070 return nil, gensupport.WrapError(&googleapi.Error{
1071 Code: res.StatusCode,
1072 Header: res.Header,
1073 })
1074 }
1075 if err != nil {
1076 return nil, err
1077 }
1078 defer googleapi.CloseBody(res)
1079 if err := googleapi.CheckResponse(res); err != nil {
1080 return nil, gensupport.WrapError(err)
1081 }
1082 ret := &ListAnswersResponse{
1083 ServerResponse: googleapi.ServerResponse{
1084 Header: res.Header,
1085 HTTPStatusCode: res.StatusCode,
1086 },
1087 }
1088 target := &ret
1089 if err := gensupport.DecodeResponse(target, res); err != nil {
1090 return nil, err
1091 }
1092 return ret, nil
1093 }
1094
1095
1096
1097
1098 func (c *LocationsQuestionsAnswersListCall) Pages(ctx context.Context, f func(*ListAnswersResponse) error) error {
1099 c.ctx_ = ctx
1100 defer c.PageToken(c.urlParams_.Get("pageToken"))
1101 for {
1102 x, err := c.Do()
1103 if err != nil {
1104 return err
1105 }
1106 if err := f(x); err != nil {
1107 return err
1108 }
1109 if x.NextPageToken == "" {
1110 return nil
1111 }
1112 c.PageToken(x.NextPageToken)
1113 }
1114 }
1115
1116 type LocationsQuestionsAnswersUpsertCall struct {
1117 s *Service
1118 parent string
1119 upsertanswerrequest *UpsertAnswerRequest
1120 urlParams_ gensupport.URLParams
1121 ctx_ context.Context
1122 header_ http.Header
1123 }
1124
1125
1126
1127
1128
1129 func (r *LocationsQuestionsAnswersService) Upsert(parent string, upsertanswerrequest *UpsertAnswerRequest) *LocationsQuestionsAnswersUpsertCall {
1130 c := &LocationsQuestionsAnswersUpsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1131 c.parent = parent
1132 c.upsertanswerrequest = upsertanswerrequest
1133 return c
1134 }
1135
1136
1137
1138
1139 func (c *LocationsQuestionsAnswersUpsertCall) Fields(s ...googleapi.Field) *LocationsQuestionsAnswersUpsertCall {
1140 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1141 return c
1142 }
1143
1144
1145 func (c *LocationsQuestionsAnswersUpsertCall) Context(ctx context.Context) *LocationsQuestionsAnswersUpsertCall {
1146 c.ctx_ = ctx
1147 return c
1148 }
1149
1150
1151
1152 func (c *LocationsQuestionsAnswersUpsertCall) Header() http.Header {
1153 if c.header_ == nil {
1154 c.header_ = make(http.Header)
1155 }
1156 return c.header_
1157 }
1158
1159 func (c *LocationsQuestionsAnswersUpsertCall) doRequest(alt string) (*http.Response, error) {
1160 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1161 var body io.Reader = nil
1162 body, err := googleapi.WithoutDataWrapper.JSONReader(c.upsertanswerrequest)
1163 if err != nil {
1164 return nil, err
1165 }
1166 c.urlParams_.Set("alt", alt)
1167 c.urlParams_.Set("prettyPrint", "false")
1168 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/answers:upsert")
1169 urls += "?" + c.urlParams_.Encode()
1170 req, err := http.NewRequest("POST", urls, body)
1171 if err != nil {
1172 return nil, err
1173 }
1174 req.Header = reqHeaders
1175 googleapi.Expand(req.URL, map[string]string{
1176 "parent": c.parent,
1177 })
1178 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1179 }
1180
1181
1182
1183
1184
1185
1186 func (c *LocationsQuestionsAnswersUpsertCall) Do(opts ...googleapi.CallOption) (*Answer, error) {
1187 gensupport.SetOptions(c.urlParams_, opts...)
1188 res, err := c.doRequest("json")
1189 if res != nil && res.StatusCode == http.StatusNotModified {
1190 if res.Body != nil {
1191 res.Body.Close()
1192 }
1193 return nil, gensupport.WrapError(&googleapi.Error{
1194 Code: res.StatusCode,
1195 Header: res.Header,
1196 })
1197 }
1198 if err != nil {
1199 return nil, err
1200 }
1201 defer googleapi.CloseBody(res)
1202 if err := googleapi.CheckResponse(res); err != nil {
1203 return nil, gensupport.WrapError(err)
1204 }
1205 ret := &Answer{
1206 ServerResponse: googleapi.ServerResponse{
1207 Header: res.Header,
1208 HTTPStatusCode: res.StatusCode,
1209 },
1210 }
1211 target := &ret
1212 if err := gensupport.DecodeResponse(target, res); err != nil {
1213 return nil, err
1214 }
1215 return ret, nil
1216 }
1217
View as plain text