オークション パッケージを表示

購入アカウントまたはそのクライアントのいずれかが登録している既存のオークション パッケージを表示するには、次の方法を使用します。Marketplace API でオークション パッケージを追加または変更することはできません。

個々のオークション パッケージを取得する

buyers.auctionPackages.get メソッドを使用すると、自分または少なくとも 1 つの クライアントが登録している特定の AuctionPackage を取得できます。

購入者アカウントが登録していない AuctionPackage を表示しようとすると、エラーが発生します。

次のサンプルは、get メソッドを使用して個々の AuctionPackage を取得する方法を示しています。

REST

リクエスト

GET https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/auctionPackages/558444393847004125?alt=json
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

レスポンス

{
  "name":"buyers/12345678/auctionPackages/558444393847004125",
  "creator":"buyers/240142376",
  "displayName":"Luxury travel",
  "description":"Web, display. Verticals include: travel & transportation, hotels & accommodation, ecotourism. Ads.txt targeting: direct & reseller. Minimum predicted viewability: 75%",
  "createTime":"2038-06-28T19:12:38.823Z",
  "updateTime":"2042-01-11T18:45:14.106Z",
  "subscribedClients":[
     "buyers/12345678/clients/873721984",
     "buyers/12345678/clients/136428959"
  ]
}

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.auctionPackages;

import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.AuctionPackage;
import com.google.api.services.samples.authorizedbuyers.marketplace.v1.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 get an auction package for the given buyer and auction package ID.
 */
public class GetAuctionPackages {

  public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) {
    Long accountId = parsedArgs.getLong("account_id");
    Long auctionPackageId = parsedArgs.getLong("auction_package_id");
    String name = String.format("buyers/%s/auctionPackages/%d", accountId, auctionPackageId);

    AuctionPackage auctionPackage = null;

    try {
      auctionPackage = marketplaceClient.buyers().auctionPackages().get(name).execute();
    } catch (IOException ex) {
      System.out.printf("Marketplace API returned error response:%n%s", ex);
      System.exit(1);
    }

    System.out.printf(
        "Found auction package with ID \"%s\" for buyer account ID '%d':%n",
        auctionPackageId, accountId);
    Utils.printAuctionPackage(auctionPackage);
  }

  public static void main(String[] args) {
    ArgumentParser parser =
        ArgumentParsers.newFor("GetAuctionPackages")
            .build()
            .defaultHelp(true)
            .description(("Get an auction package for the given buyer and auction package ID."));
    parser
        .addArgument("-a", "--account_id")
        .help(
            "The resource ID of the buyers resource under which the auction package is being "
                + " retrieved. This will be used to construct the name used as a path parameter for"
                + " the auctionPackages.get request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("--auction_package_id")
        .help(
            "The resource ID of the buyers.auctionPackages resource that is being retrieved. "
                + "This will be used to construct the name used as a path parameter for the "
                + "auctionPackages.get 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);
  }
}

複数のオークション パッケージを一覧表示する(購入者レベル)

buyers.auctionPackages.list メソッドを使用すると、購入者とそのクライアントが 登録しているすべてのオークション パッケージをページ分割して表示できます。

次のサンプルは、list メソッドを使用してオークション パッケージを一覧表示する方法を示しています。

REST

リクエスト

GET https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/auctionPackages?pageSize=3&alt=json
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

レスポンス

{
 "auctionPackages": [
   {
     "name": "buyers/12345678/auctionPackages/558444393847004125",
     "creator": "buyers/240142376",
     "displayName": "Luxury travel",
     "description": "Web, display. Verticals include: travel & transportation, hotels & accommodation, ecotourism. Ads.txt targeting: direct & reseller. Minimum predicted viewability: 75%",
     "createTime": "2038-06-28T19:12:38.823Z",
     "updateTime": "2042-01-11T18:45:14.106Z",
     "subscribedClients": [
       "buyers/12345678/clients/873721984",
       "buyers/12345678/clients/136428959"
     ]
   },
   {
     "name": "buyers/12345678/auctionPackages/558444393847627347",
     "creator": "buyers/143579823",
     "displayName": "Mars Top 25 Video",
      "description": "Top 25 Sites in Mars Video",
     "createTime": "2040-11-16T16:45:46.185Z",
     "updateTime": "2041-05-03T13:53:17.151Z",
     "subscribedClients": [
       "buyers/12345678/clients/142940840"
     ]
   },
   {
     "name": "buyers/12345678/auctionPackages/558444393848195715",
     "creator": "buyers/12345678",
     "displayName": "Mars Top 100 Sports",
     "createTime": "2041-11-29T16:07:43.631Z",
     "updateTime": "2041-11-29T16:07:43.631Z"
   }
 ],
 "nextPageToken": "CAMQ5Ja-7a7g9gIY5Ja-7a7g9gI="
}

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.auctionPackages;

import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.AuctionPackage;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.ListAuctionPackagesResponse;
import com.google.api.services.samples.authorizedbuyers.marketplace.v1.Utils;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.List;
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 list auction packages for a given buyer account ID. */
public class ListAuctionPackages {

  public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) {
    Long accountId = parsedArgs.getLong("account_id");
    Integer pageSize = parsedArgs.getInt("page_size");
    String parentBuyerName = String.format("buyers/%s", accountId);
    String pageToken = null;

    System.out.printf("Found auction packages for buyer Account ID '%d':%n", accountId);

    do {
      List<AuctionPackage> auctionPackages = null;

      try {
        ListAuctionPackagesResponse response =
            marketplaceClient
                .buyers()
                .auctionPackages()
                .list(parentBuyerName)
                .setPageSize(pageSize)
                .setPageToken(pageToken)
                .execute();

        auctionPackages = response.getAuctionPackages();
        pageToken = response.getNextPageToken();
      } catch (IOException ex) {
        System.out.printf("Marketplace API returned error response:%n%s", ex);
        System.exit(1);
      }
      if (auctionPackages == null) {
        System.out.println("No auction packages found.");
      } else {
        for (AuctionPackage auctionPackage : auctionPackages) {
          Utils.printAuctionPackage(auctionPackage);
        }
      }
    } while (pageToken != null);
  }

  public static void main(String[] args) {
    ArgumentParser parser =
        ArgumentParsers.newFor("ListAuctionPackages")
            .build()
            .defaultHelp(true)
            .description(("Lists publisher profiles associated with the given buyer account."));
    parser
        .addArgument("-a", "--account_id")
        .help(
            "The resource ID of the buyers resource under which the auction packages resource "
                + "is being accessed. This will be used to construct the parent used as a path "
                + "parameter for the auctionPackages.list request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("-p", "--page_size")
        .help(
            "The number of rows to return per page. The server may return fewer rows than "
                + "specified.")
        .setDefault(Utils.getMaximumPageSize())
        .type(Integer.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);
  }
}

複数のオークション パッケージを一覧表示する(入札者レベル)

bidders.auctionPackages.list メソッドを使用すると、入札者とその購入者、クライアント、 メディア プランナーが登録しているすべてのオークション パッケージをページ分割して表示できます。

次のサンプルは、list メソッドを使用してオークション パッケージを一覧表示する方法を示しています。

REST

リクエスト

GET https://authorizedbuyersmarketplace.googleapis.com/v1/bidders/12345678/auctionPackages?pageSize=3&alt=json
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

レスポンス

{
 "auctionPackages": [
   {
     "name": "buyers/12345678/auctionPackages/558444393847004125",
     "creator": "buyers/240142376",
     "displayName": "Luxury travel",
     "description": "Web, display. Verticals include: travel & transportation, hotels & accommodation, ecotourism. Ads.txt targeting: direct & reseller. Minimum predicted viewability: 75%",
     "createTime": "2038-06-28T19:12:38.823Z",
     "updateTime": "2042-01-11T18:45:14.106Z",
     "subscribedClients": [
       "buyers/12345678/clients/873721984",
       "buyers/12345678/clients/136428959"
     ],
     "subscribedMediaPlanners": [
        {
           "accountId": "11111111"
        }
     ],
     "eligibleSeatIds": [
        "test_seat1",
        "test_seat2",
        "test_seat3"
     ]
   },
   {
     "name": "buyers/12345678/auctionPackages/558444393847627347",
     "creator": "buyers/143579823",
     "displayName": "Mars Top 25 Video",
      "description": "Top 25 Sites in Mars Video",
     "createTime": "2040-11-16T16:45:46.185Z",
     "updateTime": "2041-05-03T13:53:17.151Z",
     "subscribedClients": [
       "buyers/12345678/clients/142940840"
     ]
   },
   {
     "name": "buyers/12345678/auctionPackages/558444393848195715",
     "creator": "buyers/12345678",
     "displayName": "Mars Top 100 Sports",
     "createTime": "2041-11-29T16:07:43.631Z",
     "updateTime": "2041-11-29T16:07:43.631Z"
   }
 ],
 "nextPageToken": "CAMQ5Ja-7a7g9gIY5Ja-7a7g9gI="
}