export const AddEditProduct = (gapi, data, merchantId, type="ADD") => {
// Use gapi.client.request(args) function
const args = {
'path': `/content/v2.1/${merchantId}/products${type === 'UPDATE' ? `/${
data.id || data.offerId}` : ''}`,
'method': type === "UPDATE" ? 'PUT' : 'POST',
'body': JSON.stringify(data)
};
// Execute the API request.
return new Promise((resolve, reject) => {
return gapi.client.request(args)
.then((response) => {
resolve(response)
})
.catch((error) => {
reject(error)
})
})
};