1 // Copyright 2020 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 androidpublisher provides access to the Google Play Developer API. 8 // 9 // For product documentation, see: https://developers.google.com/android-publisher 10 // 11 // # Creating a client 12 // 13 // Usage example: 14 // 15 // import "google.golang.org/api/androidpublisher/v1" 16 // ... 17 // ctx := context.Background() 18 // androidpublisherService, err := androidpublisher.NewService(ctx) 19 // 20 // In this example, Google Application Default Credentials are used for authentication. 21 // 22 // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials. 23 // 24 // # Other authentication options 25 // 26 // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey: 27 // 28 // androidpublisherService, err := androidpublisher.NewService(ctx, option.WithAPIKey("AIza...")) 29 // 30 // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource: 31 // 32 // config := &oauth2.Config{...} 33 // // ... 34 // token, err := config.Exchange(ctx, ...) 35 // androidpublisherService, err := androidpublisher.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) 36 // 37 // See https://godoc.org/google.golang.org/api/option/ for details on options. 38 package androidpublisher // import "google.golang.org/api/androidpublisher/v1" 39 40 import ( 41 "bytes" 42 "context" 43 "encoding/json" 44 "errors" 45 "fmt" 46 "io" 47 "net/http" 48 "net/url" 49 "strconv" 50 "strings" 51 52 googleapi "google.golang.org/api/googleapi" 53 gensupport "google.golang.org/api/internal/gensupport" 54 option "google.golang.org/api/option" 55 internaloption "google.golang.org/api/option/internaloption" 56 htransport "google.golang.org/api/transport/http" 57 ) 58 59 // Always reference these packages, just in case the auto-generated code 60 // below doesn't. 61 var _ = bytes.NewBuffer 62 var _ = strconv.Itoa 63 var _ = fmt.Sprintf 64 var _ = json.NewDecoder 65 var _ = io.Copy 66 var _ = url.Parse 67 var _ = gensupport.MarshalJSON 68 var _ = googleapi.Version 69 var _ = errors.New 70 var _ = strings.Replace 71 var _ = context.Canceled 72 var _ = internaloption.WithDefaultEndpoint 73 74 const apiId = "androidpublisher:v1" 75 const apiName = "androidpublisher" 76 const apiVersion = "v1" 77 const basePath = "https://www.googleapis.com/" 78 79 // NewService creates a new Service. 80 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 81 opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) 82 client, endpoint, err := htransport.NewClient(ctx, opts...) 83 if err != nil { 84 return nil, err 85 } 86 s, err := New(client) 87 if err != nil { 88 return nil, err 89 } 90 if endpoint != "" { 91 s.BasePath = endpoint 92 } 93 return s, nil 94 } 95 96 // New creates a new Service. It uses the provided http.Client for requests. 97 // 98 // Deprecated: please use NewService instead. 99 // To provide a custom HTTP client, use option.WithHTTPClient. 100 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. 101 func New(client *http.Client) (*Service, error) { 102 if client == nil { 103 return nil, errors.New("client is nil") 104 } 105 s := &Service{client: client, BasePath: basePath} 106 return s, nil 107 } 108 109 type Service struct { 110 client *http.Client 111 BasePath string // API endpoint base URL 112 UserAgent string // optional additional User-Agent fragment 113 } 114 115 func (s *Service) userAgent() string { 116 if s.UserAgent == "" { 117 return googleapi.UserAgent 118 } 119 return googleapi.UserAgent + " " + s.UserAgent 120 } 121