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 adexchangebuyer
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 = "adexchangebuyer:v1.2"
75 const apiName = "adexchangebuyer"
76 const apiVersion = "v1.2"
77 const basePath = "https://www.googleapis.com/adexchangebuyer/v1.2/"
78
79
80 const (
81
82 AdexchangeBuyerScope = "https://www.googleapis.com/auth/adexchange.buyer"
83 )
84
85
86 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
87 scopesOption := option.WithScopes(
88 "https://www.googleapis.com/auth/adexchange.buyer",
89 )
90
91 opts = append([]option.ClientOption{scopesOption}, opts...)
92 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
93 client, endpoint, err := htransport.NewClient(ctx, opts...)
94 if err != nil {
95 return nil, err
96 }
97 s, err := New(client)
98 if err != nil {
99 return nil, err
100 }
101 if endpoint != "" {
102 s.BasePath = endpoint
103 }
104 return s, nil
105 }
106
107
108
109
110
111
112 func New(client *http.Client) (*Service, error) {
113 if client == nil {
114 return nil, errors.New("client is nil")
115 }
116 s := &Service{client: client, BasePath: basePath}
117 s.Accounts = NewAccountsService(s)
118 s.Creatives = NewCreativesService(s)
119 return s, nil
120 }
121
122 type Service struct {
123 client *http.Client
124 BasePath string
125 UserAgent string
126
127 Accounts *AccountsService
128
129 Creatives *CreativesService
130 }
131
132 func (s *Service) userAgent() string {
133 if s.UserAgent == "" {
134 return googleapi.UserAgent
135 }
136 return googleapi.UserAgent + " " + s.UserAgent
137 }
138
139 func NewAccountsService(s *Service) *AccountsService {
140 rs := &AccountsService{s: s}
141 return rs
142 }
143
144 type AccountsService struct {
145 s *Service
146 }
147
148 func NewCreativesService(s *Service) *CreativesService {
149 rs := &CreativesService{s: s}
150 return rs
151 }
152
153 type CreativesService struct {
154 s *Service
155 }
156
157
158 type Account struct {
159
160 BidderLocation []*AccountBidderLocation `json:"bidderLocation,omitempty"`
161
162
163
164
165 CookieMatchingNid string `json:"cookieMatchingNid,omitempty"`
166
167
168 CookieMatchingUrl string `json:"cookieMatchingUrl,omitempty"`
169
170
171 Id int64 `json:"id,omitempty"`
172
173
174 Kind string `json:"kind,omitempty"`
175
176
177
178
179
180 MaximumActiveCreatives int64 `json:"maximumActiveCreatives,omitempty"`
181
182
183
184
185 MaximumTotalQps int64 `json:"maximumTotalQps,omitempty"`
186
187
188
189 NumberActiveCreatives int64 `json:"numberActiveCreatives,omitempty"`
190
191
192
193 googleapi.ServerResponse `json:"-"`
194
195
196
197
198
199
200
201 ForceSendFields []string `json:"-"`
202
203
204
205
206
207
208
209
210 NullFields []string `json:"-"`
211 }
212
213 func (s *Account) MarshalJSON() ([]byte, error) {
214 type NoMethod Account
215 raw := NoMethod(*s)
216 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
217 }
218
219 type AccountBidderLocation struct {
220
221 MaximumQps int64 `json:"maximumQps,omitempty"`
222
223
224
225
226
227
228
229
230 Region string `json:"region,omitempty"`
231
232
233 Url string `json:"url,omitempty"`
234
235
236
237
238
239
240
241 ForceSendFields []string `json:"-"`
242
243
244
245
246
247
248
249 NullFields []string `json:"-"`
250 }
251
252 func (s *AccountBidderLocation) MarshalJSON() ([]byte, error) {
253 type NoMethod AccountBidderLocation
254 raw := NoMethod(*s)
255 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
256 }
257
258
259
260
261 type AccountsList struct {
262
263 Items []*Account `json:"items,omitempty"`
264
265
266 Kind string `json:"kind,omitempty"`
267
268
269
270 googleapi.ServerResponse `json:"-"`
271
272
273
274
275
276
277
278 ForceSendFields []string `json:"-"`
279
280
281
282
283
284
285
286 NullFields []string `json:"-"`
287 }
288
289 func (s *AccountsList) MarshalJSON() ([]byte, error) {
290 type NoMethod AccountsList
291 raw := NoMethod(*s)
292 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
293 }
294
295
296 type Creative struct {
297
298
299 HTMLSnippet string `json:"HTMLSnippet,omitempty"`
300
301
302 AccountId int64 `json:"accountId,omitempty"`
303
304
305
306 AdvertiserId googleapi.Int64s `json:"advertiserId,omitempty"`
307
308
309
310 AdvertiserName string `json:"advertiserName,omitempty"`
311
312
313 AgencyId int64 `json:"agencyId,omitempty,string"`
314
315
316
317
318
319 ApiUploadTimestamp string `json:"apiUploadTimestamp,omitempty"`
320
321
322
323 Attribute []int64 `json:"attribute,omitempty"`
324
325
326
327 BuyerCreativeId string `json:"buyerCreativeId,omitempty"`
328
329
330 ClickThroughUrl []string `json:"clickThroughUrl,omitempty"`
331
332
333
334 Corrections []*CreativeCorrections `json:"corrections,omitempty"`
335
336
337
338
339
340
341
342 DisapprovalReasons []*CreativeDisapprovalReasons `json:"disapprovalReasons,omitempty"`
343
344
345
346 FilteringReasons *CreativeFilteringReasons `json:"filteringReasons,omitempty"`
347
348
349 Height int64 `json:"height,omitempty"`
350
351
352
353 ImpressionTrackingUrl []string `json:"impressionTrackingUrl,omitempty"`
354
355
356 Kind string `json:"kind,omitempty"`
357
358
359
360 ProductCategories []int64 `json:"productCategories,omitempty"`
361
362
363
364 RestrictedCategories []int64 `json:"restrictedCategories,omitempty"`
365
366
367
368 SensitiveCategories []int64 `json:"sensitiveCategories,omitempty"`
369
370
371
372 Status string `json:"status,omitempty"`
373
374
375
376 VendorType []int64 `json:"vendorType,omitempty"`
377
378
379
380 Version int64 `json:"version,omitempty"`
381
382
383
384 VideoURL string `json:"videoURL,omitempty"`
385
386
387 Width int64 `json:"width,omitempty"`
388
389
390
391 googleapi.ServerResponse `json:"-"`
392
393
394
395
396
397
398
399 ForceSendFields []string `json:"-"`
400
401
402
403
404
405
406
407 NullFields []string `json:"-"`
408 }
409
410 func (s *Creative) MarshalJSON() ([]byte, error) {
411 type NoMethod Creative
412 raw := NoMethod(*s)
413 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
414 }
415
416 type CreativeCorrections struct {
417
418 Details []string `json:"details,omitempty"`
419
420
421 Reason string `json:"reason,omitempty"`
422
423
424
425
426
427
428
429 ForceSendFields []string `json:"-"`
430
431
432
433
434
435
436
437 NullFields []string `json:"-"`
438 }
439
440 func (s *CreativeCorrections) MarshalJSON() ([]byte, error) {
441 type NoMethod CreativeCorrections
442 raw := NoMethod(*s)
443 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
444 }
445
446 type CreativeDisapprovalReasons struct {
447
448 Details []string `json:"details,omitempty"`
449
450
451 Reason string `json:"reason,omitempty"`
452
453
454
455
456
457
458
459 ForceSendFields []string `json:"-"`
460
461
462
463
464
465
466
467 NullFields []string `json:"-"`
468 }
469
470 func (s *CreativeDisapprovalReasons) MarshalJSON() ([]byte, error) {
471 type NoMethod CreativeDisapprovalReasons
472 raw := NoMethod(*s)
473 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
474 }
475
476
477
478 type CreativeFilteringReasons struct {
479
480
481 Date string `json:"date,omitempty"`
482
483
484 Reasons []*CreativeFilteringReasonsReasons `json:"reasons,omitempty"`
485
486
487
488
489
490
491
492 ForceSendFields []string `json:"-"`
493
494
495
496
497
498
499
500 NullFields []string `json:"-"`
501 }
502
503 func (s *CreativeFilteringReasons) MarshalJSON() ([]byte, error) {
504 type NoMethod CreativeFilteringReasons
505 raw := NoMethod(*s)
506 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
507 }
508
509 type CreativeFilteringReasonsReasons struct {
510
511
512
513 FilteringCount int64 `json:"filteringCount,omitempty,string"`
514
515
516
517 FilteringStatus int64 `json:"filteringStatus,omitempty"`
518
519
520
521
522
523
524
525 ForceSendFields []string `json:"-"`
526
527
528
529
530
531
532
533
534 NullFields []string `json:"-"`
535 }
536
537 func (s *CreativeFilteringReasonsReasons) MarshalJSON() ([]byte, error) {
538 type NoMethod CreativeFilteringReasonsReasons
539 raw := NoMethod(*s)
540 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
541 }
542
543
544
545
546 type CreativesList struct {
547
548 Items []*Creative `json:"items,omitempty"`
549
550
551 Kind string `json:"kind,omitempty"`
552
553
554
555
556 NextPageToken string `json:"nextPageToken,omitempty"`
557
558
559
560 googleapi.ServerResponse `json:"-"`
561
562
563
564
565
566
567
568 ForceSendFields []string `json:"-"`
569
570
571
572
573
574
575
576 NullFields []string `json:"-"`
577 }
578
579 func (s *CreativesList) MarshalJSON() ([]byte, error) {
580 type NoMethod CreativesList
581 raw := NoMethod(*s)
582 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
583 }
584
585
586
587 type AccountsGetCall struct {
588 s *Service
589 id int64
590 urlParams_ gensupport.URLParams
591 ifNoneMatch_ string
592 ctx_ context.Context
593 header_ http.Header
594 }
595
596
597
598
599 func (r *AccountsService) Get(id int64) *AccountsGetCall {
600 c := &AccountsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
601 c.id = id
602 return c
603 }
604
605
606
607
608 func (c *AccountsGetCall) Fields(s ...googleapi.Field) *AccountsGetCall {
609 c.urlParams_.Set("fields", googleapi.CombineFields(s))
610 return c
611 }
612
613
614
615
616
617
618 func (c *AccountsGetCall) IfNoneMatch(entityTag string) *AccountsGetCall {
619 c.ifNoneMatch_ = entityTag
620 return c
621 }
622
623
624
625
626 func (c *AccountsGetCall) Context(ctx context.Context) *AccountsGetCall {
627 c.ctx_ = ctx
628 return c
629 }
630
631
632
633 func (c *AccountsGetCall) Header() http.Header {
634 if c.header_ == nil {
635 c.header_ = make(http.Header)
636 }
637 return c.header_
638 }
639
640 func (c *AccountsGetCall) doRequest(alt string) (*http.Response, error) {
641 reqHeaders := make(http.Header)
642 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210819")
643 for k, v := range c.header_ {
644 reqHeaders[k] = v
645 }
646 reqHeaders.Set("User-Agent", c.s.userAgent())
647 if c.ifNoneMatch_ != "" {
648 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
649 }
650 var body io.Reader = nil
651 c.urlParams_.Set("alt", alt)
652 c.urlParams_.Set("prettyPrint", "false")
653 urls := googleapi.ResolveRelative(c.s.BasePath, "accounts/{id}")
654 urls += "?" + c.urlParams_.Encode()
655 req, err := http.NewRequest("GET", urls, body)
656 if err != nil {
657 return nil, err
658 }
659 req.Header = reqHeaders
660 googleapi.Expand(req.URL, map[string]string{
661 "id": strconv.FormatInt(c.id, 10),
662 })
663 return gensupport.SendRequest(c.ctx_, c.s.client, req)
664 }
665
666
667
668
669
670
671
672
673 func (c *AccountsGetCall) Do(opts ...googleapi.CallOption) (*Account, error) {
674 gensupport.SetOptions(c.urlParams_, opts...)
675 res, err := c.doRequest("json")
676 if res != nil && res.StatusCode == http.StatusNotModified {
677 if res.Body != nil {
678 res.Body.Close()
679 }
680 return nil, &googleapi.Error{
681 Code: res.StatusCode,
682 Header: res.Header,
683 }
684 }
685 if err != nil {
686 return nil, err
687 }
688 defer googleapi.CloseBody(res)
689 if err := googleapi.CheckResponse(res); err != nil {
690 return nil, err
691 }
692 ret := &Account{
693 ServerResponse: googleapi.ServerResponse{
694 Header: res.Header,
695 HTTPStatusCode: res.StatusCode,
696 },
697 }
698 target := &ret
699 if err := gensupport.DecodeResponse(target, res); err != nil {
700 return nil, err
701 }
702 return ret, nil
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728 }
729
730
731
732 type AccountsListCall struct {
733 s *Service
734 urlParams_ gensupport.URLParams
735 ifNoneMatch_ string
736 ctx_ context.Context
737 header_ http.Header
738 }
739
740
741 func (r *AccountsService) List() *AccountsListCall {
742 c := &AccountsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
743 return c
744 }
745
746
747
748
749 func (c *AccountsListCall) Fields(s ...googleapi.Field) *AccountsListCall {
750 c.urlParams_.Set("fields", googleapi.CombineFields(s))
751 return c
752 }
753
754
755
756
757
758
759 func (c *AccountsListCall) IfNoneMatch(entityTag string) *AccountsListCall {
760 c.ifNoneMatch_ = entityTag
761 return c
762 }
763
764
765
766
767 func (c *AccountsListCall) Context(ctx context.Context) *AccountsListCall {
768 c.ctx_ = ctx
769 return c
770 }
771
772
773
774 func (c *AccountsListCall) Header() http.Header {
775 if c.header_ == nil {
776 c.header_ = make(http.Header)
777 }
778 return c.header_
779 }
780
781 func (c *AccountsListCall) doRequest(alt string) (*http.Response, error) {
782 reqHeaders := make(http.Header)
783 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210819")
784 for k, v := range c.header_ {
785 reqHeaders[k] = v
786 }
787 reqHeaders.Set("User-Agent", c.s.userAgent())
788 if c.ifNoneMatch_ != "" {
789 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
790 }
791 var body io.Reader = nil
792 c.urlParams_.Set("alt", alt)
793 c.urlParams_.Set("prettyPrint", "false")
794 urls := googleapi.ResolveRelative(c.s.BasePath, "accounts")
795 urls += "?" + c.urlParams_.Encode()
796 req, err := http.NewRequest("GET", urls, body)
797 if err != nil {
798 return nil, err
799 }
800 req.Header = reqHeaders
801 return gensupport.SendRequest(c.ctx_, c.s.client, req)
802 }
803
804
805
806
807
808
809
810
811 func (c *AccountsListCall) Do(opts ...googleapi.CallOption) (*AccountsList, error) {
812 gensupport.SetOptions(c.urlParams_, opts...)
813 res, err := c.doRequest("json")
814 if res != nil && res.StatusCode == http.StatusNotModified {
815 if res.Body != nil {
816 res.Body.Close()
817 }
818 return nil, &googleapi.Error{
819 Code: res.StatusCode,
820 Header: res.Header,
821 }
822 }
823 if err != nil {
824 return nil, err
825 }
826 defer googleapi.CloseBody(res)
827 if err := googleapi.CheckResponse(res); err != nil {
828 return nil, err
829 }
830 ret := &AccountsList{
831 ServerResponse: googleapi.ServerResponse{
832 Header: res.Header,
833 HTTPStatusCode: res.StatusCode,
834 },
835 }
836 target := &ret
837 if err := gensupport.DecodeResponse(target, res); err != nil {
838 return nil, err
839 }
840 return ret, nil
841
842
843
844
845
846
847
848
849
850
851
852
853
854 }
855
856
857
858 type AccountsPatchCall struct {
859 s *Service
860 id int64
861 account *Account
862 urlParams_ gensupport.URLParams
863 ctx_ context.Context
864 header_ http.Header
865 }
866
867
868
869
870
871 func (r *AccountsService) Patch(id int64, account *Account) *AccountsPatchCall {
872 c := &AccountsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
873 c.id = id
874 c.account = account
875 return c
876 }
877
878
879
880
881 func (c *AccountsPatchCall) Fields(s ...googleapi.Field) *AccountsPatchCall {
882 c.urlParams_.Set("fields", googleapi.CombineFields(s))
883 return c
884 }
885
886
887
888
889 func (c *AccountsPatchCall) Context(ctx context.Context) *AccountsPatchCall {
890 c.ctx_ = ctx
891 return c
892 }
893
894
895
896 func (c *AccountsPatchCall) Header() http.Header {
897 if c.header_ == nil {
898 c.header_ = make(http.Header)
899 }
900 return c.header_
901 }
902
903 func (c *AccountsPatchCall) doRequest(alt string) (*http.Response, error) {
904 reqHeaders := make(http.Header)
905 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210819")
906 for k, v := range c.header_ {
907 reqHeaders[k] = v
908 }
909 reqHeaders.Set("User-Agent", c.s.userAgent())
910 var body io.Reader = nil
911 body, err := googleapi.WithoutDataWrapper.JSONReader(c.account)
912 if err != nil {
913 return nil, err
914 }
915 reqHeaders.Set("Content-Type", "application/json")
916 c.urlParams_.Set("alt", alt)
917 c.urlParams_.Set("prettyPrint", "false")
918 urls := googleapi.ResolveRelative(c.s.BasePath, "accounts/{id}")
919 urls += "?" + c.urlParams_.Encode()
920 req, err := http.NewRequest("PATCH", urls, body)
921 if err != nil {
922 return nil, err
923 }
924 req.Header = reqHeaders
925 googleapi.Expand(req.URL, map[string]string{
926 "id": strconv.FormatInt(c.id, 10),
927 })
928 return gensupport.SendRequest(c.ctx_, c.s.client, req)
929 }
930
931
932
933
934
935
936
937
938 func (c *AccountsPatchCall) Do(opts ...googleapi.CallOption) (*Account, error) {
939 gensupport.SetOptions(c.urlParams_, opts...)
940 res, err := c.doRequest("json")
941 if res != nil && res.StatusCode == http.StatusNotModified {
942 if res.Body != nil {
943 res.Body.Close()
944 }
945 return nil, &googleapi.Error{
946 Code: res.StatusCode,
947 Header: res.Header,
948 }
949 }
950 if err != nil {
951 return nil, err
952 }
953 defer googleapi.CloseBody(res)
954 if err := googleapi.CheckResponse(res); err != nil {
955 return nil, err
956 }
957 ret := &Account{
958 ServerResponse: googleapi.ServerResponse{
959 Header: res.Header,
960 HTTPStatusCode: res.StatusCode,
961 },
962 }
963 target := &ret
964 if err := gensupport.DecodeResponse(target, res); err != nil {
965 return nil, err
966 }
967 return ret, nil
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996 }
997
998
999
1000 type AccountsUpdateCall struct {
1001 s *Service
1002 id int64
1003 account *Account
1004 urlParams_ gensupport.URLParams
1005 ctx_ context.Context
1006 header_ http.Header
1007 }
1008
1009
1010
1011
1012 func (r *AccountsService) Update(id int64, account *Account) *AccountsUpdateCall {
1013 c := &AccountsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1014 c.id = id
1015 c.account = account
1016 return c
1017 }
1018
1019
1020
1021
1022 func (c *AccountsUpdateCall) Fields(s ...googleapi.Field) *AccountsUpdateCall {
1023 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1024 return c
1025 }
1026
1027
1028
1029
1030 func (c *AccountsUpdateCall) Context(ctx context.Context) *AccountsUpdateCall {
1031 c.ctx_ = ctx
1032 return c
1033 }
1034
1035
1036
1037 func (c *AccountsUpdateCall) Header() http.Header {
1038 if c.header_ == nil {
1039 c.header_ = make(http.Header)
1040 }
1041 return c.header_
1042 }
1043
1044 func (c *AccountsUpdateCall) doRequest(alt string) (*http.Response, error) {
1045 reqHeaders := make(http.Header)
1046 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210819")
1047 for k, v := range c.header_ {
1048 reqHeaders[k] = v
1049 }
1050 reqHeaders.Set("User-Agent", c.s.userAgent())
1051 var body io.Reader = nil
1052 body, err := googleapi.WithoutDataWrapper.JSONReader(c.account)
1053 if err != nil {
1054 return nil, err
1055 }
1056 reqHeaders.Set("Content-Type", "application/json")
1057 c.urlParams_.Set("alt", alt)
1058 c.urlParams_.Set("prettyPrint", "false")
1059 urls := googleapi.ResolveRelative(c.s.BasePath, "accounts/{id}")
1060 urls += "?" + c.urlParams_.Encode()
1061 req, err := http.NewRequest("PUT", urls, body)
1062 if err != nil {
1063 return nil, err
1064 }
1065 req.Header = reqHeaders
1066 googleapi.Expand(req.URL, map[string]string{
1067 "id": strconv.FormatInt(c.id, 10),
1068 })
1069 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1070 }
1071
1072
1073
1074
1075
1076
1077
1078
1079 func (c *AccountsUpdateCall) Do(opts ...googleapi.CallOption) (*Account, error) {
1080 gensupport.SetOptions(c.urlParams_, opts...)
1081 res, err := c.doRequest("json")
1082 if res != nil && res.StatusCode == http.StatusNotModified {
1083 if res.Body != nil {
1084 res.Body.Close()
1085 }
1086 return nil, &googleapi.Error{
1087 Code: res.StatusCode,
1088 Header: res.Header,
1089 }
1090 }
1091 if err != nil {
1092 return nil, err
1093 }
1094 defer googleapi.CloseBody(res)
1095 if err := googleapi.CheckResponse(res); err != nil {
1096 return nil, err
1097 }
1098 ret := &Account{
1099 ServerResponse: googleapi.ServerResponse{
1100 Header: res.Header,
1101 HTTPStatusCode: res.StatusCode,
1102 },
1103 }
1104 target := &ret
1105 if err := gensupport.DecodeResponse(target, res); err != nil {
1106 return nil, err
1107 }
1108 return ret, nil
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137 }
1138
1139
1140
1141 type CreativesGetCall struct {
1142 s *Service
1143 accountId int64
1144 buyerCreativeId string
1145 urlParams_ gensupport.URLParams
1146 ifNoneMatch_ string
1147 ctx_ context.Context
1148 header_ http.Header
1149 }
1150
1151
1152
1153
1154
1155
1156 func (r *CreativesService) Get(accountId int64, buyerCreativeId string) *CreativesGetCall {
1157 c := &CreativesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1158 c.accountId = accountId
1159 c.buyerCreativeId = buyerCreativeId
1160 return c
1161 }
1162
1163
1164
1165
1166 func (c *CreativesGetCall) Fields(s ...googleapi.Field) *CreativesGetCall {
1167 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1168 return c
1169 }
1170
1171
1172
1173
1174
1175
1176 func (c *CreativesGetCall) IfNoneMatch(entityTag string) *CreativesGetCall {
1177 c.ifNoneMatch_ = entityTag
1178 return c
1179 }
1180
1181
1182
1183
1184 func (c *CreativesGetCall) Context(ctx context.Context) *CreativesGetCall {
1185 c.ctx_ = ctx
1186 return c
1187 }
1188
1189
1190
1191 func (c *CreativesGetCall) Header() http.Header {
1192 if c.header_ == nil {
1193 c.header_ = make(http.Header)
1194 }
1195 return c.header_
1196 }
1197
1198 func (c *CreativesGetCall) doRequest(alt string) (*http.Response, error) {
1199 reqHeaders := make(http.Header)
1200 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210819")
1201 for k, v := range c.header_ {
1202 reqHeaders[k] = v
1203 }
1204 reqHeaders.Set("User-Agent", c.s.userAgent())
1205 if c.ifNoneMatch_ != "" {
1206 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1207 }
1208 var body io.Reader = nil
1209 c.urlParams_.Set("alt", alt)
1210 c.urlParams_.Set("prettyPrint", "false")
1211 urls := googleapi.ResolveRelative(c.s.BasePath, "creatives/{accountId}/{buyerCreativeId}")
1212 urls += "?" + c.urlParams_.Encode()
1213 req, err := http.NewRequest("GET", urls, body)
1214 if err != nil {
1215 return nil, err
1216 }
1217 req.Header = reqHeaders
1218 googleapi.Expand(req.URL, map[string]string{
1219 "accountId": strconv.FormatInt(c.accountId, 10),
1220 "buyerCreativeId": c.buyerCreativeId,
1221 })
1222 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1223 }
1224
1225
1226
1227
1228
1229
1230
1231
1232 func (c *CreativesGetCall) Do(opts ...googleapi.CallOption) (*Creative, error) {
1233 gensupport.SetOptions(c.urlParams_, opts...)
1234 res, err := c.doRequest("json")
1235 if res != nil && res.StatusCode == http.StatusNotModified {
1236 if res.Body != nil {
1237 res.Body.Close()
1238 }
1239 return nil, &googleapi.Error{
1240 Code: res.StatusCode,
1241 Header: res.Header,
1242 }
1243 }
1244 if err != nil {
1245 return nil, err
1246 }
1247 defer googleapi.CloseBody(res)
1248 if err := googleapi.CheckResponse(res); err != nil {
1249 return nil, err
1250 }
1251 ret := &Creative{
1252 ServerResponse: googleapi.ServerResponse{
1253 Header: res.Header,
1254 HTTPStatusCode: res.StatusCode,
1255 },
1256 }
1257 target := &ret
1258 if err := gensupport.DecodeResponse(target, res); err != nil {
1259 return nil, err
1260 }
1261 return ret, nil
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294 }
1295
1296
1297
1298 type CreativesInsertCall struct {
1299 s *Service
1300 creative *Creative
1301 urlParams_ gensupport.URLParams
1302 ctx_ context.Context
1303 header_ http.Header
1304 }
1305
1306
1307 func (r *CreativesService) Insert(creative *Creative) *CreativesInsertCall {
1308 c := &CreativesInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1309 c.creative = creative
1310 return c
1311 }
1312
1313
1314
1315
1316 func (c *CreativesInsertCall) Fields(s ...googleapi.Field) *CreativesInsertCall {
1317 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1318 return c
1319 }
1320
1321
1322
1323
1324 func (c *CreativesInsertCall) Context(ctx context.Context) *CreativesInsertCall {
1325 c.ctx_ = ctx
1326 return c
1327 }
1328
1329
1330
1331 func (c *CreativesInsertCall) Header() http.Header {
1332 if c.header_ == nil {
1333 c.header_ = make(http.Header)
1334 }
1335 return c.header_
1336 }
1337
1338 func (c *CreativesInsertCall) doRequest(alt string) (*http.Response, error) {
1339 reqHeaders := make(http.Header)
1340 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210819")
1341 for k, v := range c.header_ {
1342 reqHeaders[k] = v
1343 }
1344 reqHeaders.Set("User-Agent", c.s.userAgent())
1345 var body io.Reader = nil
1346 body, err := googleapi.WithoutDataWrapper.JSONReader(c.creative)
1347 if err != nil {
1348 return nil, err
1349 }
1350 reqHeaders.Set("Content-Type", "application/json")
1351 c.urlParams_.Set("alt", alt)
1352 c.urlParams_.Set("prettyPrint", "false")
1353 urls := googleapi.ResolveRelative(c.s.BasePath, "creatives")
1354 urls += "?" + c.urlParams_.Encode()
1355 req, err := http.NewRequest("POST", urls, body)
1356 if err != nil {
1357 return nil, err
1358 }
1359 req.Header = reqHeaders
1360 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1361 }
1362
1363
1364
1365
1366
1367
1368
1369
1370 func (c *CreativesInsertCall) Do(opts ...googleapi.CallOption) (*Creative, error) {
1371 gensupport.SetOptions(c.urlParams_, opts...)
1372 res, err := c.doRequest("json")
1373 if res != nil && res.StatusCode == http.StatusNotModified {
1374 if res.Body != nil {
1375 res.Body.Close()
1376 }
1377 return nil, &googleapi.Error{
1378 Code: res.StatusCode,
1379 Header: res.Header,
1380 }
1381 }
1382 if err != nil {
1383 return nil, err
1384 }
1385 defer googleapi.CloseBody(res)
1386 if err := googleapi.CheckResponse(res); err != nil {
1387 return nil, err
1388 }
1389 ret := &Creative{
1390 ServerResponse: googleapi.ServerResponse{
1391 Header: res.Header,
1392 HTTPStatusCode: res.StatusCode,
1393 },
1394 }
1395 target := &ret
1396 if err := gensupport.DecodeResponse(target, res); err != nil {
1397 return nil, err
1398 }
1399 return ret, nil
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416 }
1417
1418
1419
1420 type CreativesListCall struct {
1421 s *Service
1422 urlParams_ gensupport.URLParams
1423 ifNoneMatch_ string
1424 ctx_ context.Context
1425 header_ http.Header
1426 }
1427
1428
1429
1430 func (r *CreativesService) List() *CreativesListCall {
1431 c := &CreativesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1432 return c
1433 }
1434
1435
1436
1437
1438 func (c *CreativesListCall) MaxResults(maxResults int64) *CreativesListCall {
1439 c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
1440 return c
1441 }
1442
1443
1444
1445
1446
1447 func (c *CreativesListCall) PageToken(pageToken string) *CreativesListCall {
1448 c.urlParams_.Set("pageToken", pageToken)
1449 return c
1450 }
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460 func (c *CreativesListCall) StatusFilter(statusFilter string) *CreativesListCall {
1461 c.urlParams_.Set("statusFilter", statusFilter)
1462 return c
1463 }
1464
1465
1466
1467
1468 func (c *CreativesListCall) Fields(s ...googleapi.Field) *CreativesListCall {
1469 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1470 return c
1471 }
1472
1473
1474
1475
1476
1477
1478 func (c *CreativesListCall) IfNoneMatch(entityTag string) *CreativesListCall {
1479 c.ifNoneMatch_ = entityTag
1480 return c
1481 }
1482
1483
1484
1485
1486 func (c *CreativesListCall) Context(ctx context.Context) *CreativesListCall {
1487 c.ctx_ = ctx
1488 return c
1489 }
1490
1491
1492
1493 func (c *CreativesListCall) Header() http.Header {
1494 if c.header_ == nil {
1495 c.header_ = make(http.Header)
1496 }
1497 return c.header_
1498 }
1499
1500 func (c *CreativesListCall) doRequest(alt string) (*http.Response, error) {
1501 reqHeaders := make(http.Header)
1502 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210819")
1503 for k, v := range c.header_ {
1504 reqHeaders[k] = v
1505 }
1506 reqHeaders.Set("User-Agent", c.s.userAgent())
1507 if c.ifNoneMatch_ != "" {
1508 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1509 }
1510 var body io.Reader = nil
1511 c.urlParams_.Set("alt", alt)
1512 c.urlParams_.Set("prettyPrint", "false")
1513 urls := googleapi.ResolveRelative(c.s.BasePath, "creatives")
1514 urls += "?" + c.urlParams_.Encode()
1515 req, err := http.NewRequest("GET", urls, body)
1516 if err != nil {
1517 return nil, err
1518 }
1519 req.Header = reqHeaders
1520 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1521 }
1522
1523
1524
1525
1526
1527
1528
1529
1530 func (c *CreativesListCall) Do(opts ...googleapi.CallOption) (*CreativesList, error) {
1531 gensupport.SetOptions(c.urlParams_, opts...)
1532 res, err := c.doRequest("json")
1533 if res != nil && res.StatusCode == http.StatusNotModified {
1534 if res.Body != nil {
1535 res.Body.Close()
1536 }
1537 return nil, &googleapi.Error{
1538 Code: res.StatusCode,
1539 Header: res.Header,
1540 }
1541 }
1542 if err != nil {
1543 return nil, err
1544 }
1545 defer googleapi.CloseBody(res)
1546 if err := googleapi.CheckResponse(res); err != nil {
1547 return nil, err
1548 }
1549 ret := &CreativesList{
1550 ServerResponse: googleapi.ServerResponse{
1551 Header: res.Header,
1552 HTTPStatusCode: res.StatusCode,
1553 },
1554 }
1555 target := &ret
1556 if err := gensupport.DecodeResponse(target, res); err != nil {
1557 return nil, err
1558 }
1559 return ret, nil
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603 }
1604
1605
1606
1607
1608 func (c *CreativesListCall) Pages(ctx context.Context, f func(*CreativesList) error) error {
1609 c.ctx_ = ctx
1610 defer c.PageToken(c.urlParams_.Get("pageToken"))
1611 for {
1612 x, err := c.Do()
1613 if err != nil {
1614 return err
1615 }
1616 if err := f(x); err != nil {
1617 return err
1618 }
1619 if x.NextPageToken == "" {
1620 return nil
1621 }
1622 c.PageToken(x.NextPageToken)
1623 }
1624 }
1625
View as plain text