You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1605 lines
52 KiB

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