...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 package youtubeanalytics
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
60
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 = "youtubeAnalytics:v1"
75 const apiName = "youtubeAnalytics"
76 const apiVersion = "v1"
77 const basePath = "https://youtubeanalytics.googleapis.com/"
78 const mtlsBasePath = "https://youtubeanalytics.mtls.googleapis.com/"
79
80
81 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
82 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
83 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
84 client, endpoint, err := htransport.NewClient(ctx, opts...)
85 if err != nil {
86 return nil, err
87 }
88 s, err := New(client)
89 if err != nil {
90 return nil, err
91 }
92 if endpoint != "" {
93 s.BasePath = endpoint
94 }
95 return s, nil
96 }
97
98
99
100
101
102
103 func New(client *http.Client) (*Service, error) {
104 if client == nil {
105 return nil, errors.New("client is nil")
106 }
107 s := &Service{client: client, BasePath: basePath}
108 return s, nil
109 }
110
111 type Service struct {
112 client *http.Client
113 BasePath string
114 UserAgent string
115 }
116
117 func (s *Service) userAgent() string {
118 if s.UserAgent == "" {
119 return googleapi.UserAgent
120 }
121 return googleapi.UserAgent + " " + s.UserAgent
122 }
123
View as plain text