updateProduct method

Future<void> updateProduct(
  1. String productId,
  2. List<Patch> patchRequests
)

Updates a product, by ID. You can patch these attributes and objects:

  • description. Operations: add, replace, remove
  • category. Operations: add, replace, remove
  • image_url. Operations: add, replace, remove
  • home_url. Operations: add, replace, remove

Implementation

Future<void> updateProduct(
    String productId, List<Patch> patchRequests) async {
  var uri = _payPalHttpClient.getUrl('/v1/catalogs/products/$productId');

  var patchRequest = List.generate(
      patchRequests.length, (index) => patchRequests[index].toJson());

  var body = jsonEncode(patchRequest);

  await _payPalHttpClient.patch(uri, body: body);
}