ক্লায়েন্ট কার্যকলাপ পরিচালনা করুন

আপনি একজন Client state পরিবর্তন করতে নিম্নলিখিত পদ্ধতিগুলো ব্যবহার করতে পারেন। ক্লায়েন্ট আমন্ত্রণ গ্রহণ করার পর নতুন Client রিসোর্সগুলোর state স্বয়ংক্রিয়ভাবে ACTIVE এ সেট হয়ে যায়।

কোনো নির্দিষ্ট Client state INACTIVE এ সেট করলে, অথরাইজড বায়ার্স মার্কেটপ্লেস UI-তে সেই ক্লায়েন্টের অ্যাক্সেস বাতিল হয়ে যাবে।

নিষ্ক্রিয় করুন

আপনি buyers.clients.deactivate মেথডটি ব্যবহার করে একজন সক্রিয় Client নিষ্ক্রিয় করতে পারেন।

উদাহরণস্বরূপ, কোনো ক্লায়েন্টের অনুমোদিত ক্রেতা মার্কেটপ্লেস UI-তে প্রবেশাধিকার নিষ্ক্রিয় করতে চাইলে আপনি এই পদ্ধতিটি ব্যবহার করতে পারেন।

যখন আপনি কোনো Client নিষ্ক্রিয় করেন, তখন সে ইউজার ইন্টারফেস (UI)-এ প্রবেশাধিকার হারায়। তবে, আপনি নিষ্ক্রিয় ক্লায়েন্টদের পক্ষ থেকে প্রস্তাবনাগুলো দেখতে এবং সেগুলোর বিষয়ে আলোচনা চালিয়ে যেতে পারবেন।

নিম্নলিখিত নমুনাটি দেখায় যে আপনি কীভাবে deactivate পদ্ধতি ব্যবহার করে একজন Client নিষ্ক্রিয় করতে পারেন।

বিশ্রাম

অনুরোধ

POST https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/clients/837492105:deactivate?alt=json
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

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

{
 "name": "buyers/12345678/clients/837492105",
 "role": "CLIENT_DEAL_VIEWER",
 "state": "INACTIVE",
 "displayName": "Demo Viewer 1",
 "sellerVisible": true
}

জাভা

/*
 * Copyright 2021 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.clients;

import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.Client;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.DeactivateClientRequest;
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 deactivate a client for the given buyer account ID and client ID.
 */
public class DeactivateClients {

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

    Client client = null;

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

    System.out.printf(
        "Deactivated Client with ID \"%s\" for buyer account ID '%d':%n", clientId, accountId);
    Utils.printClient(client);
  }

  public static void main(String[] args) {
    ArgumentParser parser =
        ArgumentParsers.newFor("DeactivateClients")
            .build()
            .defaultHelp(true)
            .description(("Deactivate a client for the given buyer account ID and client ID."));
    parser
        .addArgument("-a", "--account_id")
        .help(
            "The resource ID of the buyers resource under which the client was created. This "
                + "will be used to construct the parent used as a path parameter for the "
                + "clients.deactivate request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("-c", "--client_id")
        .help(
            "The resource ID of the buyers.clients resource for which the client was created "
                + "This will be used to construct the name used as a path parameter for the "
                + "clients.deactivate 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.clients.activate মেথডটি ব্যবহার করে একজন নিষ্ক্রিয় Client পুনরায় সক্রিয় করতে পারেন।

উদাহরণস্বরূপ, কোনো ক্লায়েন্টের অনুমোদিত ক্রেতা মার্কেটপ্লেস UI-তে অ্যাক্সেস নিষ্ক্রিয় করার পর তা পুনরুদ্ধার করতে চাইলে আপনি এই পদ্ধতিটি ব্যবহার করতে পারেন।

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

বিশ্রাম

অনুরোধ

POST https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/clients/837492105:activate?alt=json
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

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

{
 "name": "buyers/12345678/clients/837492105",
 "role": "CLIENT_DEAL_VIEWER",
 "state": "ACTIVE",
 "displayName": "Demo Viewer 1",
 "sellerVisible": true
}

জাভা

/*
 * Copyright 2021 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.clients;

import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.ActivateClientRequest;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.Client;
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 activate a client for the given buyer account ID and client ID.
 */
public class ActivateClients {

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

    Client client = null;

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

    System.out.printf(
        "Activated Client with ID \"%s\" for buyer account ID '%d':%n", clientId, accountId);
    Utils.printClient(client);
  }

  public static void main(String[] args) {
    ArgumentParser parser =
        ArgumentParsers.newFor("ActivateClients")
            .build()
            .defaultHelp(true)
            .description(("Activate a client for the given buyer account ID and client ID."));
    parser
        .addArgument("-a", "--account_id")
        .help(
            "The resource ID of the buyers resource under which the client was created. This "
                + "will be used to construct the parent used as a path parameter for the "
                + "clients.activate request.")
        .required(true)
        .type(Long.class);
    parser
        .addArgument("-c", "--client_id")
        .help(
            "The resource ID of the buyers.clients resource for which the client was created "
                + "This will be used to construct the name used as a path parameter for the "
                + "clients.activate 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);
  }
}