create method

Future<ReturnShippingLabel> create(
  1. ReturnShippingLabel request,
  2. String merchantId,
  3. String returnId, {
  4. String? $fields,
})

Links a return shipping label to a return id.

You can only create one return label per return id. Since the label is sent to the buyer, the linked return label cannot be updated or deleted. If you try to create multiple return shipping labels for a single return id, every create request except the first will fail.

request - The metadata request object.

Request parameters:

merchantId - Required. The merchant the Return Shipping Label belongs to.

returnId - Required. Provide the Google-generated merchant order return ID.

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

Completes with a ReturnShippingLabel.

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<ReturnShippingLabel> create(
  ReturnShippingLabel request,
  core.String merchantId,
  core.String returnId, {
  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_ = commons.escapeVariable('$merchantId') +
      '/orderreturns/' +
      commons.escapeVariable('$returnId') +
      '/labels';

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