ফিল্টার অ্যাকাউন্ট আপনি অ্যাক্সেস করতে পারেন

accounts.list পদ্ধতি আপনাকে Account সংস্থানগুলির একটি তালিকা পুনরুদ্ধার করতে দেয় যা প্রমাণীকৃত ব্যবহারকারী অ্যাক্সেস করতে পারে। আপনি বিভিন্ন মানদণ্ডের উপর ভিত্তি করে ফলাফল সংকুচিত করতে filter ক্যোয়ারী প্যারামিটার ব্যবহার করতে পারেন, যেমন নিম্নলিখিত:

  • অ্যাকাউন্ট বৈশিষ্ট্য
  • অন্যান্য অ্যাকাউন্টের সাথে সম্পর্ক (যেমন, একটি উন্নত অ্যাকাউন্ট কাঠামোর প্রদানকারী)
  • অ্যাকাউন্টের সাথে সম্পর্কিত পরিষেবা

এটি একাধিক অ্যাকাউন্ট পরিচালনা বা নির্দিষ্ট শর্ত পূরণ করে এমন নির্দিষ্ট ব্যবসায়িক অ্যাকাউন্টগুলি খুঁজে পেতে সহায়ক হতে পারে।

আপনি account স্তরে ফিল্টার করতে নিম্নলিখিত ক্ষেত্রগুলি ব্যবহার করতে পারেন:

  • access : ব্যবহারকারীর account অ্যাক্সেসের ধরন অনুসারে ফিল্টার। এই ফিল্টার নিম্নলিখিত মান গ্রহণ করে:
    • DIRECT : শুধুমাত্র সেই অ্যাকাউন্টগুলি ফেরত দেয় যেখানে ব্যবহারকারীর সরাসরি অ্যাক্সেস আছে।
    • INDIRECT : ব্যবহারকারীর পরোক্ষ অ্যাক্সেস আছে শুধুমাত্র অ্যাকাউন্ট ফেরত.
    • ALL : ব্যবহারকারীর অ্যাক্সেস আছে এমন সমস্ত অ্যাকাউন্ট ফেরত দেয় (প্রত্যক্ষ এবং পরোক্ষ উভয়ই)। ফিল্টার নির্দিষ্ট করা না থাকলে এটি ডিফল্ট আচরণ।
  • capabilities : account সম্পদের capabilities দ্বারা ফিল্টার (উল্লেখ্য যে এই ক্ষেত্রটি সম্পদে উপলব্ধ নয়)। শুধুমাত্র CAN_UPLOAD_PRODUCTS ক্ষমতা সমর্থিত। এই ক্ষেত্রটি অস্বীকার সমর্থন করে এবং সংগ্রহের বাক্য গঠন ব্যবহার করে।
  • relationship(...) : অন্য অ্যাকাউন্টের সাথে অ্যাকাউন্টের সম্পর্কের ধরন দ্বারা ফিল্টার। আপনি একটি অনুরোধে একাধিক relationship(...) ফিল্টার অন্তর্ভুক্ত করতে পারেন।
  • accountName : account রিসোর্সের accountName দ্বারা ফিল্টার।

ফিল্টার সিনট্যাক্স সম্পর্কে আরও বিস্তারিত তথ্যের জন্য, ফিল্টার সিনট্যাক্স গাইড দেখুন।

উদাহরণ

নিম্নলিখিত উদাহরণগুলি ব্যাখ্যা করে যে কীভাবে সবচেয়ে সাধারণ প্রশ্নগুলি তৈরি করা যায়। নিম্নলিখিত সমস্ত উদাহরণ accounts.list পদ্ধতি ব্যবহার করে। আরও তথ্যের জন্য, accounts.list রেফারেন্স ডকুমেন্টেশন দেখুন।

একটি নির্দিষ্ট প্রদানকারীর সাব-অ্যাকাউন্ট খুঁজুন

accounts.listSubaccounts পদ্ধতি সাব-অ্যাকাউন্ট তালিকা করার একটি সরাসরি উপায় প্রদান করে। আপনি নিম্নলিখিত বিভাগে বর্ণিত ফিল্টারিং ক্ষমতাগুলিও ব্যবহার করতে পারেন। আপনি যদি একটি উন্নত অ্যাকাউন্ট পরিচালনা করেন, আপনি providerId আইডিতে ফিল্টার করে এর সমস্ত উপ-অ্যাকাউন্ট তালিকাভুক্ত করতে পারেন। আপনার উন্নত অ্যাকাউন্টের ID দিয়ে PROVIDER_ID প্রতিস্থাপন করুন।

উদাহরণস্বরূপ, প্রদানকারীর আইডি 123 হলে relationship(providerId=123) ব্যবহার করুন।

এটি আপনার অ্যাকাউন্টের কাঠামো পরিচালনার জন্য দরকারী।

GET https://merchantapi.googleapis.com/accounts/v1/accounts?filter=relationship(providerId%20%3D%20PROVIDER_ID)

একটি সফল অনুরোধ একটি 200 স্ট্যাটাস কোড এবং মিলিত সাব-অ্যাকাউন্টের তালিকা সহ একটি প্রতিক্রিয়া বডি প্রদান করে:

{
  "accounts": [
    {
      "name": "accounts/77777",
      "accountId": "77777",
      "accountName": "SubAccount A of Provider",
      "adultContent": false,
      "languageCode": "fr",
      "timeZone": {
        "id": "Europe/Paris"
      }
    },
    {
      "name": "accounts/88888",
      "accountId": "88888",
      "accountName": "SubAccount B of Provider",
      "adultContent": false,
      "languageCode": "de",
      "timeZone": {
        "id": "Europe/Berlin"
      }
    }
  ],
  "nextPageToken": "XYZ123abcDEF..."
}

পণ্য আপলোড করতে পারে না যে অ্যাকাউন্ট খুঁজুন

আপনি আরও নির্দিষ্ট অনুসন্ধান তৈরি করতে একাধিক ফিল্টার শর্ত একত্রিত করতে পারেন।

ফিল্টার accountName=*store* AND -capabilities:CAN_UPLOAD_PRODUCTS তাদের নামে "স্টোর" সহ সমস্ত অ্যাকাউন্ট খুঁজে পায় যেগুলি সরাসরি পণ্য আপলোড করার জন্য কনফিগার করা হয়নি৷ The - before capabilities একটি negation operator হিসেবে কাজ করে। এটি শুধুমাত্র উন্নত অ্যাকাউন্ট পুনরুদ্ধার করতে উপযোগী হতে পারে।

GET https://merchantapi.googleapis.com/accounts/v1/accounts?filter=accountName%20%3D%20%22*store*%22%20AND%20-capabilities%3ACAN_UPLOAD_PRODUCTS

একটি সফল অনুরোধ একটি 200 স্ট্যাটাস কোড এবং মিলে যাওয়া অ্যাকাউন্টগুলির তালিকা সহ একটি প্রতিক্রিয়া বডি প্রদান করে:

{
  "accounts": [
    {
      "name": "accounts/54321",
      "accountId": "54321",
      "accountName": "Partner Store - US",
      "adultContent": false,
      "languageCode": "en",
      "timeZone": {
        "id": "America/New_York"
      }
    },
    {
      "name": "accounts/98765",
      "accountId": "98765",
      "accountName": "Auxiliary Brand Store",
      "adultContent": false,
      "languageCode": "fr",
      "timeZone": {
        "id": "Europe/Paris"
      }
    }
  ],
  "nextPageToken": "CDEfghIJKlmnOPQ..."
}

নাম দ্বারা অ্যাকাউন্ট খুঁজুন

আপনি এমন অ্যাকাউন্টগুলি অনুসন্ধান করতে পারেন যার প্রদর্শনের নাম একটি নির্দিষ্ট প্যাটার্নের সাথে মেলে৷

উদাহরণস্বরূপ, accountName=*store* তাদের নামে "store" সহ সমস্ত অ্যাকাউন্ট খুঁজে পাবে।

এটি দ্রুত নির্দিষ্ট ব্যবসায়িক অ্যাকাউন্টগুলি সনাক্ত করতে সহায়তা করে৷

GET https://merchantapi.googleapis.com/accounts/v1/accounts?filter=accountName%20%3D%20%22*store*%22

একটি সফল অনুরোধ একটি 200 স্ট্যাটাস কোড এবং মিলে যাওয়া অ্যাকাউন্টগুলির তালিকা সহ একটি প্রতিক্রিয়া বডি প্রদান করে:

{
  "accounts": [
    {
      "name": "accounts/12345",
      "accountId": "12345",
      "accountName": "My Awesome Store",
      "adultContent": false,
      "languageCode": "en",
      "timeZone": {
        "id": "America/Los_Angeles"
      }
    },
    {
      "name": "accounts/67890",
      "accountId": "67890",
      "accountName": "Another Store Online",
      "adultContent": false,
      "languageCode": "en",
      "timeZone": {
        "id": "Europe/London"
      }
    }
  ],
  "nextPageToken": "ABSdefGHIjklMNO..."
}

একটি নির্দিষ্ট পরিষেবার জন্য একটি প্রদানকারীর সাথে লিঙ্ক করা অ্যাকাউন্ট খুঁজুন

আপনি একটি প্রদানকারীর সাথে একটি নির্দিষ্ট পরিষেবার সম্পর্ক আছে এমন অ্যাকাউন্টগুলি খুঁজে পেতে পারেন৷ উদাহরণস্বরূপ, অ্যাকাউন্ট একত্রিত করার জন্য প্রদানকারীর PROVIDER_ID অধীনে একত্রিত সমস্ত অ্যাকাউন্ট খুঁজে পেতে, ফিল্টার relationship(providerId= PROVIDER_ID ) AND service(type="ACCOUNT_AGGREGATION") ব্যবহার করুন।

GET https://merchantapi.googleapis.com/accounts/v1/accounts?filter=relationship(providerId%20%3D%20PROVIDER_ID%20AND%20service(type%20%3D%20%22ACCOUNT_AGGREGATION%22))

একটি সফল অনুরোধ একটি 200 স্ট্যাটাস কোড এবং মিলে যাওয়া অ্যাকাউন্টগুলির তালিকা সহ একটি প্রতিক্রিয়া বডি প্রদান করে:

{
  "accounts": [
    {
      "name": "accounts/54321",
      "accountId": "54321",
      "accountName": "Aggregated Account X",
      "adultContent": false,
      "languageCode": "en",
      "timeZone": {
        "id": "America/New_York"
      }
    }
  ]
}

পরিষেবা সম্পর্ক অনুমোদন অবস্থার উপর ভিত্তি করে অ্যাকাউন্ট খুঁজুন

আপনি একটি প্রদানকারীর সাথে তাদের পরিষেবা সম্পর্কের অবস্থার উপর ভিত্তি করে অ্যাকাউন্টগুলি ফিল্টার করতে পারেন৷ উদাহরণস্বরূপ, একটি নির্দিষ্ট প্রদানকারী PROVIDER_ID থেকে একটি অ্যাকাউন্ট লিঙ্ক অনুরোধ (handshakeState = "PENDING") গ্রহণ করেনি এমন সমস্ত অ্যাকাউন্টগুলি খুঁজে পেতে।

উদাহরণস্বরূপ, এমন অ্যাকাউন্টগুলি খুঁজে বের করতে যেখানে প্রদানকারীর আইডি 123 , পরিষেবার ধরন হল ACCOUNT_MANAGEMENT এবং স্থিতি PENDING , relationship(service(handshakeState = "PENDING" AND type = "ACCOUNT_MANAGEMENT") AND providerId = 123)

GET https://merchantapi.googleapis.com/accounts/v1/accounts?filter=relationship(service(handshakeState%20%3D%20%22PENDING%22%20AND%20type%20%3D%20%22ACCOUNT_MANAGEMENT%22)%20AND%20providerId%20%3D%20PROVIDER_ID)

একটি সফল অনুরোধ একটি 200 স্ট্যাটাস কোড এবং মিলে যাওয়া অ্যাকাউন্টগুলির তালিকা সহ একটি প্রতিক্রিয়া বডি প্রদান করে:

{
  "accounts": [
    {
      "name": "accounts/98765",
      "accountId": "98765",
      "accountName": "Managed Account Y",
      "adultContent": false,
      "languageCode": "es",
      "timeZone": {
        "id": "Europe/Madrid"
      }
    }
  ]
}

ক্লায়েন্ট লাইব্রেরি ব্যবহার করে অ্যাকাউন্ট ফিল্টার করুন

নিম্নলিখিত উদাহরণগুলি দেখায় কিভাবে ক্লায়েন্ট লাইব্রেরি ব্যবহার করে অ্যাকাউন্ট ফিল্টার করতে সম্মিলিত মানদণ্ডের উপর ভিত্তি করে, যেমন অ্যাকাউন্টের নাম এবং একটি প্রদানকারীর সাথে সম্পর্ক। এই উদাহরণগুলি accounts.list পদ্ধতি ব্যবহার করে। আরও তথ্যের জন্য, accounts.list রেফারেন্স ডকুমেন্টেশন দেখুন।

জাভা

import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.Account;
import com.google.shopping.merchant.accounts.v1.AccountsServiceClient;
import com.google.shopping.merchant.accounts.v1.AccountsServiceClient.ListAccountsPagedResponse;
import com.google.shopping.merchant.accounts.v1.AccountsServiceSettings;
import com.google.shopping.merchant.accounts.v1.ListAccountsRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/** This class demonstrates how to filter the accounts the user making the request has access to. */
public class FilterAccountsSample {

  public static void filterAccounts(Config config) throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the credentials retrieved above.
    AccountsServiceSettings accountsServiceSettings =
        AccountsServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Calls the API and catches and prints any network failures/errors.
    try (AccountsServiceClient accountsServiceClient =
        AccountsServiceClient.create(accountsServiceSettings)) {

      // Filter for accounts with display names containing "store" and a provider with the ID "123":
      String filter = "accountName = \"*store*\" AND relationship(providerId = 123)";

      // Filter for all subaccounts of account "123":
      // String filter2 = "relationship(providerId = 123 AND service(type =
      // \"ACCOUNT_AGGREGATION\"))";

      // String filter3 = "relationship(service(handshakeState = \"APPROVED\" AND type =
      // \"ACCOUNT_MANAGEMENT\") AND providerId = 123)";

      ListAccountsRequest request = ListAccountsRequest.newBuilder().setFilter(filter).build();

      System.out.println("Sending list accounts request with filter:");
      ListAccountsPagedResponse response = accountsServiceClient.listAccounts(request);

      int count = 0;

      // Iterates over all rows in all pages and prints the sub-account
      // in each row.
      // `response.iterateAll()` automatically uses the `nextPageToken` and recalls the
      // request to fetch all pages of data.
      for (Account account : response.iterateAll()) {
        System.out.println(account);
        count++;
      }
      System.out.print("The following count of elements were returned: ");
      System.out.println(count);
    } catch (Exception e) {
      System.out.println(e);
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();

    filterAccounts(config);
  }
}

পিএইচপি

use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\AccountsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\ListAccountsRequest;

/**
 * This class demonstrates how to filter the accounts the user making the request has access to.
 */
class FilterAccounts
{
    public static function filterAccounts(array $config): void
    {

        // Gets the OAuth credentials to make the request.
        $credentials = Authentication::useServiceAccountOrTokenFile();

        // Creates options config containing credentials for the client to use.
        $options = ['credentials' => $credentials];

        // Creates a client.
        $accountsServiceClient = new AccountsServiceClient($options);

        // Calls the API and catches and prints any network failures/errors.
        try {

            // Filter for accounts with display names containing "store" and a provider with the ID "123":
            $filter = "accountName = \"*store*\" AND relationship(providerId = 123)";

            // Filter for all subaccounts of account "123":
            // $filter = "relationship(providerId = 123 AND service(type = \"ACCOUNT_AGGREGATION\"))";

            // $filter = "relationship(service(handshakeState = \"APPROVED\" AND type =
            // \"ACCOUNT_MANAGEMENT\") AND providerId = 123)";

            $request = new ListAccountsRequest(['filter' => $filter]);

            print "Sending list accounts request with filter:\n";
            $response = $accountsServiceClient->listAccounts($request);

            $count = 0;

            // Iterates over all rows in all pages and prints the sub-account
            // in each row.
            // `response.iterateAll()` automatically uses the `nextPageToken` and recalls the
            // request to fetch all pages of data.
            foreach ($response->iterateAllElements() as $account) {
                print_r($account); 
                $count++;
            }
            print "The following count of elements were returned: ";
            print $count . PHP_EOL;
        } catch (ApiException $e) {
            print $e->getMessage();
        }
    }

    public function callSample(): void
    {
        $config = Config::generateConfig();
        self::filterAccounts($config);
    }
}

$sample = new FilterAccounts();
$sample->callSample();

পাইথন

from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import AccountsServiceClient
from google.shopping.merchant_accounts_v1 import ListAccountsRequest


def filter_accounts():
  """Filters the accounts the user making the request has access to."""

  # Get OAuth credentials.
  credentials = generate_user_credentials.main()

  # Create a client.
  client = AccountsServiceClient(credentials=credentials)

  # Create the filter string.
  filter_string = 'accountName = "*store*" AND relationship(providerId = 123)'

  # Create the request.
  request = ListAccountsRequest(filter=filter_string)

  # Make the request and print the response.
  try:
    print("Sending list accounts request with filter:")
    response = client.list_accounts(request=request)

    count = 0
    for account in response:
      print(account)
      count += 1

    print(f"The following count of elements were returned: {count}")

  except RuntimeError as e:
    print(e)


if __name__ == "__main__":
  filter_accounts()

অ্যাপসস্ক্রিপ্ট


/**
 * Filters and lists accounts for which the logged-in user has access to
 */
function filterAccounts() {
  // IMPORTANT:
  // Enable the Merchant API Accounts sub-API Advanced Service and call it
  // "MerchantApiAccounts"

  // Create the filter string.
  // Documentation can be found at
  // https://developers.google.com/merchant/api/guides/accounts/filter-syntax
  const filter = 'accountName = "*store*" AND relationship(providerId = 123)';
  try {
    console.log('Sending filter Accounts request');
    let pageToken;
    let pageSize = 500;
    // Call the Accounts.list API method with a filter. Use the pageToken to iterate through
    // all pages of results.
    do {
      response =
          MerchantApiAccounts.Accounts.list({pageSize, pageToken, filter});
      for (const account of response.accounts) {
        console.log(account);
      }
      pageToken = response.nextPageToken;
    } while (pageToken);  // Exits when there is no next page token.

  } catch (e) {
    console.log('ERROR!');
    console.log(e);
  }
}

cURL

curl --location 'https://merchantapi.googleapis.com/accounts/v1/accounts?filter=accountName%20%3D%20%22*store*%22%20AND%20relationship(providerId%20%3D%20PROVIDER_ID)' \
--header 'Authorization: Bearer <API_TOKEN>'