No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

1522 líneas
50 KiB

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