Melihat paket pilihan

Panduan ini menjelaskan metode yang dapat Anda gunakan untuk melihat paket pilihan Anda.

Melihat paket pilihan satu per satu

Untuk melihat salah satu paket pilihan Anda, gunakan curators.curatedPackages.get metode.

Contoh berikut membuat permintaan GET ke endpoint API, yang merespons dengan paket pilihan yang ditentukan.

REST

Permintaan

GET https://authorizedbuyersmarketplace.googleapis.com/v1beta/curators/[YOUR_ACCOUNT_ID]/curatedPackages/123456789?alt=json
Authorization: Bearer ACCESS_TOKEN

Respons

{
 "name": "curators/[YOUR_ACCOUNT_ID]/curatedPackages/123456789",
 "displayName": "Premium Mobile Web Package",
 "description": "High-performing mobile web inventory for premium brands.",
 "createTime": "2026-06-01T16:00:00Z",
 "updateTime": "2026-06-01T16:20:00Z",
 "floorPriceCpm": {
   "currencyCode": "USD",
   "units": "2",
   "nanos": 500000000
 },
 "feeCpm": {
   "currencyCode": "USD",
   "units": "0",
   "nanos": 150000000
 },
 "state": "ACTIVE",
 "accessSettings": {
   "allowlistedMediaPlanners": [
     "mediaPlanners/987654321"
   ]
 },
 "targeting": {
   "includedDeviceTypes": [
     "DEVICE_TYPE_PHONE",
     "DEVICE_TYPE_TABLET"
   ],
   "includedEnvironment": "ENVIRONMENT_SITE"
 }
}

Java

/*
 * Copyright (c) 2026 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.
 */

package com.google.api.services.samples.authorizedbuyers.marketplace.v1beta.curators.curatedPackages;

import com.google.api.services.authorizedbuyersmarketplace.v1beta.AuthorizedBuyersMarketplace;
import com.google.api.services.authorizedbuyersmarketplace.v1beta.model.CuratedPackage;
import com.google.api.services.samples.authorizedbuyers.marketplace.v1beta.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;

public class GetCuratedPackage {

  /**
   * Executes the get operation for a curated package.
   *
   * @param marketplaceClient the initialized Marketplace API client.
   * @param accountId the resource ID of the curator account.
   * @param curatedPackageId the resource ID of the curated package.
   * @throws IOException if the API returns an error.
   */
  public static void execute(
      AuthorizedBuyersMarketplace marketplaceClient, Long accountId, String curatedPackageId)
      throws IOException {
    String name = String.format("curators/%s/curatedPackages/%s", accountId, curatedPackageId);

    System.out.printf("Get curated package with name \"%s\".%n", name);

    // Get the specified curated package.
    CuratedPackage curatedPackage =
        marketplaceClient.curators().curatedPackages().get(name).execute();

    System.out.println("Successfully retrieved curated package:");
    Utils.jsonPrettyPrint(curatedPackage);
  }

  /**
   * Creates and configures the ArgumentParser for this sample.
   *
   * @return the configured ArgumentParser.
   */
  private static ArgumentParser createArgumentParser() {
    ArgumentParser parser =
        ArgumentParsers.newFor("GetCuratedPackage")
            .build()
            .defaultHelp(true)
            .description("Gets a specified curated package.");

    // Required arguments.
    parser
        .addArgument("-a", "--account_id")
        .help("The account ID of the curator that created the curated package.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("-c", "--curated_package_id")
        .help("The resource ID of the curated package to retrieve.")
        .required(true);

    return parser;
  }

  public static void main(String[] args) {
    ArgumentParser parser = createArgumentParser();

    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);
    }

    try {
      execute(
          client,
          parsedArgs.getLong("account_id"),
          parsedArgs.getString("curated_package_id"));
    } catch (IOException ex) {
      System.out.printf("Marketplace API returned error response:%n%s", ex);
      System.exit(1);
    }
  }
}

Melihat daftar semua paket pilihan Anda

Untuk melihat semua paket pilihan Anda, gunakan metode curators.curatedPackages.list.

Contoh berikut membuat permintaan GET ke endpoint API yang merespons dengan daftar paket pilihan untuk akun kurator yang ditentukan. Contoh ini menentukan parameter kueri filter dan menampilkan paket pilihan dengan kolom state yang ditetapkan ke ACTIVE.

REST

Permintaan

GET https://authorizedbuyersmarketplace.googleapis.com/v1beta/curators/[YOUR_ACCOUNT_ID]/curatedPackages?pageSize=2&filter=state%3DACTIVE&alt=json
Authorization: Bearer ACCESS_TOKEN

Respons

{
 "curatedPackages": [
   {
     "name": "curators/[YOUR_ACCOUNT_ID]/curatedPackages/123456789",
     "displayName": "Premium Mobile Web Package",
     "description": "High-performing mobile web inventory for premium brands.",
     "createTime": "2026-06-01T16:00:00Z",
     "updateTime": "2026-06-01T16:20:00Z",
     "floorPriceCpm": {
       "currencyCode": "USD",
       "units": "2",
       "nanos": 500000000
     },
     "feeCpm": {
       "currencyCode": "USD",
       "units": "0",
       "nanos": 150000000
     },
     "state": "ACTIVE",
     "accessSettings": {
       "allowlistedMediaPlanners": [
         "mediaPlanners/987654321"
       ]
     },
     "targeting": {
       "includedDeviceTypes": [
         "DEVICE_TYPE_PHONE",
         "DEVICE_TYPE_TABLET"
       ],
       "includedEnvironment": "ENVIRONMENT_SITE"
     }
   },
   {
     "name": "curators/[YOUR_ACCOUNT_ID]/curatedPackages/987654321",
     "displayName": "Premium Connected TV Package",
     "description": "Premium connected TV inventory.",
     "createTime": "2026-06-01T15:00:00Z",
     "updateTime": "2026-06-01T15:00:00Z",
     "floorPriceCpm": {
       "currencyCode": "USD",
       "units": "5",
       "nanos": 0
     },
     "feeCpm": {
       "currencyCode": "USD",
       "units": "0",
       "nanos": 500000000
     },
     "state": "ACTIVE",
     "accessSettings": {
       "allowlistedMediaPlanners": [
         "mediaPlanners/987654321"
       ]
     },
     "targeting": {
       "includedDeviceTypes": [
         "DEVICE_TYPE_CONNECTED_TV"
       ]
     }
   }
 ],
 "nextPageToken": "CAMQ5Ja-7a7g9gIY5Ja-7a7g9gI="
}

Java

/*
 * Copyright (c) 2026 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.
 */

package com.google.api.services.samples.authorizedbuyers.marketplace.v1beta.curators.curatedPackages;

import com.google.api.services.authorizedbuyersmarketplace.v1beta.AuthorizedBuyersMarketplace;
import com.google.api.services.authorizedbuyersmarketplace.v1beta.model.ListCuratedPackagesResponse;
import com.google.api.services.samples.authorizedbuyers.marketplace.v1beta.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;

public class ListCuratedPackages {

  /**
   * Executes the list operation for curated packages.
   *
   * @param marketplaceClient the initialized Marketplace API client.
   * @param accountId the resource ID of the curator account.
   * @param pageSize the number of rows to return per page.
   * @param filter an optional parameter to filter the returned curated packages.
   * @throws IOException if the API returns an error.
   */
  public static void execute(
      AuthorizedBuyersMarketplace marketplaceClient,
      Long accountId,
      Integer pageSize,
      String filter)
      throws IOException {
    String parentBuyerName = String.format("curators/%s", accountId);
    String pageToken = null;

    if (filter == null) {
      System.out.printf("Listing curated packages for curator Account ID \"%d\":%n", accountId);
    } else {
      System.out.printf(
          "Listing curated packages for curator Account ID \"%d\" with filter \"%s\":%n",
          accountId,
          filter);
    }

    // Iterate through and print pages from the curatedPackages.list response.
    do {
      ListCuratedPackagesResponse response =
          marketplaceClient
              .curators()
              .curatedPackages()
              .list(parentBuyerName)
              .setFilter(filter)
              .setPageSize(pageSize)
              .setPageToken(pageToken)
              .execute();

      pageToken = response.getNextPageToken();
      Utils.jsonPrettyPrint(response);
    } while (pageToken != null);
  }

  /**
   * Creates and configures the ArgumentParser for this sample.
   *
   * @return the configured ArgumentParser.
   */
  private static ArgumentParser createArgumentParser() {
    ArgumentParser parser =
        ArgumentParsers.newFor("ListCuratedPackages")
            .build()
            .defaultHelp(true)
            .description(("Lists curated packages for the given curator account."));

    // Required arguments.
    parser
        .addArgument("-a", "--account_id")
        .help("The account ID of the curator that created the curated package.")
        .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);

    // Optional arguments.
    parser
        .addArgument("-f", "--filter")
        .help("An optional parameter used the filter the curated packages returned. Uses " +
            "Cloud API list filtering syntax. To learn more, see:" +
            "https://developers.google.com/authorized-buyers/apis/guides/get-started/list-filters");

    return parser;
  }

  public static void main(String[] args) {
    ArgumentParser parser = createArgumentParser();

    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);
    }

    try {
      execute(
          client,
          parsedArgs.getLong("account_id"),
          parsedArgs.getInt("page_size"),
          parsedArgs.getString("filter"));
    } catch (IOException ex) {
      System.out.printf("Marketplace API returned error response:%n%s", ex);
      System.exit(1);
    }
  }
}

Langkah berikutnya

Untuk mempelajari lebih lanjut alur kerja lain yang dapat Anda lakukan dengan resource curatedPackages, tinjau konten berikut: