নিলাম প্যাকেজ সদস্যতা

একটি AuctionPackage ক্রেতা অ্যাকাউন্ট বা স্বতন্ত্র ক্লায়েন্টকে সাবস্ক্রাইব করার জন্য আপনি নিম্নলিখিত পদ্ধতিগুলো ব্যবহার করতে পারেন।

নিলাম প্যাকেজ থেকে সদস্যতা বাতিল করতে, আনসাবস্ক্রাইব (Unsubscribe) দেখুন।

সাবস্ক্রাইব ক্রেতারা

আপনি buyers.auctionPackages.subscribe মেথডটি ব্যবহার করে কোনো ক্রেতাকে একটি বিদ্যমান AuctionPackage এ সাবস্ক্রাইব করতে পারেন।

একবার সাবস্ক্রাইব করা হলে, অকশন প্যাকেজে থাকা টার্গেটিং বিবরণের উপর ভিত্তি করে নির্দিষ্ট ক্রেতার পক্ষ থেকে আপনার এন্ডপয়েন্টগুলিতে বিডের অনুরোধ পাঠানো হয়। ছয় মাস অতিবাহিত না হলে, আপনাকে স্বয়ংক্রিয়ভাবে অকশন প্যাকেজ থেকে আনসাবস্ক্রাইব করে দেওয়া হয়।
পরিবর্তন করা হয়েছে এবং আপনি এর লক্ষ্যবস্তু ইনভেন্টরির জন্য কোনো বিড করেননি।

নিম্নলিখিত নমুনাটি দেখায় যে আপনি কীভাবে subscribe পদ্ধতি ব্যবহার করে একজন ক্রেতাকে একটি AuctionPackage এ সাবস্ক্রাইব করতে পারেন।

বিশ্রাম

অনুরোধ

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

প্রতিক্রিয়া

{
 "name": "buyers/12345678/auctionPackages/560644393848382202",
 "creator": "buyers/42528410",
 "displayName": "Top 100 Mars Mobile Apps",
 "description": "Mobile Apps, Display format, United Federation of Mars.",
 "createTime": "2042-03-25T05:20:50.136Z",
 "updateTime": "2042-03-25T05:20:50.136Z"
}

জাভা

/*
 * 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.SubscribeAuctionPackageRequest;
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 subscribe a given buyer account to a specified auction package.
 *
 * <p>Once subscribed, the bidder will begin receiving bid requests for the buyer account that
 * include the auction package deal ID and contain inventory matching the auction package's
 * targeting criteria.
 */
public class SubscribeToAuctionPackages {

  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/%d/auctionPackages/%d", accountId, auctionPackageId);

    AuctionPackage auctionPackage = null;

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

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

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

সাবস্ক্রাইব ক্লায়েন্ট

আপনি কোনো ক্রেতার এক বা একাধিক ক্লায়েন্টকে একটি AuctionPackage এ সাবস্ক্রাইব করার জন্য buyers.auctionPackages.subscribeClients মেথডটি ব্যবহার করতে পারেন।

একবার সাবস্ক্রাইব করা হলে, নির্দিষ্ট ক্রেতা ও ক্লায়েন্টদের পক্ষ থেকে অকশন প্যাকেজ টার্গেট করার ভিত্তিতে আপনার এন্ডপয়েন্টগুলোতে বিড রিকোয়েস্ট পাঠানো হয়।

নিম্নলিখিত নমুনাটি দেখায় যে কীভাবে আপনি subscribeClients পদ্ধতি ব্যবহার করে একটি AuctionPackage এ ক্লায়েন্টদের সাবস্ক্রাইব করতে পারেন।

বিশ্রাম

অনুরোধ

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

{
 "clients": [
   "buyers/12345678/clients/873721984",
   "buyers/12345678/clients/136428959"
 ]
}

প্রতিক্রিয়া

{
 "name": "buyers/12345678/auctionPackages/560644393848382202",
 "creator": "buyers/42528410",
 "displayName": "Top 100 Mars Mobile Apps",
 "description": "Mobile Apps, Display format, United Federation of Mars.",
 "createTime": "2042-03-25T05:20:50.136Z",
 "updateTime": "2042-03-25T05:20:50.136Z",
 "subscribedClients": [
   "buyers/12345678/clients/873721984",
   "buyers/12345678/clients/136428959"
 ]
}

জাভা

/*
 * 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.SubscribeClientsRequest;
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 subscribe one or more clients to a specified auction package. */
public class SubscribeClientsToAuctionPackages {

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

    AuctionPackage auctionPackage = null;

    SubscribeClientsRequest subscribeClientsRequest = new SubscribeClientsRequest();
    subscribeClientsRequest.setClients(clientIds);

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

    System.out.printf(
        "Subscribing the following clients for buyer \"%d\" to auction package "
            + "with ID \"%s\":%n",
        accountId, auctionPackageId);
    System.out.println("\t- " + String.join(String.format("%n\t- "), clientIds));
    Utils.printAuctionPackage(auctionPackage);
  }

  public static void main(String[] args) {
    ArgumentParser parser =
        ArgumentParsers.newFor("SubscribeClientsToAuctionPackages")
            .build()
            .defaultHelp(true)
            .description(("Subscribe one or more clients to the specified auction package."));
    parser
        .addArgument("-a", "--account_id")
        .help(
            "The resource ID of the buyers resource under which the clients subscribing to the"
                + " auction package exist. This will be used to construct the name used as a path"
                + " parameter for the auctionPackages.subscribeClients request, and client names"
                + " that will be included in the body of the auctionPackages.subscribeClients"
                + " request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("--auction_package_id")
        .help(
            "The resource ID of the buyers.auctionPackages resource that the buyer is "
                + "subscribing their clients to. This will be used to construct the name used as a "
                + "path parameter for the auctionPackages.subscribeClients request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("--client_ids")
        .help(
            "The resource IDs of one or more buyers.clients resources that the buyer is subscribing"
                + " to an auction package. This will be used to construct client names that will be"
                + " included in the body of the auctionPackages.subscribeClients request. Specify"
                + " each client ID separated by a space.")
        .required(true)
        .type(Long.class)
        .nargs("+");

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