অ্যাক্সেসযোগ্য অ্যাকাউন্টের তালিকা করুন

আপনি CustomerServiceListAccessibleCustomers পদ্ধতির মাধ্যমে আপনার কাছে অ্যাক্সেসযোগ্য গ্রাহকদের তালিকা করতে পারেন। তবে, এই ধরনের অনুরোধে কোন গ্রাহকদের ফেরত দেওয়া হয় তা বোঝা দরকার।

অ্যাক্সেসযোগ্য গ্রাহকদের তালিকাভুক্ত করা হল Search Ads 360 Reporting API-এর কয়েকটি অনুরোধের মধ্যে একটি যার জন্য আপনাকে অনুরোধে একটি গ্রাহক আইডি নির্দিষ্ট করতে হবে না এবং সরবরাহ করা login-customer-id উপেক্ষা করবে।

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

কল্পনা করুন যে আপনি ব্যবহারকারী A যিনি উপরে চিত্রিত দুটি শ্রেণিবিন্যাসের মধ্যে M1 এবং C3 এর একজন প্রশাসক। আপনি যদি Search Ads 360 Reporting API-তে একটি কল করেন, উদাহরণস্বরূপ SearchAds360Service এ, আপনি M1 , C1 , C2 , এবং C3 অ্যাকাউন্টগুলির তথ্য অ্যাক্সেস করতে পারেন৷ যাইহোক, CustomerService.ListAccessibleCustomers এর কাছে একটি কল শুধুমাত্র M1 এবং C3 ফেরত দেবে কারণ তারাই একমাত্র অ্যাকাউন্ট যেখানে ব্যবহারকারী A এর সরাসরি অ্যাক্সেস আছে।

এখানে CustomerService.ListAccessibleCustomers পদ্ধতির ব্যবহার ব্যাখ্যা করে একটি কোড উদাহরণ রয়েছে:

জাভা

// 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 sample;

import com.google.ads.searchads360.v0.lib.SearchAds360Client;
import com.google.ads.searchads360.v0.services.CustomerServiceClient;
import com.google.ads.searchads360.v0.services.ListAccessibleCustomersRequest;
import com.google.ads.searchads360.v0.services.ListAccessibleCustomersResponse;

/** List all customers that can be accessed by the authenticated Google account. */
public class ListAccessibleCustomers {

  public static void main(String[] args) {
    try {
      // Creates a SearchAds360Client with local properties file
      final SearchAds360Client searchAds360Client =
          SearchAds360Client.newBuilder().fromPropertiesFile().build();
      // Creates the Customer Service Client.
      CustomerServiceClient client = searchAds360Client.createCustomerServiceClient();
      new ListAccessibleCustomers().runExample(client);
    } catch (Exception exception) {
      System.err.printf("Failed with exception: %s%n", exception);
      exception.printStackTrace();
      System.exit(1);
    }
  }

  private void runExample(CustomerServiceClient customerServiceClient) {
    ListAccessibleCustomersResponse response =
        customerServiceClient.listAccessibleCustomers(
            ListAccessibleCustomersRequest.getDefaultInstance());

    System.out.printf("Total results: %d%n", response.getResourceNamesCount());

    for (String customerResourceName : response.getResourceNamesList()) {
      System.out.printf("Customer resource name: %s%n", customerResourceName);
    }
  }
}

ListAccessibleCustomers.java ডাউনলোড করুন

পাইথন

#!/usr/bin/env python
# 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.
"""Lists all accessible customers."""

import traceback
from util_searchads360 import SearchAds360Client


def main(client) -> None:
  customer_service = client.get_customer_service()

  # Issues a list accessible customer request.
  accessible_customers = customer_service.list_accessible_customers()
  result_total = len(accessible_customers.resource_names)
  print(f"Total results: {result_total}")

  resource_names = accessible_customers.resource_names
  for resource_name in resource_names:
    print(f'Accessible customer resource name: "{resource_name}"')


if __name__ == "__main__":
  # SearchAds360Client will read the search-ads-360.yaml configuration file in
  # the home directory if none is specified.
  search_ads_360_client = SearchAds360Client.load_from_file()

  try:
    main(search_ads_360_client)
  except Exception:  # pylint: disable=broad-except
    traceback.print_exc()

list_accessible_customers.py ডাউনলোড করুন