คุณสามารถใช้วิธีการต่อไปนี้เพื่อดูดีลที่สรุปแล้ว สำหรับบัญชีของคุณ และบัญชีของลูกค้า
ดูดีลแต่ละรายการ
คุณสามารถใช้วิธี
buyers.finalizedDeals.get
เพื่อดึงข้อมูล
FinalizedDeal
ที่เฉพาะเจาะจงซึ่งเชื่อมโยงกับบัญชีของคุณหรือบัญชีของลูกค้า
ตัวอย่างต่อไปนี้แสดงวิธีดึงข้อมูล FinalizedDeal แต่ละรายการด้วยวิธี get
REST
ส่งคำขอ
GET https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/finalizedDeals/1840860?alt=json Authorization: Bearer ACCESS_TOKEN Content-Type: application/json
การตอบกลับ
{
"name": "buyers/12345678/finalizedDeals/1840860",
"deal": {
"name": "buyers/12345678/proposals/MP8642048/deals/1840860",
"createTime": "2031-03-26T05:53:33.053Z",
"updateTime": "2031-03-26T05:54:33.442Z",
"displayName": "test-pg-deal-4",
"buyer": "buyers/12345678",
"publisherProfile": "buyers/12345678/publisherProfiles/PP12345",
"flightStartTime": "2032-03-31T16:00:00Z",
"flightEndTime": "2032-03-31T18:59:00Z",
"targeting": {
"inventorySizeTargeting": {
"targetedInventorySizes": [
{
"width": "200",
"height": "200",
"type": "PIXEL"
},
{
"width": "234",
"height": "60",
"type": "PIXEL"
},
{
"width": "240",
"height": "400",
"type": "PIXEL"
},
{
"width": "300",
"height": "250",
"type": "PIXEL"
},
{
"width": "300",
"height": "600",
"type": "PIXEL"
},
{
"width": "300",
"height": "1050",
"type": "PIXEL"
}
]
}
},
"creativeRequirements": {
"creativePreApprovalPolicy": "SELLER_PRE_APPROVAL_NOT_REQUIRED",
"creativeSafeFrameCompatibility": "COMPATIBLE",
"programmaticCreativeSource": "ADVERTISER",
"creativeFormat": "DISPLAY"
},
"deliveryControl": {
"deliveryRateType": "EVENLY"
},
"billedBuyer": "buyers/12345678",
"dealType": "PROGRAMMATIC_GUARANTEED",
"programmaticGuaranteedTerms": {
"guaranteedLooks": "1",
"fixedPrice": {
"type": "CPM",
"amount": {
"currencyCode": "USD",
"nanos": 10000000
}
},
"reservationType": "STANDARD"
},
"sellerTimeZone": {
"id": "Asia/Shanghai"
}
},
"dealServingStatus": "ENDED",
"dealPausingInfo": {
"pausingConsented": true
},
"rtbMetrics": {},
"readyToServe": false
}Java
/* * 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.finalizedDeals; import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace; import com.google.api.services.authorizedbuyersmarketplace.v1.model.FinalizedDeal; 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 finalized deal for the given buyer and deal IDs. * * <p>Note that deal IDs for finalized deals are identical to those of non-finalized deals–when a * deal becomes finalized, its deal ID will not change. */ public class GetFinalizedDeals { public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) { Long accountId = parsedArgs.getLong("account_id"); Long dealId = parsedArgs.getLong("deal_id"); String name = String.format("buyers/%d/finalizedDeals/%d", accountId, dealId); FinalizedDeal finalizedDeal = null; try { finalizedDeal = marketplaceClient.buyers().finalizedDeals().get(name).execute(); } catch (IOException ex) { System.out.printf("Marketplace API returned error response:%n%s", ex); System.exit(1); } System.out.printf( "Found finalized deal with ID \"%d\" for buyer account ID \"%d\":%n", dealId, accountId); Utils.printFinalizedDeal(finalizedDeal); } public static void main(String[] args) { ArgumentParser parser = ArgumentParsers.newFor("GetFinalizedDeals") .build() .defaultHelp(true) .description(("Get a finalized deal for the given buyer account ID and deal ID.")); parser .addArgument("-a", "--account_id") .help( "The resource ID of the buyers resource under which the finalized deal exists. " + "This will be used to construct the parent used as a path parameter for the " + "finalizedDeals.get request.") .required(true) .type(Long.class); parser .addArgument("-d", "--deal_id") .help( "The resource ID of the buyers.finalizedDeals resource that is being retrieved. " + "This will be used to construct the name used as a path parameter for the " + "finalizedDeals.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); } }
แสดงรายการดีลในฐานะผู้เสนอราคา
คุณสามารถใช้
bidders.finalizedDeals.list
วิธีเพื่อเลื่อนดูดีลที่สรุปแล้วทั้งหมดที่ผู้ซื้อหรือ
ลูกค้าที่เชื่อมโยงกับบัญชีผู้เสนอราคาของคุณเป็นผู้เจรจา
คุณสามารถใช้วิธีนี้เพื่อค้นหาในหลายบัญชีในวงกว้าง
ตัวอย่างต่อไปนี้แสดงวิธีแสดงรายการดีลที่สรุปแล้วด้วยวิธี list
REST
ส่งคำขอ
GET https://authorizedbuyersmarketplace.googleapis.com/v1/bidders/12345678/finalizedDeals?filter=deal.dealType+%3D+PROGRAMMATIC_GUARANTEED&orderBy=deal.flightStartTime+desc&pageSize=3&alt=json Authorization: Bearer ACCESS_TOKEN Content-Type: application/json
การตอบกลับ
{
"finalizedDeals": [
{
"name": "buyers/12345678/finalizedDeals/2809704",
"deal": {
"name": "buyers/12345678/proposals/MP24462282/deals/2809704",
"createTime": "2031-05-10T21:12:10.586Z",
"updateTime": "2031-08-18T16:23:35.087Z",
"displayName": "test-pg-deal-1",
"buyer": "buyers/12345678",
"publisherProfile": "buyers/12345678/publisherProfiles/PP62461",
"flightStartTime": "2031-12-14T16:00:00Z",
"flightEndTime": "2031-03-07T15:59:00Z",
"targeting": {
"inventorySizeTargeting": {
"targetedInventorySizes": [
{
"width": "1",
"height": "1",
"type": "NATIVE"
}
]
}
},
"creativeRequirements": {
"creativePreApprovalPolicy": "SELLER_PRE_APPROVAL_NOT_REQUIRED",
"creativeSafeFrameCompatibility": "COMPATIBLE",
"programmaticCreativeSource": "ADVERTISER",
"creativeFormat": "DISPLAY"
},
"deliveryControl": {
"deliveryRateType": "FRONT_LOADED"
},
"billedBuyer": "buyers/12345678",
"dealType": "PROGRAMMATIC_GUARANTEED",
"programmaticGuaranteedTerms": {
"guaranteedLooks": "1000",
"fixedPrice": {
"type": "CPM",
"amount": {
"currencyCode": "CNY",
"units": "20"
}
},
"reservationType": "STANDARD"
},
"sellerTimeZone": {
"id": "Asia/Shanghai"
}
},
"dealServingStatus": "PAUSED_BY_SELLER",
"dealPausingInfo": {
"pausingConsented": true,
"pauseRole": "SELLER"
},
"rtbMetrics": {}
},
{
"name": "buyers/12345678/finalizedDeals/1537354",
"deal": {
"name": "buyers/39382167/proposals/MP14640061/deals/1537354",
"createTime": "2031-06-11T15:03:25.412Z",
"updateTime": "2031-06-11T15:18:34.209Z",
"displayName": "test-pg-deal-2",
"buyer": "buyers/39382167",
"publisherProfile": "buyers/39382167/publisherProfiles/PP382992",
"flightStartTime": "2032-12-13T16:00:00Z",
"flightEndTime": "2034-03-06T15:59:00Z",
"targeting": {
"inventorySizeTargeting": {
"targetedInventorySizes": [
{
"width": "1",
"height": "1",
"type": "NATIVE"
}
]
}
},
"creativeRequirements": {
"creativePreApprovalPolicy": "SELLER_PRE_APPROVAL_NOT_REQUIRED",
"creativeSafeFrameCompatibility": "COMPATIBLE",
"programmaticCreativeSource": "ADVERTISER",
"creativeFormat": "DISPLAY"
},
"deliveryControl": {
"deliveryRateType": "FRONT_LOADED"
},
"billedBuyer": "buyers/39382167",
"dealType": "PROGRAMMATIC_GUARANTEED",
"programmaticGuaranteedTerms": {
"guaranteedLooks": "1000",
"fixedPrice": {
"type": "CPM",
"amount": {
"currencyCode": "CNY",
"units": "20"
}
},
"reservationType": "STANDARD"
},
"sellerTimeZone": {
"id": "Asia/Shanghai"
}
},
"dealServingStatus": "ACTIVE",
"dealPausingInfo": {
"pausingConsented": true
},
"rtbMetrics": {},
"readyToServe": true
},
{
"name": "buyers/6524914/finalizedDeals/3126325",
"deal": {
"name": "buyers/6524914/proposals/MP17820211/deals/1518325",
"createTime": "2031-05-11T15:16:49.903Z",
"updateTime": "2031-05-11T15:21:34.162Z",
"displayName": "test-pg-deal-3",
"client": "buyers/6524914/clients/19823764",
"publisherProfile": "buyers/6524914/publisherProfiles/2109413",
"flightStartTime": "2032-04-11T16:00:00Z",
"flightEndTime": "2032-10-13T15:59:00Z",
"targeting": {
"inventorySizeTargeting": {
"targetedInventorySizes": [
{
"width": "1",
"height": "1",
"type": "NATIVE"
}
]
}
},
"creativeRequirements": {
"creativePreApprovalPolicy": "SELLER_PRE_APPROVAL_NOT_REQUIRED",
"creativeSafeFrameCompatibility": "COMPATIBLE",
"programmaticCreativeSource": "ADVERTISER",
"creativeFormat": "DISPLAY"
},
"deliveryControl": {
"deliveryRateType": "FRONT_LOADED"
},
"billedBuyer": "buyers/6524914",
"dealType": "PROGRAMMATIC_GUARANTEED",
"programmaticGuaranteedTerms": {
"guaranteedLooks": "1000",
"fixedPrice": {
"type": "CPM",
"amount": {
"currencyCode": "CNY",
"units": "18"
}
},
"reservationType": "STANDARD"
},
"sellerTimeZone": {
"id": "Asia/Shanghai"
}
},
"dealServingStatus": "ACTIVE",
"dealPausingInfo": {},
"rtbMetrics": {},
"readyToServe": true
}
],
"nextPageToken": "CAMQy_DV1qLx9gIYy_DV1qLx9gI="
}Java
/* * 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.bidders.finalizedDeals; import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace; import com.google.api.services.authorizedbuyersmarketplace.v1.model.FinalizedDeal; import com.google.api.services.authorizedbuyersmarketplace.v1.model.ListFinalizedDealsResponse; 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 finalized deals for a given bidder, their buyers, and * clients. */ public class ListFinalizedDeals { public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) { Long accountId = parsedArgs.getLong("account_id"); Integer pageSize = parsedArgs.getInt("page_size"); String parentBidderName = String.format("bidders/%d", accountId); String pageToken = null; System.out.printf("Found finalized deals for bidder account ID '%d':%n", accountId); do { List<FinalizedDeal> finalizedDeals = null; try { ListFinalizedDealsResponse response = marketplaceClient .bidders() .finalizedDeals() .list(parentBidderName) .setFilter(parsedArgs.getString("filter")) .setOrderBy(parsedArgs.getString("order_by")) .setPageSize(pageSize) .setPageToken(pageToken) .execute(); finalizedDeals = response.getFinalizedDeals(); pageToken = response.getNextPageToken(); } catch (IOException ex) { System.out.printf("Marketplace API returned error response:%n%s", ex); System.exit(1); } if (finalizedDeals == null) { System.out.println("No finalized deals found."); } else { for (FinalizedDeal finalizedDeal : finalizedDeals) { Utils.printFinalizedDeal(finalizedDeal); } } } while (pageToken != null); } public static void main(String[] args) { ArgumentParser parser = ArgumentParsers.newFor("ListFinalizedDeals") .build() .defaultHelp(true) .description(("Lists finalized deals associated with the given bidder account.")); parser .addArgument("-a", "--account_id") .help( "The resource ID of the bidders resource under which the finalized deals are being" + " retrieved. This will be used to construct the parent used as a path parameter" + " for the finalizedDeals.list request.") .required(true) .type(Long.class); parser .addArgument("-f", "--filter") .help( "Query string to filter finalized deals. By default, this example will filter by " + "deal type to retrieve programmatic guaranteed deals to demonstrate usage.") .setDefault("deal.dealType = PROGRAMMATIC_GUARANTEED"); parser .addArgument("-o", "--order_by") .help( "Query string used to sort the response of the list method. By default, this " + "example will return deals in descending order of their flight start time to " + "demonstrate usage. To learn more about the syntax for this parameter, see: " + "https://cloud.google.com/apis/design/design_patterns#sorting_order") .setDefault("deal.flightStartTime desc"); 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); } }
แสดงรายการดีลในฐานะผู้ซื้อ
คุณสามารถใช้วิธี
buyers.finalizedDeals.list
เพื่อเลื่อนดูดีลที่สรุปแล้วทั้งหมดที่เชื่อมโยงกับบัญชีของคุณหรือบัญชีของลูกค้า
ตัวอย่างต่อไปนี้แสดงวิธีแสดงรายการดีลที่สรุปแล้วด้วยวิธี list
REST
ส่งคำขอ
GET https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/finalizedDeals?filter=deal.dealType+%3D+PROGRAMMATIC_GUARANTEED&orderBy=deal.flightStartTime+desc&pageSize=3&alt=json Authorization: Bearer ACCESS_TOKEN Content-Type: application/json
การตอบกลับ
{
"finalizedDeals": [
{
"name": "buyers/12345678/finalizedDeals/2809704",
"deal": {
"name": "buyers/12345678/proposals/MP24462282/deals/2809704",
"createTime": "2032-05-10T21:12:10.586Z",
"updateTime": "2032-08-18T16:23:35.087Z",
"displayName": "test-pg-deal-1",
"buyer": "buyers/12345678",
"publisherProfile": "buyers/12345678/publisherProfiles/PP62461",
"flightStartTime": "2032-12-14T16:00:00Z",
"flightEndTime": "2032-03-07T15:59:00Z",
"targeting": {
"inventorySizeTargeting": {
"targetedInventorySizes": [
{
"width": "1",
"height": "1",
"type": "NATIVE"
}
]
}
},
"creativeRequirements": {
"creativePreApprovalPolicy": "SELLER_PRE_APPROVAL_NOT_REQUIRED",
"creativeSafeFrameCompatibility": "COMPATIBLE",
"programmaticCreativeSource": "ADVERTISER",
"creativeFormat": "DISPLAY"
},
"deliveryControl": {
"deliveryRateType": "FRONT_LOADED"
},
"billedBuyer": "buyers/12345678",
"dealType": "PROGRAMMATIC_GUARANTEED",
"programmaticGuaranteedTerms": {
"guaranteedLooks": "1000",
"fixedPrice": {
"type": "CPM",
"amount": {
"currencyCode": "CNY",
"units": "20"
}
},
"reservationType": "STANDARD"
},
"sellerTimeZone": {
"id": "Asia/Shanghai"
}
},
"dealServingStatus": "PAUSED_BY_SELLER",
"dealPausingInfo": {
"pausingConsented": true,
"pauseRole": "SELLER"
},
"rtbMetrics": {}
},
{
"name": "buyers/12345678/finalizedDeals/3853354",
"deal": {
"name": "buyers/12345678/proposals/MP75020085/deals/3853354",
"createTime": "2031-05-08T15:03:25.212Z",
"updateTime": "2031-05-08T15:18:34.329Z",
"displayName": "test-pg-deal-5",
"buyer": "buyers/12345678",
"publisherProfile": "buyers/12345678/publisherProfiles/PP54321",
"flightStartTime": "2032-12-13T16:00:00Z",
"flightEndTime": "2033-03-06T15:59:00Z",
"targeting": {
"inventorySizeTargeting": {
"targetedInventorySizes": [
{
"width": "1",
"height": "1",
"type": "NATIVE"
}
]
}
},
"creativeRequirements": {
"creativePreApprovalPolicy": "SELLER_PRE_APPROVAL_NOT_REQUIRED",
"creativeSafeFrameCompatibility": "COMPATIBLE",
"programmaticCreativeSource": "ADVERTISER",
"creativeFormat": "DISPLAY"
},
"deliveryControl": {
"deliveryRateType": "FRONT_LOADED"
},
"billedBuyer": "buyers/12345678",
"dealType": "PROGRAMMATIC_GUARANTEED",
"programmaticGuaranteedTerms": {
"guaranteedLooks": "1000",
"fixedPrice": {
"type": "CPM",
"amount": {
"currencyCode": "CNY",
"units": "20"
}
},
"reservationType": "STANDARD"
},
"sellerTimeZone": {
"id": "Asia/Shanghai"
}
},
"dealServingStatus": "ACTIVE",
"dealPausingInfo": {
"pausingConsented": true
},
"rtbMetrics": {},
"readyToServe": true
},
{
"name": "buyers/12345678/finalizedDeals/1840860",
"deal": {
"name": "buyers/12345678/proposals/MP8642048/deals/1840860",
"createTime": "2031-03-26T05:53:33.053Z",
"updateTime": "2031-03-26T05:54:33.442Z",
"displayName": "test-pg-deal-4",
"buyer": "buyers/12345678",
"publisherProfile": "buyers/12345678/publisherProfiles/PP12345",
"flightStartTime": "2032-03-31T16:00:00Z",
"flightEndTime": "2032-03-31T18:59:00Z",
"targeting": {
"inventorySizeTargeting": {
"targetedInventorySizes": [
{
"width": "200",
"height": "200",
"type": "PIXEL"
},
{
"width": "234",
"height": "60",
"type": "PIXEL"
},
{
"width": "240",
"height": "400",
"type": "PIXEL"
},
{
"width": "300",
"height": "250",
"type": "PIXEL"
},
{
"width": "300",
"height": "600",
"type": "PIXEL"
},
{
"width": "300",
"height": "1050",
"type": "PIXEL"
}
]
}
},
"creativeRequirements": {
"creativePreApprovalPolicy": "SELLER_PRE_APPROVAL_NOT_REQUIRED",
"creativeSafeFrameCompatibility": "COMPATIBLE",
"programmaticCreativeSource": "ADVERTISER",
"creativeFormat": "DISPLAY"
},
"deliveryControl": {
"deliveryRateType": "EVENLY"
},
"billedBuyer": "buyers/12345678",
"dealType": "PROGRAMMATIC_GUARANTEED",
"programmaticGuaranteedTerms": {
"guaranteedLooks": "1",
"fixedPrice": {
"type": "CPM",
"amount": {
"currencyCode": "USD",
"nanos": 10000000
}
},
"reservationType": "STANDARD"
},
"sellerTimeZone": {
"id": "Asia/Shanghai"
}
},
"dealServingStatus": "ENDED",
"dealPausingInfo": {
"pausingConsented": true
},
"rtbMetrics": {},
"readyToServe": false
}
],
"nextPageToken": "CAMQqbLfqKHx9gIYqbLfqKHx9gI="
}Java
/* * 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.finalizedDeals; import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace; import com.google.api.services.authorizedbuyersmarketplace.v1.model.FinalizedDeal; import com.google.api.services.authorizedbuyersmarketplace.v1.model.ListFinalizedDealsResponse; 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 finalized deals for a given buyer and their clients. */ public class ListFinalizedDeals { 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 finalized deals for buyer account ID '%d':%n", accountId); do { List<FinalizedDeal> finalizedDeals = null; try { ListFinalizedDealsResponse response = marketplaceClient .buyers() .finalizedDeals() .list(parentBuyerName) .setFilter(parsedArgs.getString("filter")) .setOrderBy(parsedArgs.getString("order_by")) .setPageSize(pageSize) .setPageToken(pageToken) .execute(); finalizedDeals = response.getFinalizedDeals(); pageToken = response.getNextPageToken(); } catch (IOException ex) { System.out.printf("Marketplace API returned error response:%n%s", ex); System.exit(1); } if (finalizedDeals == null) { System.out.println("No finalized deals found."); } else { for (FinalizedDeal finalizedDeal : finalizedDeals) { Utils.printFinalizedDeal(finalizedDeal); } } } while (pageToken != null); } public static void main(String[] args) { ArgumentParser parser = ArgumentParsers.newFor("ListFinalizedDeals") .build() .defaultHelp(true) .description(("Lists finalized deals associated with the given buyer account.")); parser .addArgument("-a", "--account_id") .help( "The resource ID of the buyers resource under which the finalized deals are being" + " retrieved. This will be used to construct the parent used as a path parameter" + " for the finalizedDeals.list request.") .required(true) .type(Long.class); parser .addArgument("-f", "--filter") .help( "Query string to filter finalized deals. By default, this example will filter by " + "deal type to retrieve programmatic guaranteed deals to demonstrate usage.") .setDefault("deal.dealType = PROGRAMMATIC_GUARANTEED"); parser .addArgument("-o", "--order_by") .help( "Query string used to sort the response of the list method. By default, this " + "example will return deals in descending order of their flight start time to " + "demonstrate usage. To learn more about the syntax for this parameter, see: " + "https://cloud.google.com/apis/design/design_patterns#sorting_order") .setDefault("deal.flightStartTime desc"); 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); } }