Debian Codegraph @

mybusinessqanda/v1/mybusinessqanda-gen.go

raw
1 // Copyright 2025 Google LLC.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Code generated file. DO NOT EDIT.
6
7 // Package mybusinessqanda provides access to the My Business Q&A API.
8 //
9 // For product documentation, see: https://developers.google.com/my-business/
10 //
11 // # Library status
12 //
13 // These client libraries are officially supported by Google. However, this
14 // library is considered complete and is in maintenance mode. This means
15 // that we will address critical bugs and security issues but will not add
16 // any new features.
17 //
18 // When possible, we recommend using our newer
19 // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
20 // that are still actively being worked and iterated on.
21 //
22 // # Creating a client
23 //
24 // Usage example:
25 //
26 // import "google.golang.org/api/mybusinessqanda/v1"
27 // ...
28 // ctx := context.Background()
29 // mybusinessqandaService, err := mybusinessqanda.NewService(ctx)
30 //
31 // In this example, Google Application Default Credentials are used for
32 // authentication. For information on how to create and obtain Application
33 // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
34 //
35 // # Other authentication options
36 //
37 // To use an API key for authentication (note: some APIs do not support API
38 // keys), use [google.golang.org/api/option.WithAPIKey]:
39 //
40 // mybusinessqandaService, err := mybusinessqanda.NewService(ctx, option.WithAPIKey("AIza..."))
41 //
42 // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
43 // flow, use [google.golang.org/api/option.WithTokenSource]:
44 //
45 // config := &oauth2.Config{...}
46 // // ...
47 // token, err := config.Exchange(ctx, ...)
48 // mybusinessqandaService, err := mybusinessqanda.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
49 //
50 // See [google.golang.org/api/option.ClientOption] for details on options.
51 package mybusinessqanda // import "google.golang.org/api/mybusinessqanda/v1"
52
53 import (
54 "bytes"
55 "context"
56 "encoding/json"
57 "errors"
58 "fmt"
59 "io"
60 "log/slog"
61 "net/http"
62 "net/url"
63 "strconv"
64 "strings"
65
66 "github.com/googleapis/gax-go/v2/internallog"
67 googleapi "google.golang.org/api/googleapi"
68 internal "google.golang.org/api/internal"
69 gensupport "google.golang.org/api/internal/gensupport"
70 option "google.golang.org/api/option"
71 internaloption "google.golang.org/api/option/internaloption"
72 htransport "google.golang.org/api/transport/http"
73 )
74
75 // Always reference these packages, just in case the auto-generated code
76 // below doesn't.
77 var _ = bytes.NewBuffer
78 var _ = strconv.Itoa
79 var _ = fmt.Sprintf
80 var _ = json.NewDecoder
81 var _ = io.Copy
82 var _ = url.Parse
83 var _ = gensupport.MarshalJSON
84 var _ = googleapi.Version
85 var _ = errors.New
86 var _ = strings.Replace
87 var _ = context.Canceled
88 var _ = internaloption.WithDefaultEndpoint
89 var _ = internal.Version
90 var _ = internallog.New
91
92 const apiId = "mybusinessqanda:v1"
93 const apiName = "mybusinessqanda"
94 const apiVersion = "v1"
95 const basePath = "https://mybusinessqanda.googleapis.com/"
96 const basePathTemplate = "https://mybusinessqanda.UNIVERSE_DOMAIN/"
97 const mtlsBasePath = "https://mybusinessqanda.mtls.googleapis.com/"
98
99 // NewService creates a new Service.
100 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
101 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
102 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
103 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
104 opts = append(opts, internaloption.EnableNewAuthLibrary())
105 client, endpoint, err := htransport.NewClient(ctx, opts...)
106 if err != nil {
107 return nil, err
108 }
109 s := &Service{client: client, BasePath: basePath, logger: internaloption.GetLogger(opts)}
110 s.Locations = NewLocationsService(s)
111 if err != nil {
112 return nil, err
113 }
114 if endpoint != "" {
115 s.BasePath = endpoint
116 }
117 return s, nil
118 }
119
120 // New creates a new Service. It uses the provided http.Client for requests.
121 //
122 // Deprecated: please use NewService instead.
123 // To provide a custom HTTP client, use option.WithHTTPClient.
124 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
125 func New(client *http.Client) (*Service, error) {
126 if client == nil {
127 return nil, errors.New("client is nil")
128 }
129 return NewService(context.TODO(), option.WithHTTPClient(client))
130 }
131
132 type Service struct {
133 client *http.Client
134 logger *slog.Logger
135 BasePath string // API endpoint base URL
136 UserAgent string // optional additional User-Agent fragment
137
138 Locations *LocationsService
139 }
140
141 func (s *Service) userAgent() string {
142 if s.UserAgent == "" {
143 return googleapi.UserAgent
144 }
145 return googleapi.UserAgent + " " + s.UserAgent
146 }
147
148 func NewLocationsService(s *Service) *LocationsService {
149 rs := &LocationsService{s: s}
150 rs.Questions = NewLocationsQuestionsService(s)
151 return rs
152 }
153
154 type LocationsService struct {
155 s *Service
156
157 Questions *LocationsQuestionsService
158 }
159
160 func NewLocationsQuestionsService(s *Service) *LocationsQuestionsService {
161 rs := &LocationsQuestionsService{s: s}
162 rs.Answers = NewLocationsQuestionsAnswersService(s)
163 return rs
164 }
165
166 type LocationsQuestionsService struct {
167 s *Service
168
169 Answers *LocationsQuestionsAnswersService
170 }
171
172 func NewLocationsQuestionsAnswersService(s *Service) *LocationsQuestionsAnswersService {
173 rs := &LocationsQuestionsAnswersService{s: s}
174 return rs
175 }
176
177 type LocationsQuestionsAnswersService struct {
178 s *Service
179 }
180
181 // Answer: Represents an answer to a question
182 type Answer struct {
183 // Author: Output only. The author of the answer. Will only be set during list
184 // operations.
185 Author *Author `json:"author,omitempty"`
186 // CreateTime: Output only. The timestamp for when the answer was written. Only
187 // retrieved during ListResponse fetching.
188 CreateTime string `json:"createTime,omitempty"`
189 // Name: Output only. The unique name for the answer
190 // locations/*/questions/*/answers/*
191 Name string `json:"name,omitempty"`
192 // Text: Required. The text of the answer. It should contain at least one
193 // non-whitespace character. The maximum length is 4096 characters.
194 Text string `json:"text,omitempty"`
195 // UpdateTime: Output only. The timestamp for when the answer was last
196 // modified.
197 UpdateTime string `json:"updateTime,omitempty"`
198 // UpvoteCount: Output only. The number of upvotes for the answer.
199 UpvoteCount int64 `json:"upvoteCount,omitempty"`
200
201 // ServerResponse contains the HTTP response code and headers from the server.
202 googleapi.ServerResponse `json:"-"`
203 // ForceSendFields is a list of field names (e.g. "Author") to unconditionally
204 // include in API requests. By default, fields with empty or default values are
205 // omitted from API requests. See
206 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
207 // details.
208 ForceSendFields []string `json:"-"`
209 // NullFields is a list of field names (e.g. "Author") to include in API
210 // requests with the JSON null value. By default, fields with empty values are
211 // omitted from API requests. See
212 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
213 NullFields []string `json:"-"`
214 }
215
216 func (s Answer) MarshalJSON() ([]byte, error) {
217 type NoMethod Answer
218 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
219 }
220
221 // Author: Represents the author of a question or answer
222 type Author struct {
223 // DisplayName: The display name of the user
224 DisplayName string `json:"displayName,omitempty"`
225 // ProfilePhotoUri: The profile photo URI of the user.
226 ProfilePhotoUri string `json:"profilePhotoUri,omitempty"`
227 // Type: The type of user the author is.
228 //
229 // Possible values:
230 // "AUTHOR_TYPE_UNSPECIFIED" - This should not be used.
231 // "REGULAR_USER" - A regular user.
232 // "LOCAL_GUIDE" - A Local Guide
233 // "MERCHANT" - The owner/manager of the location
234 Type string `json:"type,omitempty"`
235 // ForceSendFields is a list of field names (e.g. "DisplayName") to
236 // unconditionally include in API requests. By default, fields with empty or
237 // default values are omitted from API requests. See
238 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
239 // details.
240 ForceSendFields []string `json:"-"`
241 // NullFields is a list of field names (e.g. "DisplayName") to include in API
242 // requests with the JSON null value. By default, fields with empty values are
243 // omitted from API requests. See
244 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
245 NullFields []string `json:"-"`
246 }
247
248 func (s Author) MarshalJSON() ([]byte, error) {
249 type NoMethod Author
250 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
251 }
252
253 // Empty: A generic empty message that you can re-use to avoid defining
254 // duplicated empty messages in your APIs. A typical example is to use it as
255 // the request or the response type of an API method. For instance: service Foo
256 // { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
257 type Empty struct {
258 // ServerResponse contains the HTTP response code and headers from the server.
259 googleapi.ServerResponse `json:"-"`
260 }
261
262 // ListAnswersResponse: Response message for QuestionsAndAnswers.ListAnswers
263 type ListAnswersResponse struct {
264 // Answers: The requested answers.
265 Answers []*Answer `json:"answers,omitempty"`
266 // NextPageToken: If the number of answers exceeds the requested max page size,
267 // this field is populated with a token to fetch the next page of answers on a
268 // subsequent call. If there are no more answers, this field is not present in
269 // the response.
270 NextPageToken string `json:"nextPageToken,omitempty"`
271 // TotalSize: The total number of answers posted for this question across all
272 // pages.
273 TotalSize int64 `json:"totalSize,omitempty"`
274
275 // ServerResponse contains the HTTP response code and headers from the server.
276 googleapi.ServerResponse `json:"-"`
277 // ForceSendFields is a list of field names (e.g. "Answers") to unconditionally
278 // include in API requests. By default, fields with empty or default values are
279 // omitted from API requests. See
280 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
281 // details.
282 ForceSendFields []string `json:"-"`
283 // NullFields is a list of field names (e.g. "Answers") to include in API
284 // requests with the JSON null value. By default, fields with empty values are
285 // omitted from API requests. See
286 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
287 NullFields []string `json:"-"`
288 }
289
290 func (s ListAnswersResponse) MarshalJSON() ([]byte, error) {
291 type NoMethod ListAnswersResponse
292 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
293 }
294
295 // ListQuestionsResponse: Response message for
296 // QuestionsAndAnswers.ListQuestions
297 type ListQuestionsResponse struct {
298 // NextPageToken: If the number of questions exceeds the requested max page
299 // size, this field is populated with a token to fetch the next page of
300 // questions on a subsequent call. If there are no more questions, this field
301 // is not present in the response.
302 NextPageToken string `json:"nextPageToken,omitempty"`
303 // Questions: The requested questions,
304 Questions []*Question `json:"questions,omitempty"`
305 // TotalSize: The total number of questions posted for this location across all
306 // pages.
307 TotalSize int64 `json:"totalSize,omitempty"`
308
309 // ServerResponse contains the HTTP response code and headers from the server.
310 googleapi.ServerResponse `json:"-"`
311 // ForceSendFields is a list of field names (e.g. "NextPageToken") to
312 // unconditionally include in API requests. By default, fields with empty or
313 // default values are omitted from API requests. See
314 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
315 // details.
316 ForceSendFields []string `json:"-"`
317 // NullFields is a list of field names (e.g. "NextPageToken") to include in API
318 // requests with the JSON null value. By default, fields with empty values are
319 // omitted from API requests. See
320 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
321 NullFields []string `json:"-"`
322 }
323
324 func (s ListQuestionsResponse) MarshalJSON() ([]byte, error) {
325 type NoMethod ListQuestionsResponse
326 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
327 }
328
329 // Question: Represents a single question and some of its answers.
330 type Question struct {
331 // Author: Output only. The author of the question.
332 Author *Author `json:"author,omitempty"`
333 // CreateTime: Output only. The timestamp for when the question was written.
334 CreateTime string `json:"createTime,omitempty"`
335 // Name: Immutable. The unique name for the question. locations/*/questions/*
336 // This field will be ignored if set during question creation.
337 Name string `json:"name,omitempty"`
338 // Text: Required. The text of the question. It should contain at least three
339 // words and the total length should be greater than or equal to 10 characters.
340 // The maximum length is 4096 characters.
341 Text string `json:"text,omitempty"`
342 // TopAnswers: Output only. A list of answers to the question, sorted by
343 // upvotes. This may not be a complete list of answers depending on the request
344 // parameters (answers_per_question)
345 TopAnswers []*Answer `json:"topAnswers,omitempty"`
346 // TotalAnswerCount: Output only. The total number of answers posted for this
347 // question.
348 TotalAnswerCount int64 `json:"totalAnswerCount,omitempty"`
349 // UpdateTime: Output only. The timestamp for when the question was last
350 // modified.
351 UpdateTime string `json:"updateTime,omitempty"`
352 // UpvoteCount: Output only. The number of upvotes for the question.
353 UpvoteCount int64 `json:"upvoteCount,omitempty"`
354
355 // ServerResponse contains the HTTP response code and headers from the server.
356 googleapi.ServerResponse `json:"-"`
357 // ForceSendFields is a list of field names (e.g. "Author") to unconditionally
358 // include in API requests. By default, fields with empty or default values are
359 // omitted from API requests. See
360 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
361 // details.
362 ForceSendFields []string `json:"-"`
363 // NullFields is a list of field names (e.g. "Author") to include in API
364 // requests with the JSON null value. By default, fields with empty values are
365 // omitted from API requests. See
366 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
367 NullFields []string `json:"-"`
368 }
369
370 func (s Question) MarshalJSON() ([]byte, error) {
371 type NoMethod Question
372 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
373 }
374
375 // UpsertAnswerRequest: Request message for QuestionsAndAnswers.UpsertAnswer
376 type UpsertAnswerRequest struct {
377 // Answer: Required. The new answer.
378 Answer *Answer `json:"answer,omitempty"`
379 // ForceSendFields is a list of field names (e.g. "Answer") to unconditionally
380 // include in API requests. By default, fields with empty or default values are
381 // omitted from API requests. See
382 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
383 // details.
384 ForceSendFields []string `json:"-"`
385 // NullFields is a list of field names (e.g. "Answer") to include in API
386 // requests with the JSON null value. By default, fields with empty values are
387 // omitted from API requests. See
388 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
389 NullFields []string `json:"-"`
390 }
391
392 func (s UpsertAnswerRequest) MarshalJSON() ([]byte, error) {
393 type NoMethod UpsertAnswerRequest
394 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
395 }
396
397 type LocationsQuestionsCreateCall struct {
398 s *Service
399 parent string
400 question *Question
401 urlParams_ gensupport.URLParams
402 ctx_ context.Context
403 header_ http.Header
404 }
405
406 // Create: Adds a question for the specified location.
407 //
408 // - parent: The name of the location to write a question for.
409 func (r *LocationsQuestionsService) Create(parent string, question *Question) *LocationsQuestionsCreateCall {
410 c := &LocationsQuestionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
411 c.parent = parent
412 c.question = question
413 return c
414 }
415
416 // Fields allows partial responses to be retrieved. See
417 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
418 // details.
419 func (c *LocationsQuestionsCreateCall) Fields(s ...googleapi.Field) *LocationsQuestionsCreateCall {
420 c.urlParams_.Set("fields", googleapi.CombineFields(s))
421 return c
422 }
423
424 // Context sets the context to be used in this call's Do method.
425 func (c *LocationsQuestionsCreateCall) Context(ctx context.Context) *LocationsQuestionsCreateCall {
426 c.ctx_ = ctx
427 return c
428 }
429
430 // Header returns a http.Header that can be modified by the caller to add
431 // headers to the request.
432 func (c *LocationsQuestionsCreateCall) Header() http.Header {
433 if c.header_ == nil {
434 c.header_ = make(http.Header)
435 }
436 return c.header_
437 }
438
439 func (c *LocationsQuestionsCreateCall) doRequest(alt string) (*http.Response, error) {
440 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
441 body, err := googleapi.WithoutDataWrapper.JSONBuffer(c.question)
442 if err != nil {
443 return nil, err
444 }
445 c.urlParams_.Set("alt", alt)
446 c.urlParams_.Set("prettyPrint", "false")
447 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}")
448 urls += "?" + c.urlParams_.Encode()
449 req, err := http.NewRequest("POST", urls, body)
450 if err != nil {
451 return nil, err
452 }
453 req.Header = reqHeaders
454 googleapi.Expand(req.URL, map[string]string{
455 "parent": c.parent,
456 })
457 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "mybusinessqanda.locations.questions.create", "request", internallog.HTTPRequest(req, body.Bytes()))
458 return gensupport.SendRequest(c.ctx_, c.s.client, req)
459 }
460
461 // Do executes the "mybusinessqanda.locations.questions.create" call.
462 // Any non-2xx status code is an error. Response headers are in either
463 // *Question.ServerResponse.Header or (if a response was returned at all) in
464 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
465 // whether the returned error was because http.StatusNotModified was returned.
466 func (c *LocationsQuestionsCreateCall) Do(opts ...googleapi.CallOption) (*Question, error) {
467 gensupport.SetOptions(c.urlParams_, opts...)
468 res, err := c.doRequest("json")
469 if res != nil && res.StatusCode == http.StatusNotModified {
470 if res.Body != nil {
471 res.Body.Close()
472 }
473 return nil, gensupport.WrapError(&googleapi.Error{
474 Code: res.StatusCode,
475 Header: res.Header,
476 })
477 }
478 if err != nil {
479 return nil, err
480 }
481 defer googleapi.CloseBody(res)
482 if err := googleapi.CheckResponse(res); err != nil {
483 return nil, gensupport.WrapError(err)
484 }
485 ret := &Question{
486 ServerResponse: googleapi.ServerResponse{
487 Header: res.Header,
488 HTTPStatusCode: res.StatusCode,
489 },
490 }
491 target := &ret
492 b, err := gensupport.DecodeResponseBytes(target, res)
493 if err != nil {
494 return nil, err
495 }
496 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "mybusinessqanda.locations.questions.create", "response", internallog.HTTPResponse(res, b))
497 return ret, nil
498 }
499
500 type LocationsQuestionsDeleteCall struct {
501 s *Service
502 name string
503 urlParams_ gensupport.URLParams
504 ctx_ context.Context
505 header_ http.Header
506 }
507
508 // Delete: Deletes a specific question written by the current user.
509 //
510 // - name: The name of the question to delete.
511 func (r *LocationsQuestionsService) Delete(name string) *LocationsQuestionsDeleteCall {
512 c := &LocationsQuestionsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
513 c.name = name
514 return c
515 }
516
517 // Fields allows partial responses to be retrieved. See
518 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
519 // details.
520 func (c *LocationsQuestionsDeleteCall) Fields(s ...googleapi.Field) *LocationsQuestionsDeleteCall {
521 c.urlParams_.Set("fields", googleapi.CombineFields(s))
522 return c
523 }
524
525 // Context sets the context to be used in this call's Do method.
526 func (c *LocationsQuestionsDeleteCall) Context(ctx context.Context) *LocationsQuestionsDeleteCall {
527 c.ctx_ = ctx
528 return c
529 }
530
531 // Header returns a http.Header that can be modified by the caller to add
532 // headers to the request.
533 func (c *LocationsQuestionsDeleteCall) Header() http.Header {
534 if c.header_ == nil {
535 c.header_ = make(http.Header)
536 }
537 return c.header_
538 }
539
540 func (c *LocationsQuestionsDeleteCall) doRequest(alt string) (*http.Response, error) {
541 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
542 c.urlParams_.Set("alt", alt)
543 c.urlParams_.Set("prettyPrint", "false")
544 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
545 urls += "?" + c.urlParams_.Encode()
546 req, err := http.NewRequest("DELETE", urls, nil)
547 if err != nil {
548 return nil, err
549 }
550 req.Header = reqHeaders
551 googleapi.Expand(req.URL, map[string]string{
552 "name": c.name,
553 })
554 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "mybusinessqanda.locations.questions.delete", "request", internallog.HTTPRequest(req, nil))
555 return gensupport.SendRequest(c.ctx_, c.s.client, req)
556 }
557
558 // Do executes the "mybusinessqanda.locations.questions.delete" call.
559 // Any non-2xx status code is an error. Response headers are in either
560 // *Empty.ServerResponse.Header or (if a response was returned at all) in
561 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
562 // whether the returned error was because http.StatusNotModified was returned.
563 func (c *LocationsQuestionsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
564 gensupport.SetOptions(c.urlParams_, opts...)
565 res, err := c.doRequest("json")
566 if res != nil && res.StatusCode == http.StatusNotModified {
567 if res.Body != nil {
568 res.Body.Close()
569 }
570 return nil, gensupport.WrapError(&googleapi.Error{
571 Code: res.StatusCode,
572 Header: res.Header,
573 })
574 }
575 if err != nil {
576 return nil, err
577 }
578 defer googleapi.CloseBody(res)
579 if err := googleapi.CheckResponse(res); err != nil {
580 return nil, gensupport.WrapError(err)
581 }
582 ret := &Empty{
583 ServerResponse: googleapi.ServerResponse{
584 Header: res.Header,
585 HTTPStatusCode: res.StatusCode,
586 },
587 }
588 target := &ret
589 b, err := gensupport.DecodeResponseBytes(target, res)
590 if err != nil {
591 return nil, err
592 }
593 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "mybusinessqanda.locations.questions.delete", "response", internallog.HTTPResponse(res, b))
594 return ret, nil
595 }
596
597 type LocationsQuestionsListCall struct {
598 s *Service
599 parent string
600 urlParams_ gensupport.URLParams
601 ifNoneMatch_ string
602 ctx_ context.Context
603 header_ http.Header
604 }
605
606 // List: Returns the paginated list of questions and some of its answers for a
607 // specified location. This operation is only valid if the specified location
608 // is verified.
609 //
610 // - parent: The name of the location to fetch questions for.
611 func (r *LocationsQuestionsService) List(parent string) *LocationsQuestionsListCall {
612 c := &LocationsQuestionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
613 c.parent = parent
614 return c
615 }
616
617 // AnswersPerQuestion sets the optional parameter "answersPerQuestion": How
618 // many answers to fetch per question. The default and maximum
619 // `answers_per_question` values are 10.
620 func (c *LocationsQuestionsListCall) AnswersPerQuestion(answersPerQuestion int64) *LocationsQuestionsListCall {
621 c.urlParams_.Set("answersPerQuestion", fmt.Sprint(answersPerQuestion))
622 return c
623 }
624
625 // Filter sets the optional parameter "filter": A filter constraining the
626 // questions to return. The only filter currently supported is
627 // "ignore_answered=true"
628 func (c *LocationsQuestionsListCall) Filter(filter string) *LocationsQuestionsListCall {
629 c.urlParams_.Set("filter", filter)
630 return c
631 }
632
633 // OrderBy sets the optional parameter "orderBy": The order to return the
634 // questions. Valid options include 'update_time desc' and 'upvote_count desc',
635 // which will return the questions sorted descendingly by the requested field.
636 // The default sort order is 'update_time desc'.
637 func (c *LocationsQuestionsListCall) OrderBy(orderBy string) *LocationsQuestionsListCall {
638 c.urlParams_.Set("orderBy", orderBy)
639 return c
640 }
641
642 // PageSize sets the optional parameter "pageSize": How many questions to fetch
643 // per page. The default and maximum `page_size` values are 10.
644 func (c *LocationsQuestionsListCall) PageSize(pageSize int64) *LocationsQuestionsListCall {
645 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
646 return c
647 }
648
649 // PageToken sets the optional parameter "pageToken": If specified, the next
650 // page of questions is retrieved.
651 func (c *LocationsQuestionsListCall) PageToken(pageToken string) *LocationsQuestionsListCall {
652 c.urlParams_.Set("pageToken", pageToken)
653 return c
654 }
655
656 // Fields allows partial responses to be retrieved. See
657 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
658 // details.
659 func (c *LocationsQuestionsListCall) Fields(s ...googleapi.Field) *LocationsQuestionsListCall {
660 c.urlParams_.Set("fields", googleapi.CombineFields(s))
661 return c
662 }
663
664 // IfNoneMatch sets an optional parameter which makes the operation fail if the
665 // object's ETag matches the given value. This is useful for getting updates
666 // only after the object has changed since the last request.
667 func (c *LocationsQuestionsListCall) IfNoneMatch(entityTag string) *LocationsQuestionsListCall {
668 c.ifNoneMatch_ = entityTag
669 return c
670 }
671
672 // Context sets the context to be used in this call's Do method.
673 func (c *LocationsQuestionsListCall) Context(ctx context.Context) *LocationsQuestionsListCall {
674 c.ctx_ = ctx
675 return c
676 }
677
678 // Header returns a http.Header that can be modified by the caller to add
679 // headers to the request.
680 func (c *LocationsQuestionsListCall) Header() http.Header {
681 if c.header_ == nil {
682 c.header_ = make(http.Header)
683 }
684 return c.header_
685 }
686
687 func (c *LocationsQuestionsListCall) doRequest(alt string) (*http.Response, error) {
688 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
689 if c.ifNoneMatch_ != "" {
690 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
691 }
692 c.urlParams_.Set("alt", alt)
693 c.urlParams_.Set("prettyPrint", "false")
694 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}")
695 urls += "?" + c.urlParams_.Encode()
696 req, err := http.NewRequest("GET", urls, nil)
697 if err != nil {
698 return nil, err
699 }
700 req.Header = reqHeaders
701 googleapi.Expand(req.URL, map[string]string{
702 "parent": c.parent,
703 })
704 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "mybusinessqanda.locations.questions.list", "request", internallog.HTTPRequest(req, nil))
705 return gensupport.SendRequest(c.ctx_, c.s.client, req)
706 }
707
708 // Do executes the "mybusinessqanda.locations.questions.list" call.
709 // Any non-2xx status code is an error. Response headers are in either
710 // *ListQuestionsResponse.ServerResponse.Header or (if a response was returned
711 // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
712 // check whether the returned error was because http.StatusNotModified was
713 // returned.
714 func (c *LocationsQuestionsListCall) Do(opts ...googleapi.CallOption) (*ListQuestionsResponse, error) {
715 gensupport.SetOptions(c.urlParams_, opts...)
716 res, err := c.doRequest("json")
717 if res != nil && res.StatusCode == http.StatusNotModified {
718 if res.Body != nil {
719 res.Body.Close()
720 }
721 return nil, gensupport.WrapError(&googleapi.Error{
722 Code: res.StatusCode,
723 Header: res.Header,
724 })
725 }
726 if err != nil {
727 return nil, err
728 }
729 defer googleapi.CloseBody(res)
730 if err := googleapi.CheckResponse(res); err != nil {
731 return nil, gensupport.WrapError(err)
732 }
733 ret := &ListQuestionsResponse{
734 ServerResponse: googleapi.ServerResponse{
735 Header: res.Header,
736 HTTPStatusCode: res.StatusCode,
737 },
738 }
739 target := &ret
740 b, err := gensupport.DecodeResponseBytes(target, res)
741 if err != nil {
742 return nil, err
743 }
744 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "mybusinessqanda.locations.questions.list", "response", internallog.HTTPResponse(res, b))
745 return ret, nil
746 }
747
748 // Pages invokes f for each page of results.
749 // A non-nil error returned from f will halt the iteration.
750 // The provided context supersedes any context provided to the Context method.
751 func (c *LocationsQuestionsListCall) Pages(ctx context.Context, f func(*ListQuestionsResponse) error) error {
752 c.ctx_ = ctx
753 defer c.PageToken(c.urlParams_.Get("pageToken"))
754 for {
755 x, err := c.Do()
756 if err != nil {
757 return err
758 }
759 if err := f(x); err != nil {
760 return err
761 }
762 if x.NextPageToken == "" {
763 return nil
764 }
765 c.PageToken(x.NextPageToken)
766 }
767 }
768
769 type LocationsQuestionsPatchCall struct {
770 s *Service
771 name string
772 question *Question
773 urlParams_ gensupport.URLParams
774 ctx_ context.Context
775 header_ http.Header
776 }
777
778 // Patch: Updates a specific question written by the current user.
779 //
780 // - name: Immutable. The unique name for the question. locations/*/questions/*
781 // This field will be ignored if set during question creation.
782 func (r *LocationsQuestionsService) Patch(name string, question *Question) *LocationsQuestionsPatchCall {
783 c := &LocationsQuestionsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
784 c.name = name
785 c.question = question
786 return c
787 }
788
789 // UpdateMask sets the optional parameter "updateMask": Required. The specific
790 // fields to update. Only question text can be updated.
791 func (c *LocationsQuestionsPatchCall) UpdateMask(updateMask string) *LocationsQuestionsPatchCall {
792 c.urlParams_.Set("updateMask", updateMask)
793 return c
794 }
795
796 // Fields allows partial responses to be retrieved. See
797 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
798 // details.
799 func (c *LocationsQuestionsPatchCall) Fields(s ...googleapi.Field) *LocationsQuestionsPatchCall {
800 c.urlParams_.Set("fields", googleapi.CombineFields(s))
801 return c
802 }
803
804 // Context sets the context to be used in this call's Do method.
805 func (c *LocationsQuestionsPatchCall) Context(ctx context.Context) *LocationsQuestionsPatchCall {
806 c.ctx_ = ctx
807 return c
808 }
809
810 // Header returns a http.Header that can be modified by the caller to add
811 // headers to the request.
812 func (c *LocationsQuestionsPatchCall) Header() http.Header {
813 if c.header_ == nil {
814 c.header_ = make(http.Header)
815 }
816 return c.header_
817 }
818
819 func (c *LocationsQuestionsPatchCall) doRequest(alt string) (*http.Response, error) {
820 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
821 body, err := googleapi.WithoutDataWrapper.JSONBuffer(c.question)
822 if err != nil {
823 return nil, err
824 }
825 c.urlParams_.Set("alt", alt)
826 c.urlParams_.Set("prettyPrint", "false")
827 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
828 urls += "?" + c.urlParams_.Encode()
829 req, err := http.NewRequest("PATCH", urls, body)
830 if err != nil {
831 return nil, err
832 }
833 req.Header = reqHeaders
834 googleapi.Expand(req.URL, map[string]string{
835 "name": c.name,
836 })
837 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "mybusinessqanda.locations.questions.patch", "request", internallog.HTTPRequest(req, body.Bytes()))
838 return gensupport.SendRequest(c.ctx_, c.s.client, req)
839 }
840
841 // Do executes the "mybusinessqanda.locations.questions.patch" call.
842 // Any non-2xx status code is an error. Response headers are in either
843 // *Question.ServerResponse.Header or (if a response was returned at all) in
844 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
845 // whether the returned error was because http.StatusNotModified was returned.
846 func (c *LocationsQuestionsPatchCall) Do(opts ...googleapi.CallOption) (*Question, error) {
847 gensupport.SetOptions(c.urlParams_, opts...)
848 res, err := c.doRequest("json")
849 if res != nil && res.StatusCode == http.StatusNotModified {
850 if res.Body != nil {
851 res.Body.Close()
852 }
853 return nil, gensupport.WrapError(&googleapi.Error{
854 Code: res.StatusCode,
855 Header: res.Header,
856 })
857 }
858 if err != nil {
859 return nil, err
860 }
861 defer googleapi.CloseBody(res)
862 if err := googleapi.CheckResponse(res); err != nil {
863 return nil, gensupport.WrapError(err)
864 }
865 ret := &Question{
866 ServerResponse: googleapi.ServerResponse{
867 Header: res.Header,
868 HTTPStatusCode: res.StatusCode,
869 },
870 }
871 target := &ret
872 b, err := gensupport.DecodeResponseBytes(target, res)
873 if err != nil {
874 return nil, err
875 }
876 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "mybusinessqanda.locations.questions.patch", "response", internallog.HTTPResponse(res, b))
877 return ret, nil
878 }
879
880 type LocationsQuestionsAnswersDeleteCall struct {
881 s *Service
882 name string
883 urlParams_ gensupport.URLParams
884 ctx_ context.Context
885 header_ http.Header
886 }
887
888 // Delete: Deletes the answer written by the current user to a question.
889 //
890 // - name: The name of the question to delete an answer for.
891 func (r *LocationsQuestionsAnswersService) Delete(name string) *LocationsQuestionsAnswersDeleteCall {
892 c := &LocationsQuestionsAnswersDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
893 c.name = name
894 return c
895 }
896
897 // Fields allows partial responses to be retrieved. See
898 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
899 // details.
900 func (c *LocationsQuestionsAnswersDeleteCall) Fields(s ...googleapi.Field) *LocationsQuestionsAnswersDeleteCall {
901 c.urlParams_.Set("fields", googleapi.CombineFields(s))
902 return c
903 }
904
905 // Context sets the context to be used in this call's Do method.
906 func (c *LocationsQuestionsAnswersDeleteCall) Context(ctx context.Context) *LocationsQuestionsAnswersDeleteCall {
907 c.ctx_ = ctx
908 return c
909 }
910
911 // Header returns a http.Header that can be modified by the caller to add
912 // headers to the request.
913 func (c *LocationsQuestionsAnswersDeleteCall) Header() http.Header {
914 if c.header_ == nil {
915 c.header_ = make(http.Header)
916 }
917 return c.header_
918 }
919
920 func (c *LocationsQuestionsAnswersDeleteCall) doRequest(alt string) (*http.Response, error) {
921 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
922 c.urlParams_.Set("alt", alt)
923 c.urlParams_.Set("prettyPrint", "false")
924 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}/answers:delete")
925 urls += "?" + c.urlParams_.Encode()
926 req, err := http.NewRequest("DELETE", urls, nil)
927 if err != nil {
928 return nil, err
929 }
930 req.Header = reqHeaders
931 googleapi.Expand(req.URL, map[string]string{
932 "name": c.name,
933 })
934 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "mybusinessqanda.locations.questions.answers.delete", "request", internallog.HTTPRequest(req, nil))
935 return gensupport.SendRequest(c.ctx_, c.s.client, req)
936 }
937
938 // Do executes the "mybusinessqanda.locations.questions.answers.delete" call.
939 // Any non-2xx status code is an error. Response headers are in either
940 // *Empty.ServerResponse.Header or (if a response was returned at all) in
941 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
942 // whether the returned error was because http.StatusNotModified was returned.
943 func (c *LocationsQuestionsAnswersDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
944 gensupport.SetOptions(c.urlParams_, opts...)
945 res, err := c.doRequest("json")
946 if res != nil && res.StatusCode == http.StatusNotModified {
947 if res.Body != nil {
948 res.Body.Close()
949 }
950 return nil, gensupport.WrapError(&googleapi.Error{
951 Code: res.StatusCode,
952 Header: res.Header,
953 })
954 }
955 if err != nil {
956 return nil, err
957 }
958 defer googleapi.CloseBody(res)
959 if err := googleapi.CheckResponse(res); err != nil {
960 return nil, gensupport.WrapError(err)
961 }
962 ret := &Empty{
963 ServerResponse: googleapi.ServerResponse{
964 Header: res.Header,
965 HTTPStatusCode: res.StatusCode,
966 },
967 }
968 target := &ret
969 b, err := gensupport.DecodeResponseBytes(target, res)
970 if err != nil {
971 return nil, err
972 }
973 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "mybusinessqanda.locations.questions.answers.delete", "response", internallog.HTTPResponse(res, b))
974 return ret, nil
975 }
976
977 type LocationsQuestionsAnswersListCall struct {
978 s *Service
979 parent string
980 urlParams_ gensupport.URLParams
981 ifNoneMatch_ string
982 ctx_ context.Context
983 header_ http.Header
984 }
985
986 // List: Returns the paginated list of answers for a specified question.
987 //
988 // - parent: The name of the question to fetch answers for.
989 func (r *LocationsQuestionsAnswersService) List(parent string) *LocationsQuestionsAnswersListCall {
990 c := &LocationsQuestionsAnswersListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
991 c.parent = parent
992 return c
993 }
994
995 // OrderBy sets the optional parameter "orderBy": The order to return the
996 // answers. Valid options include 'update_time desc' and 'upvote_count desc',
997 // which will return the answers sorted descendingly by the requested field.
998 // The default sort order is 'update_time desc'.
999 func (c *LocationsQuestionsAnswersListCall) OrderBy(orderBy string) *LocationsQuestionsAnswersListCall {
1000 c.urlParams_.Set("orderBy", orderBy)
1001 return c
1002 }
1003
1004 // PageSize sets the optional parameter "pageSize": How many answers to fetch
1005 // per page. The default and maximum `page_size` values are 10.
1006 func (c *LocationsQuestionsAnswersListCall) PageSize(pageSize int64) *LocationsQuestionsAnswersListCall {
1007 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
1008 return c
1009 }
1010
1011 // PageToken sets the optional parameter "pageToken": If specified, the next
1012 // page of answers is retrieved.
1013 func (c *LocationsQuestionsAnswersListCall) PageToken(pageToken string) *LocationsQuestionsAnswersListCall {
1014 c.urlParams_.Set("pageToken", pageToken)
1015 return c
1016 }
1017
1018 // Fields allows partial responses to be retrieved. See
1019 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
1020 // details.
1021 func (c *LocationsQuestionsAnswersListCall) Fields(s ...googleapi.Field) *LocationsQuestionsAnswersListCall {
1022 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1023 return c
1024 }
1025
1026 // IfNoneMatch sets an optional parameter which makes the operation fail if the
1027 // object's ETag matches the given value. This is useful for getting updates
1028 // only after the object has changed since the last request.
1029 func (c *LocationsQuestionsAnswersListCall) IfNoneMatch(entityTag string) *LocationsQuestionsAnswersListCall {
1030 c.ifNoneMatch_ = entityTag
1031 return c
1032 }
1033
1034 // Context sets the context to be used in this call's Do method.
1035 func (c *LocationsQuestionsAnswersListCall) Context(ctx context.Context) *LocationsQuestionsAnswersListCall {
1036 c.ctx_ = ctx
1037 return c
1038 }
1039
1040 // Header returns a http.Header that can be modified by the caller to add
1041 // headers to the request.
1042 func (c *LocationsQuestionsAnswersListCall) Header() http.Header {
1043 if c.header_ == nil {
1044 c.header_ = make(http.Header)
1045 }
1046 return c.header_
1047 }
1048
1049 func (c *LocationsQuestionsAnswersListCall) doRequest(alt string) (*http.Response, error) {
1050 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1051 if c.ifNoneMatch_ != "" {
1052 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1053 }
1054 c.urlParams_.Set("alt", alt)
1055 c.urlParams_.Set("prettyPrint", "false")
1056 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/answers")
1057 urls += "?" + c.urlParams_.Encode()
1058 req, err := http.NewRequest("GET", urls, nil)
1059 if err != nil {
1060 return nil, err
1061 }
1062 req.Header = reqHeaders
1063 googleapi.Expand(req.URL, map[string]string{
1064 "parent": c.parent,
1065 })
1066 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "mybusinessqanda.locations.questions.answers.list", "request", internallog.HTTPRequest(req, nil))
1067 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1068 }
1069
1070 // Do executes the "mybusinessqanda.locations.questions.answers.list" call.
1071 // Any non-2xx status code is an error. Response headers are in either
1072 // *ListAnswersResponse.ServerResponse.Header or (if a response was returned at
1073 // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
1074 // check whether the returned error was because http.StatusNotModified was
1075 // returned.
1076 func (c *LocationsQuestionsAnswersListCall) Do(opts ...googleapi.CallOption) (*ListAnswersResponse, error) {
1077 gensupport.SetOptions(c.urlParams_, opts...)
1078 res, err := c.doRequest("json")
1079 if res != nil && res.StatusCode == http.StatusNotModified {
1080 if res.Body != nil {
1081 res.Body.Close()
1082 }
1083 return nil, gensupport.WrapError(&googleapi.Error{
1084 Code: res.StatusCode,
1085 Header: res.Header,
1086 })
1087 }
1088 if err != nil {
1089 return nil, err
1090 }
1091 defer googleapi.CloseBody(res)
1092 if err := googleapi.CheckResponse(res); err != nil {
1093 return nil, gensupport.WrapError(err)
1094 }
1095 ret := &ListAnswersResponse{
1096 ServerResponse: googleapi.ServerResponse{
1097 Header: res.Header,
1098 HTTPStatusCode: res.StatusCode,
1099 },
1100 }
1101 target := &ret
1102 b, err := gensupport.DecodeResponseBytes(target, res)
1103 if err != nil {
1104 return nil, err
1105 }
1106 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "mybusinessqanda.locations.questions.answers.list", "response", internallog.HTTPResponse(res, b))
1107 return ret, nil
1108 }
1109
1110 // Pages invokes f for each page of results.
1111 // A non-nil error returned from f will halt the iteration.
1112 // The provided context supersedes any context provided to the Context method.
1113 func (c *LocationsQuestionsAnswersListCall) Pages(ctx context.Context, f func(*ListAnswersResponse) error) error {
1114 c.ctx_ = ctx
1115 defer c.PageToken(c.urlParams_.Get("pageToken"))
1116 for {
1117 x, err := c.Do()
1118 if err != nil {
1119 return err
1120 }
1121 if err := f(x); err != nil {
1122 return err
1123 }
1124 if x.NextPageToken == "" {
1125 return nil
1126 }
1127 c.PageToken(x.NextPageToken)
1128 }
1129 }
1130
1131 type LocationsQuestionsAnswersUpsertCall struct {
1132 s *Service
1133 parent string
1134 upsertanswerrequest *UpsertAnswerRequest
1135 urlParams_ gensupport.URLParams
1136 ctx_ context.Context
1137 header_ http.Header
1138 }
1139
1140 // Upsert: Creates an answer or updates the existing answer written by the user
1141 // for the specified question. A user can only create one answer per question.
1142 //
1143 // - parent: The name of the question to write an answer for.
1144 func (r *LocationsQuestionsAnswersService) Upsert(parent string, upsertanswerrequest *UpsertAnswerRequest) *LocationsQuestionsAnswersUpsertCall {
1145 c := &LocationsQuestionsAnswersUpsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1146 c.parent = parent
1147 c.upsertanswerrequest = upsertanswerrequest
1148 return c
1149 }
1150
1151 // Fields allows partial responses to be retrieved. See
1152 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
1153 // details.
1154 func (c *LocationsQuestionsAnswersUpsertCall) Fields(s ...googleapi.Field) *LocationsQuestionsAnswersUpsertCall {
1155 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1156 return c
1157 }
1158
1159 // Context sets the context to be used in this call's Do method.
1160 func (c *LocationsQuestionsAnswersUpsertCall) Context(ctx context.Context) *LocationsQuestionsAnswersUpsertCall {
1161 c.ctx_ = ctx
1162 return c
1163 }
1164
1165 // Header returns a http.Header that can be modified by the caller to add
1166 // headers to the request.
1167 func (c *LocationsQuestionsAnswersUpsertCall) Header() http.Header {
1168 if c.header_ == nil {
1169 c.header_ = make(http.Header)
1170 }
1171 return c.header_
1172 }
1173
1174 func (c *LocationsQuestionsAnswersUpsertCall) doRequest(alt string) (*http.Response, error) {
1175 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1176 body, err := googleapi.WithoutDataWrapper.JSONBuffer(c.upsertanswerrequest)
1177 if err != nil {
1178 return nil, err
1179 }
1180 c.urlParams_.Set("alt", alt)
1181 c.urlParams_.Set("prettyPrint", "false")
1182 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/answers:upsert")
1183 urls += "?" + c.urlParams_.Encode()
1184 req, err := http.NewRequest("POST", urls, body)
1185 if err != nil {
1186 return nil, err
1187 }
1188 req.Header = reqHeaders
1189 googleapi.Expand(req.URL, map[string]string{
1190 "parent": c.parent,
1191 })
1192 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "mybusinessqanda.locations.questions.answers.upsert", "request", internallog.HTTPRequest(req, body.Bytes()))
1193 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1194 }
1195
1196 // Do executes the "mybusinessqanda.locations.questions.answers.upsert" call.
1197 // Any non-2xx status code is an error. Response headers are in either
1198 // *Answer.ServerResponse.Header or (if a response was returned at all) in
1199 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
1200 // whether the returned error was because http.StatusNotModified was returned.
1201 func (c *LocationsQuestionsAnswersUpsertCall) Do(opts ...googleapi.CallOption) (*Answer, error) {
1202 gensupport.SetOptions(c.urlParams_, opts...)
1203 res, err := c.doRequest("json")
1204 if res != nil && res.StatusCode == http.StatusNotModified {
1205 if res.Body != nil {
1206 res.Body.Close()
1207 }
1208 return nil, gensupport.WrapError(&googleapi.Error{
1209 Code: res.StatusCode,
1210 Header: res.Header,
1211 })
1212 }
1213 if err != nil {
1214 return nil, err
1215 }
1216 defer googleapi.CloseBody(res)
1217 if err := googleapi.CheckResponse(res); err != nil {
1218 return nil, gensupport.WrapError(err)
1219 }
1220 ret := &Answer{
1221 ServerResponse: googleapi.ServerResponse{
1222 Header: res.Header,
1223 HTTPStatusCode: res.StatusCode,
1224 },
1225 }
1226 target := &ret
1227 b, err := gensupport.DecodeResponseBytes(target, res)
1228 if err != nil {
1229 return nil, err
1230 }
1231 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "mybusinessqanda.locations.questions.answers.upsert", "response", internallog.HTTPResponse(res, b))
1232 return ret, nil
1233 }