delete vs trash product in e2e api

This commit is contained in:
Ron Rennick 2021-03-09 13:45:05 -04:00
parent 9352dd1b81
commit f266f20101
5 changed files with 16 additions and 4 deletions

View File

@ -27,6 +27,14 @@ export const baseProductURL = () => '/wc/v3/products/';
*/
export const buildProductURL = ( id: ModelID ) => baseProductURL() + id;
/**
* A common delete product URL builder.
*
* @param {ModelID} id the id of the product.
* @return {string} RESTful Url.
*/
export const deleteProductURL = ( id: ModelID ) => buildProductURL( id ) + '?force=true';
/**
* The base for all product types.
*/

View File

@ -3,6 +3,7 @@ import { ModelRepository } from '../../../framework';
import {
baseProductURL,
buildProductURL,
deleteProductURL,
ExternalProduct,
CreatesExternalProducts,
DeletesExternalProducts,
@ -61,6 +62,6 @@ export function externalProductRESTRepository( httpClient: HTTPClient ): ListsEx
restCreate< ExternalProductRepositoryParams >( baseProductURL, ExternalProduct, httpClient, transformer ),
restRead< ExternalProductRepositoryParams >( buildProductURL, ExternalProduct, httpClient, transformer ),
restUpdate< ExternalProductRepositoryParams >( buildProductURL, ExternalProduct, httpClient, transformer ),
restDelete< ExternalProductRepositoryParams >( buildProductURL, httpClient ),
restDelete< ExternalProductRepositoryParams >( deleteProductURL, httpClient ),
);
}

View File

@ -10,6 +10,7 @@ import {
UpdatesGroupedProducts,
baseProductURL,
buildProductURL,
deleteProductURL,
} from '../../../models';
import {
createProductTransformer,
@ -55,6 +56,6 @@ export function groupedProductRESTRepository( httpClient: HTTPClient ): ListsGro
restCreate< GroupedProductRepositoryParams >( baseProductURL, GroupedProduct, httpClient, transformer ),
restRead< GroupedProductRepositoryParams >( buildProductURL, GroupedProduct, httpClient, transformer ),
restUpdate< GroupedProductRepositoryParams >( buildProductURL, GroupedProduct, httpClient, transformer ),
restDelete< GroupedProductRepositoryParams >( buildProductURL, httpClient ),
restDelete< GroupedProductRepositoryParams >( deleteProductURL, httpClient ),
);
}

View File

@ -4,6 +4,7 @@ import {
SimpleProduct,
baseProductURL,
buildProductURL,
deleteProductURL,
CreatesSimpleProducts,
DeletesSimpleProducts,
ListsSimpleProducts,
@ -70,6 +71,6 @@ export function simpleProductRESTRepository( httpClient: HTTPClient ): ListsSimp
restCreate< SimpleProductRepositoryParams >( baseProductURL, SimpleProduct, httpClient, transformer ),
restRead< SimpleProductRepositoryParams >( buildProductURL, SimpleProduct, httpClient, transformer ),
restUpdate< SimpleProductRepositoryParams >( buildProductURL, SimpleProduct, httpClient, transformer ),
restDelete< SimpleProductRepositoryParams >( buildProductURL, httpClient ),
restDelete< SimpleProductRepositoryParams >( deleteProductURL, httpClient ),
);
}

View File

@ -10,6 +10,7 @@ import {
UpdatesVariableProducts,
baseProductURL,
buildProductURL,
deleteProductURL,
} from '../../../models';
import {
createProductTransformer,
@ -67,6 +68,6 @@ export function variableProductRESTRepository( httpClient: HTTPClient ): ListsVa
restCreate< VariableProductRepositoryParams >( baseProductURL, VariableProduct, httpClient, transformer ),
restRead< VariableProductRepositoryParams >( buildProductURL, VariableProduct, httpClient, transformer ),
restUpdate< VariableProductRepositoryParams >( buildProductURL, VariableProduct, httpClient, transformer ),
restDelete< VariableProductRepositoryParams >( buildProductURL, httpClient ),
restDelete< VariableProductRepositoryParams >( deleteProductURL, httpClient ),
);
}