...

Source file src/google.golang.org/api/mybusinessqanda/v1/mybusinessqanda-gen.go

Documentation: google.golang.org/api/mybusinessqanda/v1

     1  // Copyright 2024 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  	"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  // Always reference these packages, just in case the auto-generated code
    74  // below doesn't.
    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  // NewService creates a new Service.
    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  // New creates a new Service. It uses the provided http.Client for requests.
   117  //
   118  // Deprecated: please use NewService instead.
   119  // To provide a custom HTTP client, use option.WithHTTPClient.
   120  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   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 // API endpoint base URL
   133  	UserAgent string // optional additional User-Agent fragment
   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  // Answer: Represents an answer to a question
   179  type Answer struct {
   180  	// Author: Output only. The author of the answer. Will only be set during list
   181  	// operations.
   182  	Author *Author `json:"author,omitempty"`
   183  	// CreateTime: Output only. The timestamp for when the answer was written. Only
   184  	// retrieved during ListResponse fetching.
   185  	CreateTime string `json:"createTime,omitempty"`
   186  	// Name: Output only. The unique name for the answer
   187  	// locations/*/questions/*/answers/*
   188  	Name string `json:"name,omitempty"`
   189  	// Text: Required. The text of the answer. It should contain at least one
   190  	// non-whitespace character. The maximum length is 4096 characters.
   191  	Text string `json:"text,omitempty"`
   192  	// UpdateTime: Output only. The timestamp for when the answer was last
   193  	// modified.
   194  	UpdateTime string `json:"updateTime,omitempty"`
   195  	// UpvoteCount: Output only. The number of upvotes for the answer.
   196  	UpvoteCount int64 `json:"upvoteCount,omitempty"`
   197  
   198  	// ServerResponse contains the HTTP response code and headers from the server.
   199  	googleapi.ServerResponse `json:"-"`
   200  	// ForceSendFields is a list of field names (e.g. "Author") to unconditionally
   201  	// include in API requests. By default, fields with empty or default values are
   202  	// omitted from API requests. See
   203  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   204  	// details.
   205  	ForceSendFields []string `json:"-"`
   206  	// NullFields is a list of field names (e.g. "Author") to include in API
   207  	// requests with the JSON null value. By default, fields with empty values are
   208  	// omitted from API requests. See
   209  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // Author: Represents the author of a question or answer
   219  type Author struct {
   220  	// DisplayName: The display name of the user
   221  	DisplayName string `json:"displayName,omitempty"`
   222  	// ProfilePhotoUri: The profile photo URI of the user.
   223  	ProfilePhotoUri string `json:"profilePhotoUri,omitempty"`
   224  	// Type: The type of user the author is.
   225  	//
   226  	// Possible values:
   227  	//   "AUTHOR_TYPE_UNSPECIFIED" - This should not be used.
   228  	//   "REGULAR_USER" - A regular user.
   229  	//   "LOCAL_GUIDE" - A Local Guide
   230  	//   "MERCHANT" - The owner/manager of the location
   231  	Type string `json:"type,omitempty"`
   232  	// ForceSendFields is a list of field names (e.g. "DisplayName") to
   233  	// unconditionally include in API requests. By default, fields with empty or
   234  	// default values are omitted from API requests. See
   235  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   236  	// details.
   237  	ForceSendFields []string `json:"-"`
   238  	// NullFields is a list of field names (e.g. "DisplayName") to include in API
   239  	// requests with the JSON null value. By default, fields with empty values are
   240  	// omitted from API requests. See
   241  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // Empty: A generic empty message that you can re-use to avoid defining
   251  // duplicated empty messages in your APIs. A typical example is to use it as
   252  // the request or the response type of an API method. For instance: service Foo
   253  // { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
   254  type Empty struct {
   255  	// ServerResponse contains the HTTP response code and headers from the server.
   256  	googleapi.ServerResponse `json:"-"`
   257  }
   258  
   259  // ListAnswersResponse: Response message for QuestionsAndAnswers.ListAnswers
   260  type ListAnswersResponse struct {
   261  	// Answers: The requested answers.
   262  	Answers []*Answer `json:"answers,omitempty"`
   263  	// NextPageToken: If the number of answers exceeds the requested max page size,
   264  	// this field is populated with a token to fetch the next page of answers on a
   265  	// subsequent call. If there are no more answers, this field is not present in
   266  	// the response.
   267  	NextPageToken string `json:"nextPageToken,omitempty"`
   268  	// TotalSize: The total number of answers posted for this question across all
   269  	// pages.
   270  	TotalSize int64 `json:"totalSize,omitempty"`
   271  
   272  	// ServerResponse contains the HTTP response code and headers from the server.
   273  	googleapi.ServerResponse `json:"-"`
   274  	// ForceSendFields is a list of field names (e.g. "Answers") to unconditionally
   275  	// include in API requests. By default, fields with empty or default values are
   276  	// omitted from API requests. See
   277  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   278  	// details.
   279  	ForceSendFields []string `json:"-"`
   280  	// NullFields is a list of field names (e.g. "Answers") to include in API
   281  	// requests with the JSON null value. By default, fields with empty values are
   282  	// omitted from API requests. See
   283  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // ListQuestionsResponse: Response message for
   293  // QuestionsAndAnswers.ListQuestions
   294  type ListQuestionsResponse struct {
   295  	// NextPageToken: If the number of questions exceeds the requested max page
   296  	// size, this field is populated with a token to fetch the next page of
   297  	// questions on a subsequent call. If there are no more questions, this field
   298  	// is not present in the response.
   299  	NextPageToken string `json:"nextPageToken,omitempty"`
   300  	// Questions: The requested questions,
   301  	Questions []*Question `json:"questions,omitempty"`
   302  	// TotalSize: The total number of questions posted for this location across all
   303  	// pages.
   304  	TotalSize int64 `json:"totalSize,omitempty"`
   305  
   306  	// ServerResponse contains the HTTP response code and headers from the server.
   307  	googleapi.ServerResponse `json:"-"`
   308  	// ForceSendFields is a list of field names (e.g. "NextPageToken") to
   309  	// unconditionally include in API requests. By default, fields with empty or
   310  	// default values are omitted from API requests. See
   311  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   312  	// details.
   313  	ForceSendFields []string `json:"-"`
   314  	// NullFields is a list of field names (e.g. "NextPageToken") to include in API
   315  	// requests with the JSON null value. By default, fields with empty values are
   316  	// omitted from API requests. See
   317  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // Question: Represents a single question and some of its answers.
   327  type Question struct {
   328  	// Author: Output only. The author of the question.
   329  	Author *Author `json:"author,omitempty"`
   330  	// CreateTime: Output only. The timestamp for when the question was written.
   331  	CreateTime string `json:"createTime,omitempty"`
   332  	// Name: Immutable. The unique name for the question. locations/*/questions/*
   333  	// This field will be ignored if set during question creation.
   334  	Name string `json:"name,omitempty"`
   335  	// Text: Required. The text of the question. It should contain at least three
   336  	// words and the total length should be greater than or equal to 10 characters.
   337  	// The maximum length is 4096 characters.
   338  	Text string `json:"text,omitempty"`
   339  	// TopAnswers: Output only. A list of answers to the question, sorted by
   340  	// upvotes. This may not be a complete list of answers depending on the request
   341  	// parameters (answers_per_question)
   342  	TopAnswers []*Answer `json:"topAnswers,omitempty"`
   343  	// TotalAnswerCount: Output only. The total number of answers posted for this
   344  	// question.
   345  	TotalAnswerCount int64 `json:"totalAnswerCount,omitempty"`
   346  	// UpdateTime: Output only. The timestamp for when the question was last
   347  	// modified.
   348  	UpdateTime string `json:"updateTime,omitempty"`
   349  	// UpvoteCount: Output only. The number of upvotes for the question.
   350  	UpvoteCount int64 `json:"upvoteCount,omitempty"`
   351  
   352  	// ServerResponse contains the HTTP response code and headers from the server.
   353  	googleapi.ServerResponse `json:"-"`
   354  	// ForceSendFields is a list of field names (e.g. "Author") to unconditionally
   355  	// include in API requests. By default, fields with empty or default values are
   356  	// omitted from API requests. See
   357  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   358  	// details.
   359  	ForceSendFields []string `json:"-"`
   360  	// NullFields is a list of field names (e.g. "Author") to include in API
   361  	// requests with the JSON null value. By default, fields with empty values are
   362  	// omitted from API requests. See
   363  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // UpsertAnswerRequest: Request message for QuestionsAndAnswers.UpsertAnswer
   373  type UpsertAnswerRequest struct {
   374  	// Answer: Required. The new answer.
   375  	Answer *Answer `json:"answer,omitempty"`
   376  	// ForceSendFields is a list of field names (e.g. "Answer") to unconditionally
   377  	// include in API requests. By default, fields with empty or default values are
   378  	// omitted from API requests. See
   379  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   380  	// details.
   381  	ForceSendFields []string `json:"-"`
   382  	// NullFields is a list of field names (e.g. "Answer") to include in API
   383  	// requests with the JSON null value. By default, fields with empty values are
   384  	// omitted from API requests. See
   385  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   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  // Create: Adds a question for the specified location.
   404  //
   405  // - parent: The name of the location to write a question for.
   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  // Fields allows partial responses to be retrieved. See
   414  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   415  // details.
   416  func (c *LocationsQuestionsCreateCall) Fields(s ...googleapi.Field) *LocationsQuestionsCreateCall {
   417  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   418  	return c
   419  }
   420  
   421  // Context sets the context to be used in this call's Do method.
   422  func (c *LocationsQuestionsCreateCall) Context(ctx context.Context) *LocationsQuestionsCreateCall {
   423  	c.ctx_ = ctx
   424  	return c
   425  }
   426  
   427  // Header returns a http.Header that can be modified by the caller to add
   428  // headers to the request.
   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  // Do executes the "mybusinessqanda.locations.questions.create" call.
   459  // Any non-2xx status code is an error. Response headers are in either
   460  // *Question.ServerResponse.Header or (if a response was returned at all) in
   461  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   462  // whether the returned error was because http.StatusNotModified was returned.
   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  // Delete: Deletes a specific question written by the current user.
   504  //
   505  // - name: The name of the question to delete.
   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  // Fields allows partial responses to be retrieved. See
   513  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   514  // details.
   515  func (c *LocationsQuestionsDeleteCall) Fields(s ...googleapi.Field) *LocationsQuestionsDeleteCall {
   516  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   517  	return c
   518  }
   519  
   520  // Context sets the context to be used in this call's Do method.
   521  func (c *LocationsQuestionsDeleteCall) Context(ctx context.Context) *LocationsQuestionsDeleteCall {
   522  	c.ctx_ = ctx
   523  	return c
   524  }
   525  
   526  // Header returns a http.Header that can be modified by the caller to add
   527  // headers to the request.
   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  // Do executes the "mybusinessqanda.locations.questions.delete" call.
   554  // Any non-2xx status code is an error. Response headers are in either
   555  // *Empty.ServerResponse.Header or (if a response was returned at all) in
   556  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   557  // whether the returned error was because http.StatusNotModified was returned.
   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  // List: Returns the paginated list of questions and some of its answers for a
   600  // specified location. This operation is only valid if the specified location
   601  // is verified.
   602  //
   603  // - parent: The name of the location to fetch questions for.
   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  // AnswersPerQuestion sets the optional parameter "answersPerQuestion": How
   611  // many answers to fetch per question. The default and maximum
   612  // `answers_per_question` values are 10.
   613  func (c *LocationsQuestionsListCall) AnswersPerQuestion(answersPerQuestion int64) *LocationsQuestionsListCall {
   614  	c.urlParams_.Set("answersPerQuestion", fmt.Sprint(answersPerQuestion))
   615  	return c
   616  }
   617  
   618  // Filter sets the optional parameter "filter": A filter constraining the
   619  // questions to return. The only filter currently supported is
   620  // "ignore_answered=true"
   621  func (c *LocationsQuestionsListCall) Filter(filter string) *LocationsQuestionsListCall {
   622  	c.urlParams_.Set("filter", filter)
   623  	return c
   624  }
   625  
   626  // OrderBy sets the optional parameter "orderBy": The order to return the
   627  // questions. Valid options include 'update_time desc' and 'upvote_count desc',
   628  // which will return the questions sorted descendingly by the requested field.
   629  // The default sort order is 'update_time desc'.
   630  func (c *LocationsQuestionsListCall) OrderBy(orderBy string) *LocationsQuestionsListCall {
   631  	c.urlParams_.Set("orderBy", orderBy)
   632  	return c
   633  }
   634  
   635  // PageSize sets the optional parameter "pageSize": How many questions to fetch
   636  // per page. The default and maximum `page_size` values are 10.
   637  func (c *LocationsQuestionsListCall) PageSize(pageSize int64) *LocationsQuestionsListCall {
   638  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   639  	return c
   640  }
   641  
   642  // PageToken sets the optional parameter "pageToken": If specified, the next
   643  // page of questions is retrieved.
   644  func (c *LocationsQuestionsListCall) PageToken(pageToken string) *LocationsQuestionsListCall {
   645  	c.urlParams_.Set("pageToken", pageToken)
   646  	return c
   647  }
   648  
   649  // Fields allows partial responses to be retrieved. See
   650  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   651  // details.
   652  func (c *LocationsQuestionsListCall) Fields(s ...googleapi.Field) *LocationsQuestionsListCall {
   653  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   654  	return c
   655  }
   656  
   657  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   658  // object's ETag matches the given value. This is useful for getting updates
   659  // only after the object has changed since the last request.
   660  func (c *LocationsQuestionsListCall) IfNoneMatch(entityTag string) *LocationsQuestionsListCall {
   661  	c.ifNoneMatch_ = entityTag
   662  	return c
   663  }
   664  
   665  // Context sets the context to be used in this call's Do method.
   666  func (c *LocationsQuestionsListCall) Context(ctx context.Context) *LocationsQuestionsListCall {
   667  	c.ctx_ = ctx
   668  	return c
   669  }
   670  
   671  // Header returns a http.Header that can be modified by the caller to add
   672  // headers to the request.
   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  // Do executes the "mybusinessqanda.locations.questions.list" call.
   702  // Any non-2xx status code is an error. Response headers are in either
   703  // *ListQuestionsResponse.ServerResponse.Header or (if a response was returned
   704  // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   705  // check whether the returned error was because http.StatusNotModified was
   706  // returned.
   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  // Pages invokes f for each page of results.
   740  // A non-nil error returned from f will halt the iteration.
   741  // The provided context supersedes any context provided to the Context method.
   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  // Patch: Updates a specific question written by the current user.
   770  //
   771  //   - name: Immutable. The unique name for the question. locations/*/questions/*
   772  //     This field will be ignored if set during question creation.
   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  // UpdateMask sets the optional parameter "updateMask": Required. The specific
   781  // fields to update. Only question text can be updated.
   782  func (c *LocationsQuestionsPatchCall) UpdateMask(updateMask string) *LocationsQuestionsPatchCall {
   783  	c.urlParams_.Set("updateMask", updateMask)
   784  	return c
   785  }
   786  
   787  // Fields allows partial responses to be retrieved. See
   788  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   789  // details.
   790  func (c *LocationsQuestionsPatchCall) Fields(s ...googleapi.Field) *LocationsQuestionsPatchCall {
   791  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   792  	return c
   793  }
   794  
   795  // Context sets the context to be used in this call's Do method.
   796  func (c *LocationsQuestionsPatchCall) Context(ctx context.Context) *LocationsQuestionsPatchCall {
   797  	c.ctx_ = ctx
   798  	return c
   799  }
   800  
   801  // Header returns a http.Header that can be modified by the caller to add
   802  // headers to the request.
   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  // Do executes the "mybusinessqanda.locations.questions.patch" call.
   833  // Any non-2xx status code is an error. Response headers are in either
   834  // *Question.ServerResponse.Header or (if a response was returned at all) in
   835  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   836  // whether the returned error was because http.StatusNotModified was returned.
   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  // Delete: Deletes the answer written by the current user to a question.
   878  //
   879  // - name: The name of the question to delete an answer for.
   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  // Fields allows partial responses to be retrieved. See
   887  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   888  // details.
   889  func (c *LocationsQuestionsAnswersDeleteCall) Fields(s ...googleapi.Field) *LocationsQuestionsAnswersDeleteCall {
   890  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   891  	return c
   892  }
   893  
   894  // Context sets the context to be used in this call's Do method.
   895  func (c *LocationsQuestionsAnswersDeleteCall) Context(ctx context.Context) *LocationsQuestionsAnswersDeleteCall {
   896  	c.ctx_ = ctx
   897  	return c
   898  }
   899  
   900  // Header returns a http.Header that can be modified by the caller to add
   901  // headers to the request.
   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  // Do executes the "mybusinessqanda.locations.questions.answers.delete" call.
   928  // Any non-2xx status code is an error. Response headers are in either
   929  // *Empty.ServerResponse.Header or (if a response was returned at all) in
   930  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   931  // whether the returned error was because http.StatusNotModified was returned.
   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  // List: Returns the paginated list of answers for a specified question.
   974  //
   975  // - parent: The name of the question to fetch answers for.
   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  // OrderBy sets the optional parameter "orderBy": The order to return the
   983  // answers. Valid options include 'update_time desc' and 'upvote_count desc',
   984  // which will return the answers sorted descendingly by the requested field.
   985  // The default sort order is 'update_time desc'.
   986  func (c *LocationsQuestionsAnswersListCall) OrderBy(orderBy string) *LocationsQuestionsAnswersListCall {
   987  	c.urlParams_.Set("orderBy", orderBy)
   988  	return c
   989  }
   990  
   991  // PageSize sets the optional parameter "pageSize": How many answers to fetch
   992  // per page. The default and maximum `page_size` values are 10.
   993  func (c *LocationsQuestionsAnswersListCall) PageSize(pageSize int64) *LocationsQuestionsAnswersListCall {
   994  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   995  	return c
   996  }
   997  
   998  // PageToken sets the optional parameter "pageToken": If specified, the next
   999  // page of answers is retrieved.
  1000  func (c *LocationsQuestionsAnswersListCall) PageToken(pageToken string) *LocationsQuestionsAnswersListCall {
  1001  	c.urlParams_.Set("pageToken", pageToken)
  1002  	return c
  1003  }
  1004  
  1005  // Fields allows partial responses to be retrieved. See
  1006  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1007  // details.
  1008  func (c *LocationsQuestionsAnswersListCall) Fields(s ...googleapi.Field) *LocationsQuestionsAnswersListCall {
  1009  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1010  	return c
  1011  }
  1012  
  1013  // IfNoneMatch sets an optional parameter which makes the operation fail if the
  1014  // object's ETag matches the given value. This is useful for getting updates
  1015  // only after the object has changed since the last request.
  1016  func (c *LocationsQuestionsAnswersListCall) IfNoneMatch(entityTag string) *LocationsQuestionsAnswersListCall {
  1017  	c.ifNoneMatch_ = entityTag
  1018  	return c
  1019  }
  1020  
  1021  // Context sets the context to be used in this call's Do method.
  1022  func (c *LocationsQuestionsAnswersListCall) Context(ctx context.Context) *LocationsQuestionsAnswersListCall {
  1023  	c.ctx_ = ctx
  1024  	return c
  1025  }
  1026  
  1027  // Header returns a http.Header that can be modified by the caller to add
  1028  // headers to the request.
  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  // Do executes the "mybusinessqanda.locations.questions.answers.list" call.
  1058  // Any non-2xx status code is an error. Response headers are in either
  1059  // *ListAnswersResponse.ServerResponse.Header or (if a response was returned at
  1060  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1061  // check whether the returned error was because http.StatusNotModified was
  1062  // returned.
  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  // Pages invokes f for each page of results.
  1096  // A non-nil error returned from f will halt the iteration.
  1097  // The provided context supersedes any context provided to the Context method.
  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  // Upsert: Creates an answer or updates the existing answer written by the user
  1126  // for the specified question. A user can only create one answer per question.
  1127  //
  1128  // - parent: The name of the question to write an answer for.
  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  // Fields allows partial responses to be retrieved. See
  1137  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1138  // details.
  1139  func (c *LocationsQuestionsAnswersUpsertCall) Fields(s ...googleapi.Field) *LocationsQuestionsAnswersUpsertCall {
  1140  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1141  	return c
  1142  }
  1143  
  1144  // Context sets the context to be used in this call's Do method.
  1145  func (c *LocationsQuestionsAnswersUpsertCall) Context(ctx context.Context) *LocationsQuestionsAnswersUpsertCall {
  1146  	c.ctx_ = ctx
  1147  	return c
  1148  }
  1149  
  1150  // Header returns a http.Header that can be modified by the caller to add
  1151  // headers to the request.
  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  // Do executes the "mybusinessqanda.locations.questions.answers.upsert" call.
  1182  // Any non-2xx status code is an error. Response headers are in either
  1183  // *Answer.ServerResponse.Header or (if a response was returned at all) in
  1184  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1185  // whether the returned error was because http.StatusNotModified was returned.
  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