1// Copyright 2019 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 adexchangebuyer provides access to the Ad Exchange Buyer API. 8// 9// For product documentation, see: https://developers.google.com/ad-exchange/buyer-rest 10// 11// Creating a client 12// 13// Usage example: 14// 15// import "google.golang.org/api/adexchangebuyer/v1.2" 16// ... 17// ctx := context.Background() 18// adexchangebuyerService, err := adexchangebuyer.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// adexchangebuyerService, err := adexchangebuyer.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// adexchangebuyerService, err := adexchangebuyer.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) 36// 37// See https://godoc.org/google.golang.org/api/option/ for details on options. 38package adexchangebuyer // import "google.golang.org/api/adexchangebuyer/v1.2" 39 40import ( 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 htransport "google.golang.org/api/transport/http" 56) 57 58// Always reference these packages, just in case the auto-generated code 59// below doesn't. 60var _ = bytes.NewBuffer 61var _ = strconv.Itoa 62var _ = fmt.Sprintf 63var _ = json.NewDecoder 64var _ = io.Copy 65var _ = url.Parse 66var _ = gensupport.MarshalJSON 67var _ = googleapi.Version 68var _ = errors.New 69var _ = strings.Replace 70var _ = context.Canceled 71 72const apiId = "adexchangebuyer:v1.2" 73const apiName = "adexchangebuyer" 74const apiVersion = "v1.2" 75const basePath = "https://www.googleapis.com/adexchangebuyer/v1.2/" 76 77// OAuth2 scopes used by this API. 78const ( 79 // Manage your Ad Exchange buyer account configuration 80 AdexchangeBuyerScope = "https://www.googleapis.com/auth/adexchange.buyer" 81) 82 83// NewService creates a new Service. 84func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 85 scopesOption := option.WithScopes( 86 "https://www.googleapis.com/auth/adexchange.buyer", 87 ) 88 // NOTE: prepend, so we don't override user-specified scopes. 89 opts = append([]option.ClientOption{scopesOption}, opts...) 90 client, endpoint, err := htransport.NewClient(ctx, opts...) 91 if err != nil { 92 return nil, err 93 } 94 s, err := New(client) 95 if err != nil { 96 return nil, err 97 } 98 if endpoint != "" { 99 s.BasePath = endpoint 100 } 101 return s, nil 102} 103 104// New creates a new Service. It uses the provided http.Client for requests. 105// 106// Deprecated: please use NewService instead. 107// To provide a custom HTTP client, use option.WithHTTPClient. 108// If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. 109func New(client *http.Client) (*Service, error) { 110 if client == nil { 111 return nil, errors.New("client is nil") 112 } 113 s := &Service{client: client, BasePath: basePath} 114 s.Accounts = NewAccountsService(s) 115 s.Creatives = NewCreativesService(s) 116 return s, nil 117} 118 119type Service struct { 120 client *http.Client 121 BasePath string // API endpoint base URL 122 UserAgent string // optional additional User-Agent fragment 123 124 Accounts *AccountsService 125 126 Creatives *CreativesService 127} 128 129func (s *Service) userAgent() string { 130 if s.UserAgent == "" { 131 return googleapi.UserAgent 132 } 133 return googleapi.UserAgent + " " + s.UserAgent 134} 135 136func NewAccountsService(s *Service) *AccountsService { 137 rs := &AccountsService{s: s} 138 return rs 139} 140 141type AccountsService struct { 142 s *Service 143} 144 145func NewCreativesService(s *Service) *CreativesService { 146 rs := &CreativesService{s: s} 147 return rs 148} 149 150type CreativesService struct { 151 s *Service 152} 153 154// Account: Configuration data for an Ad Exchange buyer account. 155type Account struct { 156 // BidderLocation: Your bidder locations that have distinct URLs. 157 BidderLocation []*AccountBidderLocation `json:"bidderLocation,omitempty"` 158 159 // CookieMatchingNid: The nid parameter value used in cookie match 160 // requests. Please contact your technical account manager if you need 161 // to change this. 162 CookieMatchingNid string `json:"cookieMatchingNid,omitempty"` 163 164 // CookieMatchingUrl: The base URL used in cookie match requests. 165 CookieMatchingUrl string `json:"cookieMatchingUrl,omitempty"` 166 167 // Id: Account id. 168 Id int64 `json:"id,omitempty"` 169 170 // Kind: Resource type. 171 Kind string `json:"kind,omitempty"` 172 173 // MaximumActiveCreatives: The maximum number of active creatives that 174 // an account can have, where a creative is active if it was inserted or 175 // bid with in the last 30 days. Please contact your technical account 176 // manager if you need to change this. 177 MaximumActiveCreatives int64 `json:"maximumActiveCreatives,omitempty"` 178 179 // MaximumTotalQps: The sum of all bidderLocation.maximumQps values 180 // cannot exceed this. Please contact your technical account manager if 181 // you need to change this. 182 MaximumTotalQps int64 `json:"maximumTotalQps,omitempty"` 183 184 // NumberActiveCreatives: The number of creatives that this account 185 // inserted or bid with in the last 30 days. 186 NumberActiveCreatives int64 `json:"numberActiveCreatives,omitempty"` 187 188 // ServerResponse contains the HTTP response code and headers from the 189 // server. 190 googleapi.ServerResponse `json:"-"` 191 192 // ForceSendFields is a list of field names (e.g. "BidderLocation") to 193 // unconditionally include in API requests. By default, fields with 194 // empty values are omitted from API requests. However, any non-pointer, 195 // non-interface field appearing in ForceSendFields will be sent to the 196 // server regardless of whether the field is empty or not. This may be 197 // used to include empty fields in Patch requests. 198 ForceSendFields []string `json:"-"` 199 200 // NullFields is a list of field names (e.g. "BidderLocation") to 201 // include in API requests with the JSON null value. By default, fields 202 // with empty values are omitted from API requests. However, any field 203 // with an empty value appearing in NullFields will be sent to the 204 // server as null. It is an error if a field in this list has a 205 // non-empty value. This may be used to include null fields in Patch 206 // requests. 207 NullFields []string `json:"-"` 208} 209 210func (s *Account) MarshalJSON() ([]byte, error) { 211 type NoMethod Account 212 raw := NoMethod(*s) 213 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 214} 215 216type AccountBidderLocation struct { 217 // MaximumQps: The maximum queries per second the Ad Exchange will send. 218 MaximumQps int64 `json:"maximumQps,omitempty"` 219 220 // Region: The geographical region the Ad Exchange should send requests 221 // from. Only used by some quota systems, but always setting the value 222 // is recommended. Allowed values: 223 // - ASIA 224 // - EUROPE 225 // - US_EAST 226 // - US_WEST 227 Region string `json:"region,omitempty"` 228 229 // Url: The URL to which the Ad Exchange will send bid requests. 230 Url string `json:"url,omitempty"` 231 232 // ForceSendFields is a list of field names (e.g. "MaximumQps") to 233 // unconditionally include in API requests. By default, fields with 234 // empty values are omitted from API requests. However, any non-pointer, 235 // non-interface field appearing in ForceSendFields will be sent to the 236 // server regardless of whether the field is empty or not. This may be 237 // used to include empty fields in Patch requests. 238 ForceSendFields []string `json:"-"` 239 240 // NullFields is a list of field names (e.g. "MaximumQps") to include in 241 // API requests with the JSON null value. By default, fields with empty 242 // values are omitted from API requests. However, any field with an 243 // empty value appearing in NullFields will be sent to the server as 244 // null. It is an error if a field in this list has a non-empty value. 245 // This may be used to include null fields in Patch requests. 246 NullFields []string `json:"-"` 247} 248 249func (s *AccountBidderLocation) MarshalJSON() ([]byte, error) { 250 type NoMethod AccountBidderLocation 251 raw := NoMethod(*s) 252 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 253} 254 255// AccountsList: An account feed lists Ad Exchange buyer accounts that 256// the user has access to. Each entry in the feed corresponds to a 257// single buyer account. 258type AccountsList struct { 259 // Items: A list of accounts. 260 Items []*Account `json:"items,omitempty"` 261 262 // Kind: Resource type. 263 Kind string `json:"kind,omitempty"` 264 265 // ServerResponse contains the HTTP response code and headers from the 266 // server. 267 googleapi.ServerResponse `json:"-"` 268 269 // ForceSendFields is a list of field names (e.g. "Items") to 270 // unconditionally include in API requests. By default, fields with 271 // empty values are omitted from API requests. However, any non-pointer, 272 // non-interface field appearing in ForceSendFields will be sent to the 273 // server regardless of whether the field is empty or not. This may be 274 // used to include empty fields in Patch requests. 275 ForceSendFields []string `json:"-"` 276 277 // NullFields is a list of field names (e.g. "Items") to include in API 278 // requests with the JSON null value. By default, fields with empty 279 // values are omitted from API requests. However, any field with an 280 // empty value appearing in NullFields will be sent to the server as 281 // null. It is an error if a field in this list has a non-empty value. 282 // This may be used to include null fields in Patch requests. 283 NullFields []string `json:"-"` 284} 285 286func (s *AccountsList) MarshalJSON() ([]byte, error) { 287 type NoMethod AccountsList 288 raw := NoMethod(*s) 289 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 290} 291 292// Creative: A creative and its classification data. 293type Creative struct { 294 // HTMLSnippet: The HTML snippet that displays the ad when inserted in 295 // the web page. If set, videoURL should not be set. 296 HTMLSnippet string `json:"HTMLSnippet,omitempty"` 297 298 // AccountId: Account id. 299 AccountId int64 `json:"accountId,omitempty"` 300 301 // AdvertiserId: Detected advertiser id, if any. Read-only. This field 302 // should not be set in requests. 303 AdvertiserId googleapi.Int64s `json:"advertiserId,omitempty"` 304 305 // AdvertiserName: The name of the company being advertised in the 306 // creative. 307 AdvertiserName string `json:"advertiserName,omitempty"` 308 309 // AgencyId: The agency id for this creative. 310 AgencyId int64 `json:"agencyId,omitempty,string"` 311 312 // ApiUploadTimestamp: The last upload timestamp of this creative if it 313 // was uploaded via API. Read-only. The value of this field is 314 // generated, and will be ignored for uploads. (formatted RFC 3339 315 // timestamp). 316 ApiUploadTimestamp string `json:"apiUploadTimestamp,omitempty"` 317 318 // Attribute: All attributes for the ads that may be shown from this 319 // snippet. 320 Attribute []int64 `json:"attribute,omitempty"` 321 322 // BuyerCreativeId: A buyer-specific id identifying the creative in this 323 // ad. 324 BuyerCreativeId string `json:"buyerCreativeId,omitempty"` 325 326 // ClickThroughUrl: The set of destination urls for the snippet. 327 ClickThroughUrl []string `json:"clickThroughUrl,omitempty"` 328 329 // Corrections: Shows any corrections that were applied to this 330 // creative. Read-only. This field should not be set in requests. 331 Corrections []*CreativeCorrections `json:"corrections,omitempty"` 332 333 // DisapprovalReasons: The reasons for disapproval, if any. Note that 334 // not all disapproval reasons may be categorized, so it is possible for 335 // the creative to have a status of DISAPPROVED with an empty list for 336 // disapproval_reasons. In this case, please reach out to your TAM to 337 // help debug the issue. Read-only. This field should not be set in 338 // requests. 339 DisapprovalReasons []*CreativeDisapprovalReasons `json:"disapprovalReasons,omitempty"` 340 341 // FilteringReasons: The filtering reasons for the creative. Read-only. 342 // This field should not be set in requests. 343 FilteringReasons *CreativeFilteringReasons `json:"filteringReasons,omitempty"` 344 345 // Height: Ad height. 346 Height int64 `json:"height,omitempty"` 347 348 // ImpressionTrackingUrl: The set of urls to be called to record an 349 // impression. 350 ImpressionTrackingUrl []string `json:"impressionTrackingUrl,omitempty"` 351 352 // Kind: Resource type. 353 Kind string `json:"kind,omitempty"` 354 355 // ProductCategories: Detected product categories, if any. Read-only. 356 // This field should not be set in requests. 357 ProductCategories []int64 `json:"productCategories,omitempty"` 358 359 // RestrictedCategories: All restricted categories for the ads that may 360 // be shown from this snippet. 361 RestrictedCategories []int64 `json:"restrictedCategories,omitempty"` 362 363 // SensitiveCategories: Detected sensitive categories, if any. 364 // Read-only. This field should not be set in requests. 365 SensitiveCategories []int64 `json:"sensitiveCategories,omitempty"` 366 367 // Status: Creative serving status. Read-only. This field should not be 368 // set in requests. 369 Status string `json:"status,omitempty"` 370 371 // VendorType: All vendor types for the ads that may be shown from this 372 // snippet. 373 VendorType []int64 `json:"vendorType,omitempty"` 374 375 // Version: The version for this creative. Read-only. This field should 376 // not be set in requests. 377 Version int64 `json:"version,omitempty"` 378 379 // VideoURL: The url to fetch a video ad. If set, HTMLSnippet should not 380 // be set. 381 VideoURL string `json:"videoURL,omitempty"` 382 383 // Width: Ad width. 384 Width int64 `json:"width,omitempty"` 385 386 // ServerResponse contains the HTTP response code and headers from the 387 // server. 388 googleapi.ServerResponse `json:"-"` 389 390 // ForceSendFields is a list of field names (e.g. "HTMLSnippet") to 391 // unconditionally include in API requests. By default, fields with 392 // empty values are omitted from API requests. However, any non-pointer, 393 // non-interface field appearing in ForceSendFields will be sent to the 394 // server regardless of whether the field is empty or not. This may be 395 // used to include empty fields in Patch requests. 396 ForceSendFields []string `json:"-"` 397 398 // NullFields is a list of field names (e.g. "HTMLSnippet") to include 399 // in API requests with the JSON null value. By default, fields with 400 // empty values are omitted from API requests. However, any field with 401 // an empty value appearing in NullFields will be sent to the server as 402 // null. It is an error if a field in this list has a non-empty value. 403 // This may be used to include null fields in Patch requests. 404 NullFields []string `json:"-"` 405} 406 407func (s *Creative) MarshalJSON() ([]byte, error) { 408 type NoMethod Creative 409 raw := NoMethod(*s) 410 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 411} 412 413type CreativeCorrections struct { 414 // Details: Additional details about the correction. 415 Details []string `json:"details,omitempty"` 416 417 // Reason: The type of correction that was applied to the creative. 418 Reason string `json:"reason,omitempty"` 419 420 // ForceSendFields is a list of field names (e.g. "Details") to 421 // unconditionally include in API requests. By default, fields with 422 // empty values are omitted from API requests. However, any non-pointer, 423 // non-interface field appearing in ForceSendFields will be sent to the 424 // server regardless of whether the field is empty or not. This may be 425 // used to include empty fields in Patch requests. 426 ForceSendFields []string `json:"-"` 427 428 // NullFields is a list of field names (e.g. "Details") to include in 429 // API requests with the JSON null value. By default, fields with empty 430 // values are omitted from API requests. However, any field with an 431 // empty value appearing in NullFields will be sent to the server as 432 // null. It is an error if a field in this list has a non-empty value. 433 // This may be used to include null fields in Patch requests. 434 NullFields []string `json:"-"` 435} 436 437func (s *CreativeCorrections) MarshalJSON() ([]byte, error) { 438 type NoMethod CreativeCorrections 439 raw := NoMethod(*s) 440 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 441} 442 443type CreativeDisapprovalReasons struct { 444 // Details: Additional details about the reason for disapproval. 445 Details []string `json:"details,omitempty"` 446 447 // Reason: The categorized reason for disapproval. 448 Reason string `json:"reason,omitempty"` 449 450 // ForceSendFields is a list of field names (e.g. "Details") to 451 // unconditionally include in API requests. By default, fields with 452 // empty values are omitted from API requests. However, any non-pointer, 453 // non-interface field appearing in ForceSendFields will be sent to the 454 // server regardless of whether the field is empty or not. This may be 455 // used to include empty fields in Patch requests. 456 ForceSendFields []string `json:"-"` 457 458 // NullFields is a list of field names (e.g. "Details") to include in 459 // API requests with the JSON null value. By default, fields with empty 460 // values are omitted from API requests. However, any field with an 461 // empty value appearing in NullFields will be sent to the server as 462 // null. It is an error if a field in this list has a non-empty value. 463 // This may be used to include null fields in Patch requests. 464 NullFields []string `json:"-"` 465} 466 467func (s *CreativeDisapprovalReasons) MarshalJSON() ([]byte, error) { 468 type NoMethod CreativeDisapprovalReasons 469 raw := NoMethod(*s) 470 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 471} 472 473// CreativeFilteringReasons: The filtering reasons for the creative. 474// Read-only. This field should not be set in requests. 475type CreativeFilteringReasons struct { 476 // Date: The date in ISO 8601 format for the data. The data is collected 477 // from 00:00:00 to 23:59:59 in PST. 478 Date string `json:"date,omitempty"` 479 480 // Reasons: The filtering reasons. 481 Reasons []*CreativeFilteringReasonsReasons `json:"reasons,omitempty"` 482 483 // ForceSendFields is a list of field names (e.g. "Date") to 484 // unconditionally include in API requests. By default, fields with 485 // empty values are omitted from API requests. However, any non-pointer, 486 // non-interface field appearing in ForceSendFields will be sent to the 487 // server regardless of whether the field is empty or not. This may be 488 // used to include empty fields in Patch requests. 489 ForceSendFields []string `json:"-"` 490 491 // NullFields is a list of field names (e.g. "Date") to include in API 492 // requests with the JSON null value. By default, fields with empty 493 // values are omitted from API requests. However, any field with an 494 // empty value appearing in NullFields will be sent to the server as 495 // null. It is an error if a field in this list has a non-empty value. 496 // This may be used to include null fields in Patch requests. 497 NullFields []string `json:"-"` 498} 499 500func (s *CreativeFilteringReasons) MarshalJSON() ([]byte, error) { 501 type NoMethod CreativeFilteringReasons 502 raw := NoMethod(*s) 503 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 504} 505 506type CreativeFilteringReasonsReasons struct { 507 // FilteringCount: The number of times the creative was filtered for the 508 // status. The count is aggregated across all publishers on the 509 // exchange. 510 FilteringCount int64 `json:"filteringCount,omitempty,string"` 511 512 // FilteringStatus: The filtering status code. Please refer to the 513 // creative-status-codes.txt file for different statuses. 514 FilteringStatus int64 `json:"filteringStatus,omitempty"` 515 516 // ForceSendFields is a list of field names (e.g. "FilteringCount") to 517 // unconditionally include in API requests. By default, fields with 518 // empty values are omitted from API requests. However, any non-pointer, 519 // non-interface field appearing in ForceSendFields will be sent to the 520 // server regardless of whether the field is empty or not. This may be 521 // used to include empty fields in Patch requests. 522 ForceSendFields []string `json:"-"` 523 524 // NullFields is a list of field names (e.g. "FilteringCount") to 525 // include in API requests with the JSON null value. By default, fields 526 // with empty values are omitted from API requests. However, any field 527 // with an empty value appearing in NullFields will be sent to the 528 // server as null. It is an error if a field in this list has a 529 // non-empty value. This may be used to include null fields in Patch 530 // requests. 531 NullFields []string `json:"-"` 532} 533 534func (s *CreativeFilteringReasonsReasons) MarshalJSON() ([]byte, error) { 535 type NoMethod CreativeFilteringReasonsReasons 536 raw := NoMethod(*s) 537 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 538} 539 540// CreativesList: The creatives feed lists the active creatives for the 541// Ad Exchange buyer accounts that the user has access to. Each entry in 542// the feed corresponds to a single creative. 543type CreativesList struct { 544 // Items: A list of creatives. 545 Items []*Creative `json:"items,omitempty"` 546 547 // Kind: Resource type. 548 Kind string `json:"kind,omitempty"` 549 550 // NextPageToken: Continuation token used to page through creatives. To 551 // retrieve the next page of results, set the next request's "pageToken" 552 // value to this. 553 NextPageToken string `json:"nextPageToken,omitempty"` 554 555 // ServerResponse contains the HTTP response code and headers from the 556 // server. 557 googleapi.ServerResponse `json:"-"` 558 559 // ForceSendFields is a list of field names (e.g. "Items") to 560 // unconditionally include in API requests. By default, fields with 561 // empty values are omitted from API requests. However, any non-pointer, 562 // non-interface field appearing in ForceSendFields will be sent to the 563 // server regardless of whether the field is empty or not. This may be 564 // used to include empty fields in Patch requests. 565 ForceSendFields []string `json:"-"` 566 567 // NullFields is a list of field names (e.g. "Items") to include in API 568 // requests with the JSON null value. By default, fields with empty 569 // values are omitted from API requests. However, any field with an 570 // empty value appearing in NullFields will be sent to the server as 571 // null. It is an error if a field in this list has a non-empty value. 572 // This may be used to include null fields in Patch requests. 573 NullFields []string `json:"-"` 574} 575 576func (s *CreativesList) MarshalJSON() ([]byte, error) { 577 type NoMethod CreativesList 578 raw := NoMethod(*s) 579 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 580} 581 582// method id "adexchangebuyer.accounts.get": 583 584type AccountsGetCall struct { 585 s *Service 586 id int64 587 urlParams_ gensupport.URLParams 588 ifNoneMatch_ string 589 ctx_ context.Context 590 header_ http.Header 591} 592 593// Get: Gets one account by ID. 594func (r *AccountsService) Get(id int64) *AccountsGetCall { 595 c := &AccountsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 596 c.id = id 597 return c 598} 599 600// Fields allows partial responses to be retrieved. See 601// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 602// for more information. 603func (c *AccountsGetCall) Fields(s ...googleapi.Field) *AccountsGetCall { 604 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 605 return c 606} 607 608// IfNoneMatch sets the optional parameter which makes the operation 609// fail if the object's ETag matches the given value. This is useful for 610// getting updates only after the object has changed since the last 611// request. Use googleapi.IsNotModified to check whether the response 612// error from Do is the result of In-None-Match. 613func (c *AccountsGetCall) IfNoneMatch(entityTag string) *AccountsGetCall { 614 c.ifNoneMatch_ = entityTag 615 return c 616} 617 618// Context sets the context to be used in this call's Do method. Any 619// pending HTTP request will be aborted if the provided context is 620// canceled. 621func (c *AccountsGetCall) Context(ctx context.Context) *AccountsGetCall { 622 c.ctx_ = ctx 623 return c 624} 625 626// Header returns an http.Header that can be modified by the caller to 627// add HTTP headers to the request. 628func (c *AccountsGetCall) Header() http.Header { 629 if c.header_ == nil { 630 c.header_ = make(http.Header) 631 } 632 return c.header_ 633} 634 635func (c *AccountsGetCall) doRequest(alt string) (*http.Response, error) { 636 reqHeaders := make(http.Header) 637 reqHeaders.Set("x-goog-api-client", "gl-go/1.11.0 gdcl/20190926") 638 for k, v := range c.header_ { 639 reqHeaders[k] = v 640 } 641 reqHeaders.Set("User-Agent", c.s.userAgent()) 642 if c.ifNoneMatch_ != "" { 643 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 644 } 645 var body io.Reader = nil 646 c.urlParams_.Set("alt", alt) 647 c.urlParams_.Set("prettyPrint", "false") 648 urls := googleapi.ResolveRelative(c.s.BasePath, "accounts/{id}") 649 urls += "?" + c.urlParams_.Encode() 650 req, err := http.NewRequest("GET", urls, body) 651 if err != nil { 652 return nil, err 653 } 654 req.Header = reqHeaders 655 googleapi.Expand(req.URL, map[string]string{ 656 "id": strconv.FormatInt(c.id, 10), 657 }) 658 return gensupport.SendRequest(c.ctx_, c.s.client, req) 659} 660 661// Do executes the "adexchangebuyer.accounts.get" call. 662// Exactly one of *Account or error will be non-nil. Any non-2xx status 663// code is an error. Response headers are in either 664// *Account.ServerResponse.Header or (if a response was returned at all) 665// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to 666// check whether the returned error was because http.StatusNotModified 667// was returned. 668func (c *AccountsGetCall) Do(opts ...googleapi.CallOption) (*Account, error) { 669 gensupport.SetOptions(c.urlParams_, opts...) 670 res, err := c.doRequest("json") 671 if res != nil && res.StatusCode == http.StatusNotModified { 672 if res.Body != nil { 673 res.Body.Close() 674 } 675 return nil, &googleapi.Error{ 676 Code: res.StatusCode, 677 Header: res.Header, 678 } 679 } 680 if err != nil { 681 return nil, err 682 } 683 defer googleapi.CloseBody(res) 684 if err := googleapi.CheckResponse(res); err != nil { 685 return nil, err 686 } 687 ret := &Account{ 688 ServerResponse: googleapi.ServerResponse{ 689 Header: res.Header, 690 HTTPStatusCode: res.StatusCode, 691 }, 692 } 693 target := &ret 694 if err := gensupport.DecodeResponse(target, res); err != nil { 695 return nil, err 696 } 697 return ret, nil 698 // { 699 // "description": "Gets one account by ID.", 700 // "httpMethod": "GET", 701 // "id": "adexchangebuyer.accounts.get", 702 // "parameterOrder": [ 703 // "id" 704 // ], 705 // "parameters": { 706 // "id": { 707 // "description": "The account id", 708 // "format": "int32", 709 // "location": "path", 710 // "required": true, 711 // "type": "integer" 712 // } 713 // }, 714 // "path": "accounts/{id}", 715 // "response": { 716 // "$ref": "Account" 717 // }, 718 // "scopes": [ 719 // "https://www.googleapis.com/auth/adexchange.buyer" 720 // ] 721 // } 722 723} 724 725// method id "adexchangebuyer.accounts.list": 726 727type AccountsListCall struct { 728 s *Service 729 urlParams_ gensupport.URLParams 730 ifNoneMatch_ string 731 ctx_ context.Context 732 header_ http.Header 733} 734 735// List: Retrieves the authenticated user's list of accounts. 736func (r *AccountsService) List() *AccountsListCall { 737 c := &AccountsListCall{s: r.s, urlParams_: make(gensupport.URLParams)} 738 return c 739} 740 741// Fields allows partial responses to be retrieved. See 742// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 743// for more information. 744func (c *AccountsListCall) Fields(s ...googleapi.Field) *AccountsListCall { 745 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 746 return c 747} 748 749// IfNoneMatch sets the optional parameter which makes the operation 750// fail if the object's ETag matches the given value. This is useful for 751// getting updates only after the object has changed since the last 752// request. Use googleapi.IsNotModified to check whether the response 753// error from Do is the result of In-None-Match. 754func (c *AccountsListCall) IfNoneMatch(entityTag string) *AccountsListCall { 755 c.ifNoneMatch_ = entityTag 756 return c 757} 758 759// Context sets the context to be used in this call's Do method. Any 760// pending HTTP request will be aborted if the provided context is 761// canceled. 762func (c *AccountsListCall) Context(ctx context.Context) *AccountsListCall { 763 c.ctx_ = ctx 764 return c 765} 766 767// Header returns an http.Header that can be modified by the caller to 768// add HTTP headers to the request. 769func (c *AccountsListCall) Header() http.Header { 770 if c.header_ == nil { 771 c.header_ = make(http.Header) 772 } 773 return c.header_ 774} 775 776func (c *AccountsListCall) doRequest(alt string) (*http.Response, error) { 777 reqHeaders := make(http.Header) 778 reqHeaders.Set("x-goog-api-client", "gl-go/1.11.0 gdcl/20190926") 779 for k, v := range c.header_ { 780 reqHeaders[k] = v 781 } 782 reqHeaders.Set("User-Agent", c.s.userAgent()) 783 if c.ifNoneMatch_ != "" { 784 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 785 } 786 var body io.Reader = nil 787 c.urlParams_.Set("alt", alt) 788 c.urlParams_.Set("prettyPrint", "false") 789 urls := googleapi.ResolveRelative(c.s.BasePath, "accounts") 790 urls += "?" + c.urlParams_.Encode() 791 req, err := http.NewRequest("GET", urls, body) 792 if err != nil { 793 return nil, err 794 } 795 req.Header = reqHeaders 796 return gensupport.SendRequest(c.ctx_, c.s.client, req) 797} 798 799// Do executes the "adexchangebuyer.accounts.list" call. 800// Exactly one of *AccountsList or error will be non-nil. Any non-2xx 801// status code is an error. Response headers are in either 802// *AccountsList.ServerResponse.Header or (if a response was returned at 803// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 804// to check whether the returned error was because 805// http.StatusNotModified was returned. 806func (c *AccountsListCall) Do(opts ...googleapi.CallOption) (*AccountsList, error) { 807 gensupport.SetOptions(c.urlParams_, opts...) 808 res, err := c.doRequest("json") 809 if res != nil && res.StatusCode == http.StatusNotModified { 810 if res.Body != nil { 811 res.Body.Close() 812 } 813 return nil, &googleapi.Error{ 814 Code: res.StatusCode, 815 Header: res.Header, 816 } 817 } 818 if err != nil { 819 return nil, err 820 } 821 defer googleapi.CloseBody(res) 822 if err := googleapi.CheckResponse(res); err != nil { 823 return nil, err 824 } 825 ret := &AccountsList{ 826 ServerResponse: googleapi.ServerResponse{ 827 Header: res.Header, 828 HTTPStatusCode: res.StatusCode, 829 }, 830 } 831 target := &ret 832 if err := gensupport.DecodeResponse(target, res); err != nil { 833 return nil, err 834 } 835 return ret, nil 836 // { 837 // "description": "Retrieves the authenticated user's list of accounts.", 838 // "httpMethod": "GET", 839 // "id": "adexchangebuyer.accounts.list", 840 // "path": "accounts", 841 // "response": { 842 // "$ref": "AccountsList" 843 // }, 844 // "scopes": [ 845 // "https://www.googleapis.com/auth/adexchange.buyer" 846 // ] 847 // } 848 849} 850 851// method id "adexchangebuyer.accounts.patch": 852 853type AccountsPatchCall struct { 854 s *Service 855 id int64 856 account *Account 857 urlParams_ gensupport.URLParams 858 ctx_ context.Context 859 header_ http.Header 860} 861 862// Patch: Updates an existing account. This method supports patch 863// semantics. 864func (r *AccountsService) Patch(id int64, account *Account) *AccountsPatchCall { 865 c := &AccountsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)} 866 c.id = id 867 c.account = account 868 return c 869} 870 871// Fields allows partial responses to be retrieved. See 872// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 873// for more information. 874func (c *AccountsPatchCall) Fields(s ...googleapi.Field) *AccountsPatchCall { 875 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 876 return c 877} 878 879// Context sets the context to be used in this call's Do method. Any 880// pending HTTP request will be aborted if the provided context is 881// canceled. 882func (c *AccountsPatchCall) Context(ctx context.Context) *AccountsPatchCall { 883 c.ctx_ = ctx 884 return c 885} 886 887// Header returns an http.Header that can be modified by the caller to 888// add HTTP headers to the request. 889func (c *AccountsPatchCall) Header() http.Header { 890 if c.header_ == nil { 891 c.header_ = make(http.Header) 892 } 893 return c.header_ 894} 895 896func (c *AccountsPatchCall) doRequest(alt string) (*http.Response, error) { 897 reqHeaders := make(http.Header) 898 reqHeaders.Set("x-goog-api-client", "gl-go/1.11.0 gdcl/20190926") 899 for k, v := range c.header_ { 900 reqHeaders[k] = v 901 } 902 reqHeaders.Set("User-Agent", c.s.userAgent()) 903 var body io.Reader = nil 904 body, err := googleapi.WithoutDataWrapper.JSONReader(c.account) 905 if err != nil { 906 return nil, err 907 } 908 reqHeaders.Set("Content-Type", "application/json") 909 c.urlParams_.Set("alt", alt) 910 c.urlParams_.Set("prettyPrint", "false") 911 urls := googleapi.ResolveRelative(c.s.BasePath, "accounts/{id}") 912 urls += "?" + c.urlParams_.Encode() 913 req, err := http.NewRequest("PATCH", urls, body) 914 if err != nil { 915 return nil, err 916 } 917 req.Header = reqHeaders 918 googleapi.Expand(req.URL, map[string]string{ 919 "id": strconv.FormatInt(c.id, 10), 920 }) 921 return gensupport.SendRequest(c.ctx_, c.s.client, req) 922} 923 924// Do executes the "adexchangebuyer.accounts.patch" call. 925// Exactly one of *Account or error will be non-nil. Any non-2xx status 926// code is an error. Response headers are in either 927// *Account.ServerResponse.Header or (if a response was returned at all) 928// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to 929// check whether the returned error was because http.StatusNotModified 930// was returned. 931func (c *AccountsPatchCall) Do(opts ...googleapi.CallOption) (*Account, error) { 932 gensupport.SetOptions(c.urlParams_, opts...) 933 res, err := c.doRequest("json") 934 if res != nil && res.StatusCode == http.StatusNotModified { 935 if res.Body != nil { 936 res.Body.Close() 937 } 938 return nil, &googleapi.Error{ 939 Code: res.StatusCode, 940 Header: res.Header, 941 } 942 } 943 if err != nil { 944 return nil, err 945 } 946 defer googleapi.CloseBody(res) 947 if err := googleapi.CheckResponse(res); err != nil { 948 return nil, err 949 } 950 ret := &Account{ 951 ServerResponse: googleapi.ServerResponse{ 952 Header: res.Header, 953 HTTPStatusCode: res.StatusCode, 954 }, 955 } 956 target := &ret 957 if err := gensupport.DecodeResponse(target, res); err != nil { 958 return nil, err 959 } 960 return ret, nil 961 // { 962 // "description": "Updates an existing account. This method supports patch semantics.", 963 // "httpMethod": "PATCH", 964 // "id": "adexchangebuyer.accounts.patch", 965 // "parameterOrder": [ 966 // "id" 967 // ], 968 // "parameters": { 969 // "id": { 970 // "description": "The account id", 971 // "format": "int32", 972 // "location": "path", 973 // "required": true, 974 // "type": "integer" 975 // } 976 // }, 977 // "path": "accounts/{id}", 978 // "request": { 979 // "$ref": "Account" 980 // }, 981 // "response": { 982 // "$ref": "Account" 983 // }, 984 // "scopes": [ 985 // "https://www.googleapis.com/auth/adexchange.buyer" 986 // ] 987 // } 988 989} 990 991// method id "adexchangebuyer.accounts.update": 992 993type AccountsUpdateCall struct { 994 s *Service 995 id int64 996 account *Account 997 urlParams_ gensupport.URLParams 998 ctx_ context.Context 999 header_ http.Header 1000} 1001 1002// Update: Updates an existing account. 1003func (r *AccountsService) Update(id int64, account *Account) *AccountsUpdateCall { 1004 c := &AccountsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1005 c.id = id 1006 c.account = account 1007 return c 1008} 1009 1010// Fields allows partial responses to be retrieved. See 1011// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1012// for more information. 1013func (c *AccountsUpdateCall) Fields(s ...googleapi.Field) *AccountsUpdateCall { 1014 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1015 return c 1016} 1017 1018// Context sets the context to be used in this call's Do method. Any 1019// pending HTTP request will be aborted if the provided context is 1020// canceled. 1021func (c *AccountsUpdateCall) Context(ctx context.Context) *AccountsUpdateCall { 1022 c.ctx_ = ctx 1023 return c 1024} 1025 1026// Header returns an http.Header that can be modified by the caller to 1027// add HTTP headers to the request. 1028func (c *AccountsUpdateCall) Header() http.Header { 1029 if c.header_ == nil { 1030 c.header_ = make(http.Header) 1031 } 1032 return c.header_ 1033} 1034 1035func (c *AccountsUpdateCall) doRequest(alt string) (*http.Response, error) { 1036 reqHeaders := make(http.Header) 1037 reqHeaders.Set("x-goog-api-client", "gl-go/1.11.0 gdcl/20190926") 1038 for k, v := range c.header_ { 1039 reqHeaders[k] = v 1040 } 1041 reqHeaders.Set("User-Agent", c.s.userAgent()) 1042 var body io.Reader = nil 1043 body, err := googleapi.WithoutDataWrapper.JSONReader(c.account) 1044 if err != nil { 1045 return nil, err 1046 } 1047 reqHeaders.Set("Content-Type", "application/json") 1048 c.urlParams_.Set("alt", alt) 1049 c.urlParams_.Set("prettyPrint", "false") 1050 urls := googleapi.ResolveRelative(c.s.BasePath, "accounts/{id}") 1051 urls += "?" + c.urlParams_.Encode() 1052 req, err := http.NewRequest("PUT", urls, body) 1053 if err != nil { 1054 return nil, err 1055 } 1056 req.Header = reqHeaders 1057 googleapi.Expand(req.URL, map[string]string{ 1058 "id": strconv.FormatInt(c.id, 10), 1059 }) 1060 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1061} 1062 1063// Do executes the "adexchangebuyer.accounts.update" call. 1064// Exactly one of *Account or error will be non-nil. Any non-2xx status 1065// code is an error. Response headers are in either 1066// *Account.ServerResponse.Header or (if a response was returned at all) 1067// in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to 1068// check whether the returned error was because http.StatusNotModified 1069// was returned. 1070func (c *AccountsUpdateCall) Do(opts ...googleapi.CallOption) (*Account, error) { 1071 gensupport.SetOptions(c.urlParams_, opts...) 1072 res, err := c.doRequest("json") 1073 if res != nil && res.StatusCode == http.StatusNotModified { 1074 if res.Body != nil { 1075 res.Body.Close() 1076 } 1077 return nil, &googleapi.Error{ 1078 Code: res.StatusCode, 1079 Header: res.Header, 1080 } 1081 } 1082 if err != nil { 1083 return nil, err 1084 } 1085 defer googleapi.CloseBody(res) 1086 if err := googleapi.CheckResponse(res); err != nil { 1087 return nil, err 1088 } 1089 ret := &Account{ 1090 ServerResponse: googleapi.ServerResponse{ 1091 Header: res.Header, 1092 HTTPStatusCode: res.StatusCode, 1093 }, 1094 } 1095 target := &ret 1096 if err := gensupport.DecodeResponse(target, res); err != nil { 1097 return nil, err 1098 } 1099 return ret, nil 1100 // { 1101 // "description": "Updates an existing account.", 1102 // "httpMethod": "PUT", 1103 // "id": "adexchangebuyer.accounts.update", 1104 // "parameterOrder": [ 1105 // "id" 1106 // ], 1107 // "parameters": { 1108 // "id": { 1109 // "description": "The account id", 1110 // "format": "int32", 1111 // "location": "path", 1112 // "required": true, 1113 // "type": "integer" 1114 // } 1115 // }, 1116 // "path": "accounts/{id}", 1117 // "request": { 1118 // "$ref": "Account" 1119 // }, 1120 // "response": { 1121 // "$ref": "Account" 1122 // }, 1123 // "scopes": [ 1124 // "https://www.googleapis.com/auth/adexchange.buyer" 1125 // ] 1126 // } 1127 1128} 1129 1130// method id "adexchangebuyer.creatives.get": 1131 1132type CreativesGetCall struct { 1133 s *Service 1134 accountId int64 1135 buyerCreativeId string 1136 urlParams_ gensupport.URLParams 1137 ifNoneMatch_ string 1138 ctx_ context.Context 1139 header_ http.Header 1140} 1141 1142// Get: Gets the status for a single creative. A creative will be 1143// available 30-40 minutes after submission. 1144func (r *CreativesService) Get(accountId int64, buyerCreativeId string) *CreativesGetCall { 1145 c := &CreativesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1146 c.accountId = accountId 1147 c.buyerCreativeId = buyerCreativeId 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 1153// for more information. 1154func (c *CreativesGetCall) Fields(s ...googleapi.Field) *CreativesGetCall { 1155 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1156 return c 1157} 1158 1159// IfNoneMatch sets the optional parameter which makes the operation 1160// fail if the object's ETag matches the given value. This is useful for 1161// getting updates only after the object has changed since the last 1162// request. Use googleapi.IsNotModified to check whether the response 1163// error from Do is the result of In-None-Match. 1164func (c *CreativesGetCall) IfNoneMatch(entityTag string) *CreativesGetCall { 1165 c.ifNoneMatch_ = entityTag 1166 return c 1167} 1168 1169// Context sets the context to be used in this call's Do method. Any 1170// pending HTTP request will be aborted if the provided context is 1171// canceled. 1172func (c *CreativesGetCall) Context(ctx context.Context) *CreativesGetCall { 1173 c.ctx_ = ctx 1174 return c 1175} 1176 1177// Header returns an http.Header that can be modified by the caller to 1178// add HTTP headers to the request. 1179func (c *CreativesGetCall) Header() http.Header { 1180 if c.header_ == nil { 1181 c.header_ = make(http.Header) 1182 } 1183 return c.header_ 1184} 1185 1186func (c *CreativesGetCall) doRequest(alt string) (*http.Response, error) { 1187 reqHeaders := make(http.Header) 1188 reqHeaders.Set("x-goog-api-client", "gl-go/1.11.0 gdcl/20190926") 1189 for k, v := range c.header_ { 1190 reqHeaders[k] = v 1191 } 1192 reqHeaders.Set("User-Agent", c.s.userAgent()) 1193 if c.ifNoneMatch_ != "" { 1194 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1195 } 1196 var body io.Reader = nil 1197 c.urlParams_.Set("alt", alt) 1198 c.urlParams_.Set("prettyPrint", "false") 1199 urls := googleapi.ResolveRelative(c.s.BasePath, "creatives/{accountId}/{buyerCreativeId}") 1200 urls += "?" + c.urlParams_.Encode() 1201 req, err := http.NewRequest("GET", urls, body) 1202 if err != nil { 1203 return nil, err 1204 } 1205 req.Header = reqHeaders 1206 googleapi.Expand(req.URL, map[string]string{ 1207 "accountId": strconv.FormatInt(c.accountId, 10), 1208 "buyerCreativeId": c.buyerCreativeId, 1209 }) 1210 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1211} 1212 1213// Do executes the "adexchangebuyer.creatives.get" call. 1214// Exactly one of *Creative or error will be non-nil. Any non-2xx status 1215// code is an error. Response headers are in either 1216// *Creative.ServerResponse.Header or (if a response was returned at 1217// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 1218// to check whether the returned error was because 1219// http.StatusNotModified was returned. 1220func (c *CreativesGetCall) Do(opts ...googleapi.CallOption) (*Creative, error) { 1221 gensupport.SetOptions(c.urlParams_, opts...) 1222 res, err := c.doRequest("json") 1223 if res != nil && res.StatusCode == http.StatusNotModified { 1224 if res.Body != nil { 1225 res.Body.Close() 1226 } 1227 return nil, &googleapi.Error{ 1228 Code: res.StatusCode, 1229 Header: res.Header, 1230 } 1231 } 1232 if err != nil { 1233 return nil, err 1234 } 1235 defer googleapi.CloseBody(res) 1236 if err := googleapi.CheckResponse(res); err != nil { 1237 return nil, err 1238 } 1239 ret := &Creative{ 1240 ServerResponse: googleapi.ServerResponse{ 1241 Header: res.Header, 1242 HTTPStatusCode: res.StatusCode, 1243 }, 1244 } 1245 target := &ret 1246 if err := gensupport.DecodeResponse(target, res); err != nil { 1247 return nil, err 1248 } 1249 return ret, nil 1250 // { 1251 // "description": "Gets the status for a single creative. A creative will be available 30-40 minutes after submission.", 1252 // "httpMethod": "GET", 1253 // "id": "adexchangebuyer.creatives.get", 1254 // "parameterOrder": [ 1255 // "accountId", 1256 // "buyerCreativeId" 1257 // ], 1258 // "parameters": { 1259 // "accountId": { 1260 // "description": "The id for the account that will serve this creative.", 1261 // "format": "int32", 1262 // "location": "path", 1263 // "required": true, 1264 // "type": "integer" 1265 // }, 1266 // "buyerCreativeId": { 1267 // "description": "The buyer-specific id for this creative.", 1268 // "location": "path", 1269 // "required": true, 1270 // "type": "string" 1271 // } 1272 // }, 1273 // "path": "creatives/{accountId}/{buyerCreativeId}", 1274 // "response": { 1275 // "$ref": "Creative" 1276 // }, 1277 // "scopes": [ 1278 // "https://www.googleapis.com/auth/adexchange.buyer" 1279 // ] 1280 // } 1281 1282} 1283 1284// method id "adexchangebuyer.creatives.insert": 1285 1286type CreativesInsertCall struct { 1287 s *Service 1288 creative *Creative 1289 urlParams_ gensupport.URLParams 1290 ctx_ context.Context 1291 header_ http.Header 1292} 1293 1294// Insert: Submit a new creative. 1295func (r *CreativesService) Insert(creative *Creative) *CreativesInsertCall { 1296 c := &CreativesInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1297 c.creative = creative 1298 return c 1299} 1300 1301// Fields allows partial responses to be retrieved. See 1302// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1303// for more information. 1304func (c *CreativesInsertCall) Fields(s ...googleapi.Field) *CreativesInsertCall { 1305 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1306 return c 1307} 1308 1309// Context sets the context to be used in this call's Do method. Any 1310// pending HTTP request will be aborted if the provided context is 1311// canceled. 1312func (c *CreativesInsertCall) Context(ctx context.Context) *CreativesInsertCall { 1313 c.ctx_ = ctx 1314 return c 1315} 1316 1317// Header returns an http.Header that can be modified by the caller to 1318// add HTTP headers to the request. 1319func (c *CreativesInsertCall) Header() http.Header { 1320 if c.header_ == nil { 1321 c.header_ = make(http.Header) 1322 } 1323 return c.header_ 1324} 1325 1326func (c *CreativesInsertCall) doRequest(alt string) (*http.Response, error) { 1327 reqHeaders := make(http.Header) 1328 reqHeaders.Set("x-goog-api-client", "gl-go/1.11.0 gdcl/20190926") 1329 for k, v := range c.header_ { 1330 reqHeaders[k] = v 1331 } 1332 reqHeaders.Set("User-Agent", c.s.userAgent()) 1333 var body io.Reader = nil 1334 body, err := googleapi.WithoutDataWrapper.JSONReader(c.creative) 1335 if err != nil { 1336 return nil, err 1337 } 1338 reqHeaders.Set("Content-Type", "application/json") 1339 c.urlParams_.Set("alt", alt) 1340 c.urlParams_.Set("prettyPrint", "false") 1341 urls := googleapi.ResolveRelative(c.s.BasePath, "creatives") 1342 urls += "?" + c.urlParams_.Encode() 1343 req, err := http.NewRequest("POST", urls, body) 1344 if err != nil { 1345 return nil, err 1346 } 1347 req.Header = reqHeaders 1348 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1349} 1350 1351// Do executes the "adexchangebuyer.creatives.insert" call. 1352// Exactly one of *Creative or error will be non-nil. Any non-2xx status 1353// code is an error. Response headers are in either 1354// *Creative.ServerResponse.Header or (if a response was returned at 1355// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 1356// to check whether the returned error was because 1357// http.StatusNotModified was returned. 1358func (c *CreativesInsertCall) Do(opts ...googleapi.CallOption) (*Creative, error) { 1359 gensupport.SetOptions(c.urlParams_, opts...) 1360 res, err := c.doRequest("json") 1361 if res != nil && res.StatusCode == http.StatusNotModified { 1362 if res.Body != nil { 1363 res.Body.Close() 1364 } 1365 return nil, &googleapi.Error{ 1366 Code: res.StatusCode, 1367 Header: res.Header, 1368 } 1369 } 1370 if err != nil { 1371 return nil, err 1372 } 1373 defer googleapi.CloseBody(res) 1374 if err := googleapi.CheckResponse(res); err != nil { 1375 return nil, err 1376 } 1377 ret := &Creative{ 1378 ServerResponse: googleapi.ServerResponse{ 1379 Header: res.Header, 1380 HTTPStatusCode: res.StatusCode, 1381 }, 1382 } 1383 target := &ret 1384 if err := gensupport.DecodeResponse(target, res); err != nil { 1385 return nil, err 1386 } 1387 return ret, nil 1388 // { 1389 // "description": "Submit a new creative.", 1390 // "httpMethod": "POST", 1391 // "id": "adexchangebuyer.creatives.insert", 1392 // "path": "creatives", 1393 // "request": { 1394 // "$ref": "Creative" 1395 // }, 1396 // "response": { 1397 // "$ref": "Creative" 1398 // }, 1399 // "scopes": [ 1400 // "https://www.googleapis.com/auth/adexchange.buyer" 1401 // ] 1402 // } 1403 1404} 1405 1406// method id "adexchangebuyer.creatives.list": 1407 1408type CreativesListCall struct { 1409 s *Service 1410 urlParams_ gensupport.URLParams 1411 ifNoneMatch_ string 1412 ctx_ context.Context 1413 header_ http.Header 1414} 1415 1416// List: Retrieves a list of the authenticated user's active creatives. 1417// A creative will be available 30-40 minutes after submission. 1418func (r *CreativesService) List() *CreativesListCall { 1419 c := &CreativesListCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1420 return c 1421} 1422 1423// MaxResults sets the optional parameter "maxResults": Maximum number 1424// of entries returned on one result page. If not set, the default is 1425// 100. 1426func (c *CreativesListCall) MaxResults(maxResults int64) *CreativesListCall { 1427 c.urlParams_.Set("maxResults", fmt.Sprint(maxResults)) 1428 return c 1429} 1430 1431// PageToken sets the optional parameter "pageToken": A continuation 1432// token, used to page through ad clients. To retrieve the next page, 1433// set this parameter to the value of "nextPageToken" from the previous 1434// response. 1435func (c *CreativesListCall) PageToken(pageToken string) *CreativesListCall { 1436 c.urlParams_.Set("pageToken", pageToken) 1437 return c 1438} 1439 1440// StatusFilter sets the optional parameter "statusFilter": When 1441// specified, only creatives having the given status are returned. 1442// 1443// Possible values: 1444// "approved" - Creatives which have been approved. 1445// "disapproved" - Creatives which have been disapproved. 1446// "not_checked" - Creatives whose status is not yet checked. 1447func (c *CreativesListCall) StatusFilter(statusFilter string) *CreativesListCall { 1448 c.urlParams_.Set("statusFilter", statusFilter) 1449 return c 1450} 1451 1452// Fields allows partial responses to be retrieved. See 1453// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1454// for more information. 1455func (c *CreativesListCall) Fields(s ...googleapi.Field) *CreativesListCall { 1456 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1457 return c 1458} 1459 1460// IfNoneMatch sets the optional parameter which makes the operation 1461// fail if the object's ETag matches the given value. This is useful for 1462// getting updates only after the object has changed since the last 1463// request. Use googleapi.IsNotModified to check whether the response 1464// error from Do is the result of In-None-Match. 1465func (c *CreativesListCall) IfNoneMatch(entityTag string) *CreativesListCall { 1466 c.ifNoneMatch_ = entityTag 1467 return c 1468} 1469 1470// Context sets the context to be used in this call's Do method. Any 1471// pending HTTP request will be aborted if the provided context is 1472// canceled. 1473func (c *CreativesListCall) Context(ctx context.Context) *CreativesListCall { 1474 c.ctx_ = ctx 1475 return c 1476} 1477 1478// Header returns an http.Header that can be modified by the caller to 1479// add HTTP headers to the request. 1480func (c *CreativesListCall) Header() http.Header { 1481 if c.header_ == nil { 1482 c.header_ = make(http.Header) 1483 } 1484 return c.header_ 1485} 1486 1487func (c *CreativesListCall) doRequest(alt string) (*http.Response, error) { 1488 reqHeaders := make(http.Header) 1489 reqHeaders.Set("x-goog-api-client", "gl-go/1.11.0 gdcl/20190926") 1490 for k, v := range c.header_ { 1491 reqHeaders[k] = v 1492 } 1493 reqHeaders.Set("User-Agent", c.s.userAgent()) 1494 if c.ifNoneMatch_ != "" { 1495 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1496 } 1497 var body io.Reader = nil 1498 c.urlParams_.Set("alt", alt) 1499 c.urlParams_.Set("prettyPrint", "false") 1500 urls := googleapi.ResolveRelative(c.s.BasePath, "creatives") 1501 urls += "?" + c.urlParams_.Encode() 1502 req, err := http.NewRequest("GET", urls, body) 1503 if err != nil { 1504 return nil, err 1505 } 1506 req.Header = reqHeaders 1507 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1508} 1509 1510// Do executes the "adexchangebuyer.creatives.list" call. 1511// Exactly one of *CreativesList or error will be non-nil. Any non-2xx 1512// status code is an error. Response headers are in either 1513// *CreativesList.ServerResponse.Header or (if a response was returned 1514// at all) in error.(*googleapi.Error).Header. Use 1515// googleapi.IsNotModified to check whether the returned error was 1516// because http.StatusNotModified was returned. 1517func (c *CreativesListCall) Do(opts ...googleapi.CallOption) (*CreativesList, error) { 1518 gensupport.SetOptions(c.urlParams_, opts...) 1519 res, err := c.doRequest("json") 1520 if res != nil && res.StatusCode == http.StatusNotModified { 1521 if res.Body != nil { 1522 res.Body.Close() 1523 } 1524 return nil, &googleapi.Error{ 1525 Code: res.StatusCode, 1526 Header: res.Header, 1527 } 1528 } 1529 if err != nil { 1530 return nil, err 1531 } 1532 defer googleapi.CloseBody(res) 1533 if err := googleapi.CheckResponse(res); err != nil { 1534 return nil, err 1535 } 1536 ret := &CreativesList{ 1537 ServerResponse: googleapi.ServerResponse{ 1538 Header: res.Header, 1539 HTTPStatusCode: res.StatusCode, 1540 }, 1541 } 1542 target := &ret 1543 if err := gensupport.DecodeResponse(target, res); err != nil { 1544 return nil, err 1545 } 1546 return ret, nil 1547 // { 1548 // "description": "Retrieves a list of the authenticated user's active creatives. A creative will be available 30-40 minutes after submission.", 1549 // "httpMethod": "GET", 1550 // "id": "adexchangebuyer.creatives.list", 1551 // "parameters": { 1552 // "maxResults": { 1553 // "description": "Maximum number of entries returned on one result page. If not set, the default is 100. Optional.", 1554 // "format": "uint32", 1555 // "location": "query", 1556 // "maximum": "1000", 1557 // "minimum": "1", 1558 // "type": "integer" 1559 // }, 1560 // "pageToken": { 1561 // "description": "A continuation token, used to page through ad clients. To retrieve the next page, set this parameter to the value of \"nextPageToken\" from the previous response. Optional.", 1562 // "location": "query", 1563 // "type": "string" 1564 // }, 1565 // "statusFilter": { 1566 // "description": "When specified, only creatives having the given status are returned.", 1567 // "enum": [ 1568 // "approved", 1569 // "disapproved", 1570 // "not_checked" 1571 // ], 1572 // "enumDescriptions": [ 1573 // "Creatives which have been approved.", 1574 // "Creatives which have been disapproved.", 1575 // "Creatives whose status is not yet checked." 1576 // ], 1577 // "location": "query", 1578 // "type": "string" 1579 // } 1580 // }, 1581 // "path": "creatives", 1582 // "response": { 1583 // "$ref": "CreativesList" 1584 // }, 1585 // "scopes": [ 1586 // "https://www.googleapis.com/auth/adexchange.buyer" 1587 // ] 1588 // } 1589 1590} 1591 1592// Pages invokes f for each page of results. 1593// A non-nil error returned from f will halt the iteration. 1594// The provided context supersedes any context provided to the Context method. 1595func (c *CreativesListCall) Pages(ctx context.Context, f func(*CreativesList) error) error { 1596 c.ctx_ = ctx 1597 defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point 1598 for { 1599 x, err := c.Do() 1600 if err != nil { 1601 return err 1602 } 1603 if err := f(x); err != nil { 1604 return err 1605 } 1606 if x.NextPageToken == "" { 1607 return nil 1608 } 1609 c.PageToken(x.NextPageToken) 1610 } 1611} 1612