您可以使用以下方法来修改买家账号和任何客户的现有提案。
修补
您可以使用 buyers.proposals.patch 方法更新指定提案。
您可以使用此方法在协商期间更改提案,或开始重新协商已敲定的提案。
您无法使用 patch 更改提案的状态。
如需了解修改提案的更多方法,请参阅以下内容:
以下示例演示了如何使用 patch 方法更新提案。
REST
请求
PATCH https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/proposals/MP49876074?updateMask=buyerPrivateData.referenceId&alt=json
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json
{
"proposalRevision": "1",
"buyerPrivateData": {
"referenceId": "2f5e9550-8d22-495e-ba38-9b9496347a3b"
}
}响应
{
"name": "buyers/12345678/proposals/MP49876074",
"updateTime": "2022-03-26T04:03:19.282Z",
"proposalRevision": "2",
"dealType": "PROGRAMMATIC_GUARANTEED",
"displayName": "Test PG Proposal #0ce643e9-5518-4e8e-b352-0cb45cc2eeb2",
"state": "SELLER_REVIEW_REQUESTED",
"originatorRole": "BUYER",
"publisherProfile": "buyers/12345678/publisherProfiles/PP111111",
"buyer": "buyers/12345678",
"buyerPrivateData": {
"referenceId": "2f5e9550-8d22-495e-ba38-9b9496347a3b"
},
"billedBuyer": "buyers/12345678",
"sellerContacts": [
{
"email": "jeff@hypersonicmedia.com"
},
{
"email": "alex@hypersonicmedia.com"
},
],
"buyerContacts": [
{
"email": "testemail89319783@test.com",
"displayName": "Joe"
}
],
"lastUpdaterOrCommentorRole": "BUYER",
"notes": [
{
"createTime": "2022-03-26T04:03:19.548Z",
"creatorRole": "BUYER",
"note": "Test programmatic guaranteed deal proposal."
}
]
}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.proposals; import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace; import com.google.api.services.authorizedbuyersmarketplace.v1.model.PrivateData; import com.google.api.services.authorizedbuyersmarketplace.v1.model.Proposal; import com.google.api.services.samples.authorizedbuyers.marketplace.v1.Utils; import java.io.IOException; import java.security.GeneralSecurityException; import java.util.UUID; import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; /** * Patches a specified proposal at the given revision number. * * <p>Fields that can be patched for this resource can be found in the reference documentation: * https://developers.google.com/authorized-buyers/apis/marketplace/reference/rest/v1/buyers.proposals * * <p>Note: If the revision number is lower than what is stored for the proposal server-side, the * operation will be deemed obsolete and an error will be returned. * * <p>Only proposals for preferred and programmatic guaranteed deals can be modified by buyers. */ public class PatchProposals { public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) { Long accountId = parsedArgs.getLong("account_id"); String proposalId = parsedArgs.getString(("proposal_id")); String name = String.format("buyers/%d/proposals/%s", accountId, proposalId); Long proposalRevision = parsedArgs.getLong("proposal_revision"); PrivateData buyerPrivateData = new PrivateData(); buyerPrivateData.setReferenceId( String.format("Marketplace-Java-Sample-Reference-%s", UUID.randomUUID())); Proposal patchedProposal = new Proposal(); patchedProposal.setProposalRevision(proposalRevision); patchedProposal.setBuyerPrivateData(buyerPrivateData); String updateMask = "buyerPrivateData.referenceId"; Proposal proposal = null; try { proposal = marketplaceClient .buyers() .proposals() .patch(name, patchedProposal) .setUpdateMask(updateMask) .execute(); } catch (IOException ex) { System.out.printf("Marketplace API returned error response:%n%s", ex); System.exit(1); } System.out.printf("Patching proposal with name \"%s\":%n", name); Utils.printProposal(proposal); } public static void main(String[] args) { ArgumentParser parser = ArgumentParsers.newFor("PatchProposals") .build() .defaultHelp(true) .description(("Patches a proposal at the given revision number.")); parser .addArgument("-a", "--account_id") .help( "The resource ID of the buyers resource for which the RFP is being patched. This " + "will be used to construct the name used as a path parameter for the " + "proposals.patch request.") .required(true) .type(Long.class); parser .addArgument("-p", "--proposal_id") .help( "The resource ID of the proposals resource that is being patched. This will be used to" + " construct the name used as a path parameter for the proposals.patch request.") .required(true) .type(String.class); parser .addArgument("-r", "--proposal_revision") .help( "The revision number for the proposal being modified. Each update to the proposal " + "or its deals causes the number to increment. The revision number specified must " + "match the value stored server-side in order for the operation to be performed.") .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.proposals.addNote 为提案添加注释。
向提案添加备注时,这些备注会存储在提案的 notes 字段中。发布商可以看到备注。我们建议您使用 notes 字段在协商期间与发布商沟通。
以下示例演示了如何使用 addNote 方法向提案添加备注。
REST
请求
POST https://authorizedbuyersmarketplace.googleapis.com/v1/buyers/12345678/proposals/MP49876074:addNote?alt=json
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json
{
"note": {
"note": "Test note."
}
}响应
{
"name": "buyers/12345678/proposals/MP49876074",
"updateTime": "2022-03-26T04:03:19.282Z",
"proposalRevision": "2",
"dealType": "PROGRAMMATIC_GUARANTEED",
"displayName": "Test PG Proposal #0ce643e9-5518-4e8e-b352-0cb45cc2eeb2",
"state": "SELLER_REVIEW_REQUESTED",
"originatorRole": "BUYER",
"publisherProfile": "buyers/12345678/publisherProfiles/PP111111",
"buyer": "buyers/12345678",
"buyerPrivateData": {
"referenceId": "2f5e9550-8d22-495e-ba38-9b9496347a3b"
},
"billedBuyer": "buyers/12345678",
"sellerContacts": [
{
"email": "jeff@hypersonicmedia.com"
},
{
"email": "alex@hypersonicmedia.com"
},
],
"buyerContacts": [
{
"email": "testemail89319783@test.com",
"displayName": "Joe"
}
],
"lastUpdaterOrCommentorRole": "BUYER",
"notes": [
{
"createTime": "2022-03-26T04:03:19.548Z",
"creatorRole": "BUYER",
"note": "Test programmatic guaranteed deal proposal."
},
{
"createTime": "2022-03-26T05:36:23.406Z",
"creatorRole": "BUYER",
"note": "Test note."
}
]
}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.proposals; import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace; import com.google.api.services.authorizedbuyersmarketplace.v1.model.AddNoteRequest; import com.google.api.services.authorizedbuyersmarketplace.v1.model.Note; import com.google.api.services.authorizedbuyersmarketplace.v1.model.Proposal; 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; /** Adds a note to a given proposal. */ public class AddNoteToProposals { public static void execute(AuthorizedBuyersMarketplace marketplaceClient, Namespace parsedArgs) { Long accountId = parsedArgs.getLong("account_id"); String proposalId = parsedArgs.getString(("proposal_id")); String proposalName = String.format("buyers/%d/proposals/%s", accountId, proposalId); String noteValue = parsedArgs.getString("note"); Note note = new Note(); note.setNote(noteValue); AddNoteRequest addNoteRequest = new AddNoteRequest(); addNoteRequest.setNote(note); Proposal proposal = null; try { proposal = marketplaceClient.buyers().proposals().addNote(proposalName, addNoteRequest).execute(); } catch (IOException ex) { System.out.printf("Marketplace API returned error response:%n%s", ex); System.exit(1); } System.out.printf("Adding note to proposal with name \"%s\":%n", proposalName); Utils.printProposal(proposal); } public static void main(String[] args) { ArgumentParser parser = ArgumentParsers.newFor("AddNoteToProposals") .build() .defaultHelp(true) .description(("Adds a note to a given proposal.")); parser .addArgument("-a", "--account_id") .help( "The resource ID of the buyers resource under which the proposal is being " + "accessed. This will be used to construct the proposal name used as a path " + "parameter for the proposals.addNote request.") .required(true) .type(Long.class); parser .addArgument("-p", "--proposal_id") .help( "The resource ID of the proposals resource that a note is being added to. This " + "will be used to construct the name used as a path parameter for the " + "proposals.addNote request.") .required(true) .type(String.class); parser .addArgument("-n", "--note") .help("The note to be added to the proposal.") .type(String.class) .setDefault("Created note from Java sample."); 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); } }