save method

Future<Product> save(
  1. Product product
)

Persist product to the server

Implementation

Future<Product> save(Product product) async {
  dynamic response;

  if (product.id.isEmpty) {
    response = await WebClient().post(
        '${InvoiceNinjaAdmin.url}/api/v1/products',
        token: InvoiceNinjaAdmin.token,
        data: product.toJson());
  } else {
    response = await WebClient().put(
        '${InvoiceNinjaAdmin.url}/api/v1/products/${product.id}',
        token: InvoiceNinjaAdmin.token,
        data: product.toJson());
  }

  return ProductItem.fromJson(response).data;
}