Page Summary
-
Use the
buyers.clients.getmethod to retrieve information about a specific client, including their level of access to the Authorized Buyers Marketplace UI. -
The
buyers.clients.listmethod allows you to view multiple clients, either by paging through all clients or filtering by apartnerClientId.
You can use the following methods to view the existing
clients
under your account.
View individual client
You can use the
buyers.clients.get
method to retrieve a specific Client and view their level of access to the
Authorized Buyers Marketplace UI.
For example, when you negotiate a proposal with a publisher, you
can use get to view information about the Client specified in the proposal.
The following sample demonstrates how you can retrieve an individual Client
with the get method.
REST
Request
GET https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/clients/984287215?alt=json Authorization: Bearer ACCESS_TOKEN Content-Type: application/json
Response
{
"name": "buyers/12345678/clients/984287215",
"role": "CLIENT_DEAL_APPROVER",
"state": "ACTIVE",
"displayName": "Demo Approver 1"
}Java
/* * 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.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 get a single client for the given buyer account ID and client ID. */ public class GetClients { 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().get(name).execute(); } catch (IOException ex) { System.out.printf("Marketplace API returned error response:%n%s", ex); System.exit(1); } System.out.printf( "Found 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("GetClients") .build() .defaultHelp(true) .description(("Get 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.get " + "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.get 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); } }
List multiple clients
You can use the
buyers.clients.list
method to page through all clients, or find a client associated with one of your
customers by using filter with a partnerClientId.
The following sample demonstrates how you can list clients with the list
method.
REST
Request
GET https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/clients?pageSize=3&alt=json Authorization: Bearer ACCESS_TOKEN Content-Type: application/json
Response
{
"clients": [
{
"name": "buyers/12345678/clients/995152331",
"role": "CLIENT_DEAL_NEGOTIATOR",
"state": "ACTIVE",
"displayName": "Demo Negotiator 1",
"partnerClientId": "pcid-5e845421-251a-4a0c-8316-67f9b8140d3a"
},
{
"name": "buyers/12345678/clients/837492105",
"role": "CLIENT_DEAL_VIEWER",
"state": "INACTIVE",
"displayName": "Demo Viewer 1",
"sellerVisible": true
},
{
"name": "buyers/12345678/clients/984287215",
"role": "CLIENT_DEAL_APPROVER",
"state": "ACTIVE",
"displayName": "Demo Approver 1"
}
],
"nextPageToken": "CAMQ26Xgn7nb9gIY26Xgn7nb9gI="
}Java
/* * 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.ListClientsResponse; 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 list Clients for a given buyer account ID. */ public class ListClients { public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) { Long accountId = parsedArgs.getLong("account_id"); Integer pageSize = parsedArgs.getInt("page_size"); String parentBuyerName = String.format("buyers/%d", accountId); String pageToken = null; System.out.printf("Found Clients for buyer Account ID '%d':%n", accountId); do { List<Client> clients = null; try { ListClientsResponse response = marketplaceClient .buyers() .clients() .list(parentBuyerName) .setFilter(parsedArgs.getString("filter")) .setPageSize(pageSize) .setPageToken(pageToken) .execute(); clients = response.getClients(); pageToken = response.getNextPageToken(); } catch (IOException ex) { System.out.printf("Marketplace API returned error response:%n%s", ex); System.exit(1); } if (clients == null) { System.out.println("No clients found."); } else { for (Client client : clients) { Utils.printClient(client); } } } while (pageToken != null); } public static void main(String[] args) { ArgumentParser parser = ArgumentParsers.newFor("ListClients") .build() .defaultHelp(true) .description(("Lists clients associated with the given buyer account.")); parser .addArgument("-a", "--account_id") .help( "The resource ID of the buyers resource under which the clients were created. " + "This will be used to construct the parent used as a path parameter for the " + "clients.list request.") .required(true) .type(Long.class); parser .addArgument("-f", "--filter") .help( "Query string to filter clients. If no filter is specified, all clients will be " + "returned. By default, no filter will be set."); 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); 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); } }