管理放送敲定的交易

您可以使用下列方法,開始放送、暫停及恢復買家帳戶和任何客戶交易

手動放送交易

根據預設,只要雙方都接受,敲定的交易就會自動變成可放送。

如要手動將程式輔助保證交易設為可供放送,請與客戶技術顧問聯絡。技術客戶經理啟用後,請使用 buyers.finalizedDeals.setReadyToServe 方法,手動指出最終的程式輔助保證交易已準備就緒。這項呼叫會在設定的航班時間內,開始處理您敲定的交易。

建議您使用即時出價 API 的 buyers.creatives 資源,為要用於交易的每個廣告素材申請審查。廣告素材獲得核准後,您就可以將這些廣告素材新增至交易

您要導入的所有廣告素材都獲得核准並新增至交易之後,請呼叫 buyers.finalizedDeals.setReadyToServe,指出您已準備好回應交易的出價要求。

這個方法不會影響已放送的交易。

以下範例示範如何使用 setReadyToServe 方法手動開始提供交易。

REST

要求

POST https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/finalizedDeals/1840860:setReadyToServe?alt=json
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

回應

{
 "name": "buyers/12345678/finalizedDeals/1840860",
 "deal": {
   "name": "buyers/12345678/proposals/MP8642048/deals/1840860",
   "createTime": "2031-03-26T05:53:33.053Z",
   "updateTime": "2031-03-28T05:54:33.442Z",
   "displayName": "test-pg-deal-4",
   "buyer": "buyers/12345678",
   "publisherProfile": "buyers/12345678/publisherProfiles/PP12345",
   "flightStartTime": "2032-03-31T16:00:00Z",
   "flightEndTime": "2032-03-31T18:59:00Z",
   "targeting": {
     "inventorySizeTargeting": {
       "targetedInventorySizes": [
         {
           "width": "200",
           "height": "200",
           "type": "PIXEL"
         },
         {
           "width": "234",
           "height": "60",
           "type": "PIXEL"
         },
         {
           "width": "240",
           "height": "400",
           "type": "PIXEL"
         },
         {
           "width": "300",
           "height": "250",
           "type": "PIXEL"
         },
         {
           "width": "300",
           "height": "600",
           "type": "PIXEL"
         },
         {
           "width": "300",
           "height": "1050",
           "type": "PIXEL"
         }
       ]
     }
   },
   "creativeRequirements": {
     "creativePreApprovalPolicy": "SELLER_PRE_APPROVAL_NOT_REQUIRED",
     "creativeSafeFrameCompatibility": "COMPATIBLE",
     "programmaticCreativeSource": "ADVERTISER",
     "creativeFormat": "DISPLAY"
   },
   "deliveryControl": {
     "deliveryRateType": "EVENLY"
   },
   "billedBuyer": "buyers/12345678",
   "dealType": "PROGRAMMATIC_GUARANTEED",
   "programmaticGuaranteedTerms": {
     "guaranteedLooks": "1",
     "fixedPrice": {
       "type": "CPM",
       "amount": {
         "currencyCode": "USD",
         "nanos": 10000000
       }
     },
     "reservationType": "STANDARD"
   },
   "sellerTimeZone": {
     "id": "Asia/Shanghai"
   }
 },
 "dealServingStatus": "ENDED",
 "dealPausingInfo": {
   "pausingConsented": true
 },
 "rtbMetrics": {},
 "readyToServe": true
}

C#

/* Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using Google.Apis.AuthorizedBuyersMarketplace.v1;
using Google.Apis.AuthorizedBuyersMarketplace.v1.Data;
using Mono.Options;

using System;
using System.Collections.Generic;

namespace Google.Apis.AuthorizedBuyersMarketplace.Examples.v1.Buyers.FinalizedDeals
{
    /// <summary>
    /// Signals that the given finalized deal is ready to serve.
    ///
    /// By default, deals are set ready to serve as soon as they're finalized. For programmatic
    /// guaranteed deals, bidders can opt out of this feature by asking their account manager. This
    /// is recommended for programmatic guaranteed deals in order to ensure that bidders have
    /// creatives prepared to be used in placing bids once the deal is serving. Use
    /// finalizedDeals.addCreative to associate creatives with a programmatic guaranteed deal.
    /// </summary>
    public class SetReadyToServeFinalizedDeals : ExampleBase
    {
        private AuthorizedBuyersMarketplaceService mkService;

        /// <summary>
        /// Constructor.
        /// </summary>
        public SetReadyToServeFinalizedDeals()
        {
            mkService = Utilities.GetAuthorizedBuyersMarketplaceService();
        }

        /// <summary>
        /// Returns a description about the code example.
        /// </summary>
        public override string Description
        {
            get => "This code example signals that the given finalized deal is ready to serve.";
        }

        /// <summary>
        /// Parse specified arguments.
        /// </summary>
        protected override Dictionary<string, object> ParseArguments(List<string> exampleArgs) {
            string[] requiredOptions = new string[] {"account_id", "deal_id"};
            bool showHelp = false;

            string accountId = null;
            string dealId = null;

            OptionSet options = new OptionSet {
                "Signals that the given finalized deal is ready to serve.",
                {
                    "h|help",
                    "Show help message and exit.",
                    h => showHelp = h != null
                },
                {
                    "a|account_id=",
                    ("[Required] The resource ID of the buyers resource under which the " +
                     "finalized deal was created. This will be used to construct the name used " +
                     "as a path parameter for the finalizedDeals.setReadyToServe request."),
                    a => accountId = a
                },
                {
                    "d|deal_id=",
                    ("[Required] The resource ID of the buyers.finalizedDeals resource that is " +
                     "you intend to signal is ready to serve. This will be used to construct " +
                     "the name used as a path parameter for the finalizedDeals.setReadyToServe " +
                     "request."),
                    d => dealId = d
                },
            };

            List<string> extras = options.Parse(exampleArgs);
            var parsedArgs = new Dictionary<string, object>();

            // Show help message.
            if (showHelp == true)
            {
                options.WriteOptionDescriptions(Console.Out);
                Environment.Exit(0);
            }
            // Set optional arguments.
            parsedArgs["account_id"] = accountId;
            parsedArgs["deal_id"] = dealId;
            // Validate that options were set correctly.
            Utilities.ValidateOptions(options, parsedArgs, requiredOptions, extras);

            return parsedArgs;
        }

        /// <summary>
        /// Run the example.
        /// </summary>
        /// <param name="parsedArgs">Parsed arguments for the example.</param>
        protected override void Run(Dictionary<string, object> parsedArgs)
        {
            string accountId = (string) parsedArgs["account_id"];
            string dealId = (string) parsedArgs["deal_id"];
            string name = $"buyers/{accountId}/finalizedDeals/{dealId}";

            BuyersResource.FinalizedDealsResource.SetReadyToServeRequest request =
                mkService.Buyers.FinalizedDeals.SetReadyToServe(new SetReadyToServeRequest(), name);
            FinalizedDeal response = null;

            Console.WriteLine("Signaling that finalized deal with name \"{0}\" is ready to serve.",
                name);

            try
            {
                response = request.Execute();
            }
            catch (Exception exception)
            {
                throw new ApplicationException(
                    $"Marketplace API returned error response:\n{exception.Message}");
            }

            Utilities.PrintFinalizedDeal(response);
        }
    }
}

Java

/*
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.api.services.samples.authorizedbuyers.marketplace.v1.buyers.finalizedDeals;

import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.FinalizedDeal;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.SetReadyToServeRequest;
import com.google.api.services.samples.authorizedbuyers.marketplace.Utils;
import java.io.IOException;
import java.security.GeneralSecurityException;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;

/**
 * This sample illustrates how to signal that the given finalized deal is ready to serve.
 *
 * <p>By default, deals are set ready to serve as soon as they're finalized. For programmatic
 * guaranteed deals, bidders can opt out of this feature by asking their account manager. This is
 * recommended for programmatic guaranteed deals in order to ensure that bidders have creatives
 * prepared to be used in placing bids once the deal is serving. Use finalizedDeals.addCreative to
 * associate creatives with a programmatic guaranteed deal.
 */
public class SetReadyToServeFinalizedDeals {

  public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) {
    Long accountId = parsedArgs.getLong("account_id");
    Long dealId = parsedArgs.getLong("deal_id");
    String name = String.format("buyers/%d/finalizedDeals/%d", accountId, dealId);

    FinalizedDeal finalizedDeal = null;

    try {
      finalizedDeal =
          marketplaceClient
              .buyers()
              .finalizedDeals()
              .setReadyToServe(name, new SetReadyToServeRequest())
              .execute();
    } catch (IOException ex) {
      System.out.printf("Marketplace API returned error response:%n%s", ex);
      System.exit(1);
    }

    System.out.printf("Signaling that finalized deal with name \"%s\" is ready to serve:%n", name);
    Utils.printFinalizedDeal(finalizedDeal);
  }

  public static void main(String[] args) {
    ArgumentParser parser =
        ArgumentParsers.newFor("SetReadyToServeFinalizedDeals")
            .build()
            .defaultHelp(true)
            .description(("Signals that the given finalized deal is ready to serve."));
    parser
        .addArgument("-a", "--account_id")
        .help(
            "The resource ID of the buyers resource under which the finalized was created. "
                + "This will be used to construct the parent used as a path parameter for the "
                + "finalizedDeals.setReadyToServe request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("-d", "--deal_id")
        .help(
            "The resource ID of the buyers.finalizedDeals resource that you intend to signal is"
                + " ready to serve. This will be used to construct the name used as a path"
                + " parameter for the finalizedDeals.setReadyToServe request.")
        .required(true)
        .type(Long.class);

    Namespace parsedArgs = null;
    try {
      parsedArgs = parser.parseArgs(args);
    } catch (ArgumentParserException ex) {
      parser.handleError(ex);
      System.exit(1);
    }

    AuthorizedBuyersMarketplace client = null;
    try {
      client = Utils.getMarketplaceClient();
    } catch (IOException ex) {
      System.out.printf("Unable to create Marketplace API service:%n%s", ex);
      System.out.println("Did you specify a valid path to a service account key file?");
      System.exit(1);
    } catch (GeneralSecurityException ex) {
      System.out.printf("Unable to establish secure HttpTransport:%n%s", ex);
      System.exit(1);
    }

    execute(client, parsedArgs);
  }
}

Python

#!/usr/bin/python
#
# Copyright 2021 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Signals that the given finalized deal is ready to serve.

By default, deals are set ready to serve as soon as they're finalized. For
programmatic guaranteed deals, bidders can opt out of this feature by asking
their account manager. This is recommended for programmatic guaranteed deals in
order to ensure that bidders have creatives prepared to be used in placing bids
once the deal is serving. Use finalizedDeals.addCreative to associate creatives
with a programmatic guaranteed deal.
"""


import argparse
import os
import pprint
import sys

sys.path.insert(0, os.path.abspath('../../..'))

from googleapiclient.errors import HttpError

import util


_FINALIZED_DEALS_NAME_TEMPLATE = 'buyers/%s/finalizedDeals/%s'

DEFAULT_BUYER_RESOURCE_ID = 'ENTER_BUYER_RESOURCE_ID_HERE'
DEFAULT_FINALIZED_DEAL_RESOURCE_ID = 'ENTER_DEAL_RESOURCE_ID_HERE'


def main(marketplace, args):
    finalized_deal_name = _FINALIZED_DEALS_NAME_TEMPLATE % (
        args.account_id, args.deal_id)

    print(f'Setting finalized deal with name "{finalized_deal_name}" as ready '
          'to serve:')
    try:
        # Construct and execute the request.
        response = marketplace.buyers().finalizedDeals().setReadyToServe(
            deal=finalized_deal_name).execute()
    except HttpError as e:
        print(e)
        sys.exit(1)

    pprint.pprint(response)


if __name__ == '__main__':
    try:
        service = util.get_service(version='v1')
    except IOError as ex:
        print(f'Unable to create marketplace service - {ex}')
        print('Did you specify the key file in util.py?')
        sys.exit(1)

    parser = argparse.ArgumentParser(
        description='Signals that a finalized deal is ready to serve.')
    # Required fields.
    parser.add_argument(
        '-a', '--account_id', default=DEFAULT_BUYER_RESOURCE_ID,
        help=('The resource ID of the buyers resource for which the finalized '
              'deal is being set ready to serve. This will be used to '
              'construct the name used as a path parameter for the '
              'finalizedDeals.setReadyToServe request.'))
    parser.add_argument(
        '-d', '--deal_id', default=DEFAULT_FINALIZED_DEAL_RESOURCE_ID,
        help=('The resource ID of the buyers.finalizedDeals resource that is '
              'being set ready to serve. This will be used to construct the '
              'name used as a path parameter for the '
              'finalizedDeals.setReadyToServe request.'))

    main(service, parser.parse_args())

暫停放送

您可以使用 buyers.finalizedDeals.pause 方法暫停已完成的交易。如果您暫停交易,該交易的出價要求就會停止。

買方無法暫停私下競價交易或首選交易。

以下範例說明如何使用暫停方法暫停已敲定的交易。

REST

要求

POST https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/finalizedDeals/1840860:pause?alt=json
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

回應

{
 "name": "buyers/12345678/finalizedDeals/1840860",
 "deal": {
   "name": "buyers/12345678/proposals/MP8642048/deals/1840860",
   "createTime": "2031-03-26T05:53:33.053Z",
   "updateTime": "2032-03-31T16:30:21.351Z",
   "displayName": "test-pg-deal-4",
   "buyer": "buyers/12345678",
   "publisherProfile": "buyers/12345678/publisherProfiles/PP12345",
   "flightStartTime": "2032-03-31T16:00:00Z",
   "flightEndTime": "2032-03-31T18:59:00Z",
   "targeting": {
     "inventorySizeTargeting": {
       "targetedInventorySizes": [
         {
           "width": "200",
           "height": "200",
           "type": "PIXEL"
         },
         {
           "width": "234",
           "height": "60",
           "type": "PIXEL"
         },
         {
           "width": "240",
           "height": "400",
           "type": "PIXEL"
         },
         {
           "width": "300",
           "height": "250",
           "type": "PIXEL"
         },
         {
           "width": "300",
           "height": "600",
           "type": "PIXEL"
         },
         {
           "width": "300",
           "height": "1050",
           "type": "PIXEL"
         }
       ]
     }
   },
   "creativeRequirements": {
     "creativePreApprovalPolicy": "SELLER_PRE_APPROVAL_NOT_REQUIRED",
     "creativeSafeFrameCompatibility": "COMPATIBLE",
     "programmaticCreativeSource": "ADVERTISER",
     "creativeFormat": "DISPLAY"
   },
   "deliveryControl": {
     "deliveryRateType": "EVENLY"
   },
   "billedBuyer": "buyers/12345678",
   "dealType": "PROGRAMMATIC_GUARANTEED",
   "programmaticGuaranteedTerms": {
     "guaranteedLooks": "1",
     "fixedPrice": {
       "type": "CPM",
       "amount": {
         "currencyCode": "USD",
         "nanos": 10000000
       }
     },
     "reservationType": "STANDARD"
   },
   "sellerTimeZone": {
     "id": "Asia/Shanghai"
   }
 },
 "dealServingStatus": "ENDED",
 "dealPausingInfo": {
   "pausingConsented": true
 },
 "rtbMetrics": {},
 "readyToServe": true
}

C#

/* Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using Google.Apis.AuthorizedBuyersMarketplace.v1;
using Google.Apis.AuthorizedBuyersMarketplace.v1.Data;
using Mono.Options;

using System;
using System.Collections.Generic;

namespace Google.Apis.AuthorizedBuyersMarketplace.Examples.v1.Buyers.FinalizedDeals
{
    /// <summary>
    /// Pauses serving of a given finalized deal.
    ///
    /// Note that only programmatic guaranteed deals can be paused by buyers at this time.
    /// </summary>
    public class PauseFinalizedDeals : ExampleBase
    {
        private AuthorizedBuyersMarketplaceService mkService;

        /// <summary>
        /// Constructor.
        /// </summary>
        public PauseFinalizedDeals()
        {
            mkService = Utilities.GetAuthorizedBuyersMarketplaceService();
        }

        /// <summary>
        /// Returns a description about the code example.
        /// </summary>
        public override string Description
        {
            get => "This code example pauses serving of a given finalized deal.";
        }

        /// <summary>
        /// Parse specified arguments.
        /// </summary>
        protected override Dictionary<string, object> ParseArguments(List<string> exampleArgs) {
            string[] requiredOptions = new string[] {"account_id", "deal_id"};
            bool showHelp = false;

            string accountId = null;
            string dealId = null;

            OptionSet options = new OptionSet {
                "Pauses serving of a given finalized deal.",
                {
                    "h|help",
                    "Show help message and exit.",
                    h => showHelp = h != null
                },
                {
                    "a|account_id=",
                    ("[Required] The resource ID of the buyers resource under which the " +
                     "finalized deal was created. This will be used to construct the name used " +
                     "as a path parameter for the finalizedDeals.pause request."),
                    a => accountId = a
                },
                {
                    "d|deal_id=",
                    ("[Required] The resource ID of the buyers.finalizedDeals resource that is " +
                     "being paused. This will be used to construct the name used as a path " +
                     "parameter for the finalizedDeals.pause request."),
                    d => dealId = d
                },
            };

            List<string> extras = options.Parse(exampleArgs);
            var parsedArgs = new Dictionary<string, object>();

            // Show help message.
            if (showHelp == true)
            {
                options.WriteOptionDescriptions(Console.Out);
                Environment.Exit(0);
            }
            // Set optional arguments.
            parsedArgs["account_id"] = accountId;
            parsedArgs["deal_id"] = dealId;
            // Validate that options were set correctly.
            Utilities.ValidateOptions(options, parsedArgs, requiredOptions, extras);

            return parsedArgs;
        }

        /// <summary>
        /// Run the example.
        /// </summary>
        /// <param name="parsedArgs">Parsed arguments for the example.</param>
        protected override void Run(Dictionary<string, object> parsedArgs)
        {
            string accountId = (string) parsedArgs["account_id"];
            string dealId = (string) parsedArgs["deal_id"];
            string name = $"buyers/{accountId}/finalizedDeals/{dealId}";

            BuyersResource.FinalizedDealsResource.PauseRequest request =
                mkService.Buyers.FinalizedDeals.Pause(new PauseFinalizedDealRequest(), name);
            FinalizedDeal response = null;

            Console.WriteLine("Pausing a finalized deal with name: {0}", name);

            try
            {
                response = request.Execute();
            }
            catch (Exception exception)
            {
                throw new ApplicationException(
                    $"Marketplace API returned error response:\n{exception.Message}");
            }

            Utilities.PrintFinalizedDeal(response);
        }
    }
}

Java

/*
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.api.services.samples.authorizedbuyers.marketplace.v1.buyers.finalizedDeals;

import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.FinalizedDeal;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.PauseFinalizedDealRequest;
import com.google.api.services.samples.authorizedbuyers.marketplace.Utils;
import java.io.IOException;
import java.security.GeneralSecurityException;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;

/**
 * This sample illustrates how to pause serving of a finalized deal.
 *
 * <p>Note that only programmatic guaranteed deals can be paused by buyers at this time.
 */
public class PauseFinalizedDeals {

  public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) {
    Long accountId = parsedArgs.getLong("account_id");
    Long dealId = parsedArgs.getLong("deal_id");
    String name = String.format("buyers/%d/finalizedDeals/%d", accountId, dealId);

    FinalizedDeal finalizedDeal = null;

    try {
      finalizedDeal =
          marketplaceClient
              .buyers()
              .finalizedDeals()
              .pause(name, new PauseFinalizedDealRequest())
              .execute();
    } catch (IOException ex) {
      System.out.printf("Marketplace API returned error response:%n%s", ex);
      System.exit(1);
    }

    System.out.printf(
        "Paused finalized deal with ID \"%d\" for buyer account ID \"%d\":%n", dealId, accountId);
    Utils.printFinalizedDeal(finalizedDeal);
  }

  public static void main(String[] args) {
    ArgumentParser parser =
        ArgumentParsers.newFor("PauseFinalizedDeals")
            .build()
            .defaultHelp(true)
            .description(("Pause a finalized deal for the given buyer account ID and deal ID."));
    parser
        .addArgument("-a", "--account_id")
        .help(
            "The resource ID of the buyers resource under which the finalized was created. "
                + "This will be used to construct the parent used as a path parameter for the "
                + "finalizedDeals.pause request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("-d", "--deal_id")
        .help(
            "The resource ID of the buyers.finalizedDeals resource that is being paused. This "
                + "will be used to construct the name used as a path parameter for the "
                + "finalizedDeals.pause request.")
        .required(true)
        .type(Long.class);

    Namespace parsedArgs = null;
    try {
      parsedArgs = parser.parseArgs(args);
    } catch (ArgumentParserException ex) {
      parser.handleError(ex);
      System.exit(1);
    }

    AuthorizedBuyersMarketplace client = null;
    try {
      client = Utils.getMarketplaceClient();
    } catch (IOException ex) {
      System.out.printf("Unable to create Marketplace API service:%n%s", ex);
      System.out.println("Did you specify a valid path to a service account key file?");
      System.exit(1);
    } catch (GeneralSecurityException ex) {
      System.out.printf("Unable to establish secure HttpTransport:%n%s", ex);
      System.exit(1);
    }

    execute(client, parsedArgs);
  }
}

Python

#!/usr/bin/python
#
# Copyright 2021 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Pauses serving of a given finalized deal.

Note that only programmatic guaranteed deals can be paused by buyers at this
time.
"""


import argparse
import os
import pprint
import sys

sys.path.insert(0, os.path.abspath('../../..'))

from googleapiclient.errors import HttpError

import util


_FINALIZED_DEALS_NAME_TEMPLATE = 'buyers/%s/finalizedDeals/%s'

DEFAULT_BUYER_RESOURCE_ID = 'ENTER_BUYER_RESOURCE_ID_HERE'
DEFAULT_FINALIZED_DEAL_RESOURCE_ID = 'ENTER_DEAL_RESOURCE_ID_HERE'


def main(marketplace, args):
    finalized_deal_name = _FINALIZED_DEALS_NAME_TEMPLATE % (
        args.account_id, args.deal_id)

    body = {
        'reason': 'Paused by Marketplace Python sample.'
    }

    print(f'Pausing finalized deal with name "{finalized_deal_name}":')
    try:
        # Construct and execute the request.
        response = marketplace.buyers().finalizedDeals().pause(
            name=finalized_deal_name, body=body).execute()
    except HttpError as e:
        print(e)
        sys.exit(1)

    pprint.pprint(response)


if __name__ == '__main__':
    try:
        service = util.get_service(version='v1')
    except IOError as ex:
        print(f'Unable to create marketplace service - {ex}')
        print('Did you specify the key file in util.py?')
        sys.exit(1)

    parser = argparse.ArgumentParser(
        description=('Pause a finalized deal for the given buyer account ID '
                     'and deal ID.'))
    # Required fields.
    parser.add_argument(
        '-a', '--account_id', default=DEFAULT_BUYER_RESOURCE_ID,
        help=('The resource ID of the buyers resource for which the finalized '
              'deal is being paused. This will be used to construct the name '
              'used as a path parameter for the finalizedDeals.pause request.'))
    parser.add_argument(
        '-d', '--deal_id', default=DEFAULT_FINALIZED_DEAL_RESOURCE_ID,
        help=('The resource ID of the buyers.finalizedDeals resource that is '
              'being paused. This will be used to construct the name used as a '
              'path parameter for the finalizedDeals.pause request.'))

    main(service, parser.parse_args())

恢復提供

您可以使用 buyers.finalizedDeals.resume 方法,恢復已暫停的交易。恢復交易後 您就會收到該交易的出價要求

買方無法恢復已暫停的私下競價交易或首選交易。

以下範例說明如何使用繼續方法,恢復已敲定的交易。

REST

要求

POST https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/finalizedDeals/1840860:resume?alt=json
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

回應

{
 "name": "buyers/12345678/finalizedDeals/1840860",
 "deal": {
   "name": "buyers/12345678/proposals/MP8642048/deals/1840860",
   "createTime": "2031-03-26T05:53:33.053Z",
   "updateTime": "2032-03-31T16:35:12.413Z",
   "displayName": "test-pg-deal-4",
   "buyer": "buyers/12345678",
   "publisherProfile": "buyers/12345678/publisherProfiles/PP12345",
   "flightStartTime": "2032-03-31T16:00:00Z",
   "flightEndTime": "2032-03-31T18:59:00Z",
   "targeting": {
     "inventorySizeTargeting": {
       "targetedInventorySizes": [
         {
           "width": "200",
           "height": "200",
           "type": "PIXEL"
         },
         {
           "width": "234",
           "height": "60",
           "type": "PIXEL"
         },
         {
           "width": "240",
           "height": "400",
           "type": "PIXEL"
         },
         {
           "width": "300",
           "height": "250",
           "type": "PIXEL"
         },
         {
           "width": "300",
           "height": "600",
           "type": "PIXEL"
         },
         {
           "width": "300",
           "height": "1050",
           "type": "PIXEL"
         }
       ]
     }
   },
   "creativeRequirements": {
     "creativePreApprovalPolicy": "SELLER_PRE_APPROVAL_NOT_REQUIRED",
     "creativeSafeFrameCompatibility": "COMPATIBLE",
     "programmaticCreativeSource": "ADVERTISER",
     "creativeFormat": "DISPLAY"
   },
   "deliveryControl": {
     "deliveryRateType": "EVENLY"
   },
   "billedBuyer": "buyers/12345678",
   "dealType": "PROGRAMMATIC_GUARANTEED",
   "programmaticGuaranteedTerms": {
     "guaranteedLooks": "1",
     "fixedPrice": {
       "type": "CPM",
       "amount": {
         "currencyCode": "USD",
         "nanos": 10000000
       }
     },
     "reservationType": "STANDARD"
   },
   "sellerTimeZone": {
     "id": "Asia/Shanghai"
   }
 },
 "dealServingStatus": "ENDED",
 "dealPausingInfo": {
   "pausingConsented": true
 },
 "rtbMetrics": {},
 "readyToServe": true
}

C#

/* Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using Google.Apis.AuthorizedBuyersMarketplace.v1;
using Google.Apis.AuthorizedBuyersMarketplace.v1.Data;
using Mono.Options;

using System;
using System.Collections.Generic;

namespace Google.Apis.AuthorizedBuyersMarketplace.Examples.v1.Buyers.FinalizedDeals
{
    /// <summary>
    /// Resume serving of a given finalized deal.
    ///
    /// Note that only programmatic guaranteed deals can be resumed by buyers at this time.
    /// </summary>
    public class ResumeFinalizedDeals : ExampleBase
    {
        private AuthorizedBuyersMarketplaceService mkService;

        /// <summary>
        /// Constructor.
        /// </summary>
        public ResumeFinalizedDeals()
        {
            mkService = Utilities.GetAuthorizedBuyersMarketplaceService();
        }

        /// <summary>
        /// Returns a description about the code example.
        /// </summary>
        public override string Description
        {
            get => "This code example resumes serving of a given finalized deal.";
        }

        /// <summary>
        /// Parse specified arguments.
        /// </summary>
        protected override Dictionary<string, object> ParseArguments(List<string> exampleArgs) {
            string[] requiredOptions = new string[] {"account_id", "deal_id"};
            bool showHelp = false;

            string accountId = null;
            string dealId = null;

            OptionSet options = new OptionSet {
                "Resumes serving of a given finalized deal.",
                {
                    "h|help",
                    "Show help message and exit.",
                    h => showHelp = h != null
                },
                {
                    "a|account_id=",
                    ("[Required] The resource ID of the buyers resource under which the " +
                     "finalized deal was created. This will be used to construct the name used " +
                     "as a path parameter for the finalizedDeals.resume request."),
                    a => accountId = a
                },
                {
                    "d|deal_id=",
                    ("[Required] The resource ID of the buyers.finalizedDeals resource that is " +
                     "being resumed. This will be used to construct the name used as a path " +
                     "parameter for the finalizedDeals.resume request."),
                    d => dealId = d
                },
            };

            List<string> extras = options.Parse(exampleArgs);
            var parsedArgs = new Dictionary<string, object>();

            // Show help message.
            if (showHelp == true)
            {
                options.WriteOptionDescriptions(Console.Out);
                Environment.Exit(0);
            }
            // Set optional arguments.
            parsedArgs["account_id"] = accountId;
            parsedArgs["deal_id"] = dealId;
            // Validate that options were set correctly.
            Utilities.ValidateOptions(options, parsedArgs, requiredOptions, extras);

            return parsedArgs;
        }

        /// <summary>
        /// Run the example.
        /// </summary>
        /// <param name="parsedArgs">Parsed arguments for the example.</param>
        protected override void Run(Dictionary<string, object> parsedArgs)
        {
            string accountId = (string) parsedArgs["account_id"];
            string dealId = (string) parsedArgs["deal_id"];
            string name = $"buyers/{accountId}/finalizedDeals/{dealId}";

            BuyersResource.FinalizedDealsResource.ResumeRequest request =
                mkService.Buyers.FinalizedDeals.Resume(new ResumeFinalizedDealRequest(), name);
            FinalizedDeal response = null;

            Console.WriteLine("Resuming a finalized deal with name: {0}", name);

            try
            {
                response = request.Execute();
            }
            catch (Exception exception)
            {
                throw new ApplicationException(
                    $"Marketplace API returned error response:\n{exception.Message}");
            }

            Utilities.PrintFinalizedDeal(response);
        }
    }
}

Java

/*
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.api.services.samples.authorizedbuyers.marketplace.v1.buyers.finalizedDeals;

import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.FinalizedDeal;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.ResumeFinalizedDealRequest;
import com.google.api.services.samples.authorizedbuyers.marketplace.Utils;
import java.io.IOException;
import java.security.GeneralSecurityException;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import net.sourceforge.argparse4j.inf.Namespace;

/**
 * This sample illustrates how to resume serving of a finalized deal.
 *
 * <p>Note that only programmatic guaranteed deals can be resumed by buyers at this time.
 */
public class ResumeFinalizedDeals {

  public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) {
    Long accountId = parsedArgs.getLong("account_id");
    Long dealId = parsedArgs.getLong("deal_id");
    String name = String.format("buyers/%d/finalizedDeals/%d", accountId, dealId);

    FinalizedDeal finalizedDeal = null;

    try {
      finalizedDeal =
          marketplaceClient
              .buyers()
              .finalizedDeals()
              .resume(name, new ResumeFinalizedDealRequest())
              .execute();
    } catch (IOException ex) {
      System.out.printf("Marketplace API returned error response:%n%s", ex);
      System.exit(1);
    }

    System.out.printf(
        "Resumed finalized deal with ID \"%s\" for buyer account ID \"%d\":%n", dealId, accountId);
    Utils.printFinalizedDeal(finalizedDeal);
  }

  public static void main(String[] args) {
    ArgumentParser parser =
        ArgumentParsers.newFor("ResumeFinalizedDeals")
            .build()
            .defaultHelp(true)
            .description(("Resume a finalized deal for the given buyer account ID and deal ID."));
    parser
        .addArgument("-a", "--account_id")
        .help(
            "The resource ID of the buyers resource under which the finalized was created. "
                + "This will be used to construct the parent used as a path parameter for the "
                + "finalizedDeals.resume request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("-d", "--deal_id")
        .help(
            "The resource ID of the buyers.finalizedDeals resource that is being resumed. This "
                + "will be used to construct the name used as a path parameter for the "
                + "finalizedDeals.resume request.")
        .required(true)
        .type(Long.class);

    Namespace parsedArgs = null;
    try {
      parsedArgs = parser.parseArgs(args);
    } catch (ArgumentParserException ex) {
      parser.handleError(ex);
      System.exit(1);
    }

    AuthorizedBuyersMarketplace client = null;
    try {
      client = Utils.getMarketplaceClient();
    } catch (IOException ex) {
      System.out.printf("Unable to create Marketplace API service:%n%s", ex);
      System.out.println("Did you specify a valid path to a service account key file?");
      System.exit(1);
    } catch (GeneralSecurityException ex) {
      System.out.printf("Unable to establish secure HttpTransport:%n%s", ex);
      System.exit(1);
    }

    execute(client, parsedArgs);
  }
}

Python

#!/usr/bin/python
#
# Copyright 2021 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Resumes serving of a given paused finalized deal.

Note that only programmatic guaranteed deals can be resumed by buyers at this
time.
"""


import argparse
import os
import pprint
import sys

sys.path.insert(0, os.path.abspath('../../..'))

from googleapiclient.errors import HttpError

import util


_FINALIZED_DEALS_NAME_TEMPLATE = 'buyers/%s/finalizedDeals/%s'

DEFAULT_BUYER_RESOURCE_ID = 'ENTER_BUYER_RESOURCE_ID_HERE'
DEFAULT_FINALIZED_DEAL_RESOURCE_ID = 'ENTER_DEAL_RESOURCE_ID_HERE'


def main(marketplace, args):
    finalized_deal_name = _FINALIZED_DEALS_NAME_TEMPLATE % (
        args.account_id, args.deal_id)

    print(f'Resuming finalized deal with name "{finalized_deal_name}":')
    try:
        # Construct and execute the request.
        response = marketplace.buyers().finalizedDeals().resume(
            name=finalized_deal_name).execute()
    except HttpError as e:
        print(e)
        sys.exit(1)

    pprint.pprint(response)


if __name__ == '__main__':
    try:
        service = util.get_service(version='v1')
    except IOError as ex:
        print(f'Unable to create marketplace service - {ex}')
        print('Did you specify the key file in util.py?')
        sys.exit(1)

    parser = argparse.ArgumentParser(
        description=('Resume a finalized deal for the given buyer account ID '
                     'and deal ID.'))
    # Required fields.
    parser.add_argument(
        '-a', '--account_id', default=DEFAULT_BUYER_RESOURCE_ID,
        help=('The resource ID of the buyers resource for which the finalized '
              'deal is being resumed. This will be used to construct the name '
              'used as a path parameter for the finalizedDeals.resume request.'
              ))
    parser.add_argument(
        '-d', '--deal_id', default=DEFAULT_FINALIZED_DEAL_RESOURCE_ID,
        help=('The resource ID of the buyers.finalizedDeals resource that is '
              'being resumed. This will be used to construct the name used as '
              'a path parameter for the finalizedDeals.resume request.'))

    main(service, parser.parse_args())