accept method

Future<Proposal> accept(
  1. AcceptProposalRequest request,
  2. String name, {
  3. String? $fields,
})

Accepts the proposal at the given revision number.

If the revision number in the request is behind the latest from the server, an error message will be returned. This call updates the Proposal.state from BUYER_ACCEPTANCE_REQUESTED to FINALIZED; it has no side effect if the Proposal.state is already FINALIZED and throws exception if the Proposal.state is not either BUYER_ACCEPTANCE_REQUESTED or FINALIZED. Accepting a proposal means the buyer understands and accepts the Proposal.terms_and_conditions proposed by the seller.

request - The metadata request object.

Request parameters:

name - Name of the proposal. Format: buyers/{accountId}/proposals/{proposalId} Value must have pattern ^buyers/\[^/\]+/proposals/\[^/\]+$.

$fields - Selector specifying which fields to include in a partial response.

Completes with a Proposal.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<Proposal> accept(
  AcceptProposalRequest request,
  core.String name, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v1/' + core.Uri.encodeFull('$name') + ':accept';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return Proposal.fromJson(response_ as core.Map<core.String, core.dynamic>);
}