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; 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. * The base for all product types.
*/ */

View File

@ -3,6 +3,7 @@ import { ModelRepository } from '../../../framework';
import { import {
baseProductURL, baseProductURL,
buildProductURL, buildProductURL,
deleteProductURL,
ExternalProduct, ExternalProduct,
CreatesExternalProducts, CreatesExternalProducts,
DeletesExternalProducts, DeletesExternalProducts,
@ -61,6 +62,6 @@ export function externalProductRESTRepository( httpClient: HTTPClient ): ListsEx
restCreate< ExternalProductRepositoryParams >( baseProductURL, ExternalProduct, httpClient, transformer ), restCreate< ExternalProductRepositoryParams >( baseProductURL, ExternalProduct, httpClient, transformer ),
restRead< ExternalProductRepositoryParams >( buildProductURL, ExternalProduct, httpClient, transformer ), restRead< ExternalProductRepositoryParams >( buildProductURL, ExternalProduct, httpClient, transformer ),
restUpdate< 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, UpdatesGroupedProducts,
baseProductURL, baseProductURL,
buildProductURL, buildProductURL,
deleteProductURL,
} from '../../../models'; } from '../../../models';
import { import {
createProductTransformer, createProductTransformer,
@ -55,6 +56,6 @@ export function groupedProductRESTRepository( httpClient: HTTPClient ): ListsGro
restCreate< GroupedProductRepositoryParams >( baseProductURL, GroupedProduct, httpClient, transformer ), restCreate< GroupedProductRepositoryParams >( baseProductURL, GroupedProduct, httpClient, transformer ),
restRead< GroupedProductRepositoryParams >( buildProductURL, GroupedProduct, httpClient, transformer ), restRead< GroupedProductRepositoryParams >( buildProductURL, GroupedProduct, httpClient, transformer ),
restUpdate< 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, SimpleProduct,
baseProductURL, baseProductURL,
buildProductURL, buildProductURL,
deleteProductURL,
CreatesSimpleProducts, CreatesSimpleProducts,
DeletesSimpleProducts, DeletesSimpleProducts,
ListsSimpleProducts, ListsSimpleProducts,
@ -70,6 +71,6 @@ export function simpleProductRESTRepository( httpClient: HTTPClient ): ListsSimp
restCreate< SimpleProductRepositoryParams >( baseProductURL, SimpleProduct, httpClient, transformer ), restCreate< SimpleProductRepositoryParams >( baseProductURL, SimpleProduct, httpClient, transformer ),
restRead< SimpleProductRepositoryParams >( buildProductURL, SimpleProduct, httpClient, transformer ), restRead< SimpleProductRepositoryParams >( buildProductURL, SimpleProduct, httpClient, transformer ),
restUpdate< 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, UpdatesVariableProducts,
baseProductURL, baseProductURL,
buildProductURL, buildProductURL,
deleteProductURL,
} from '../../../models'; } from '../../../models';
import { import {
createProductTransformer, createProductTransformer,
@ -67,6 +68,6 @@ export function variableProductRESTRepository( httpClient: HTTPClient ): ListsVa
restCreate< VariableProductRepositoryParams >( baseProductURL, VariableProduct, httpClient, transformer ), restCreate< VariableProductRepositoryParams >( baseProductURL, VariableProduct, httpClient, transformer ),
restRead< VariableProductRepositoryParams >( buildProductURL, VariableProduct, httpClient, transformer ), restRead< VariableProductRepositoryParams >( buildProductURL, VariableProduct, httpClient, transformer ),
restUpdate< VariableProductRepositoryParams >( buildProductURL, VariableProduct, httpClient, transformer ), restUpdate< VariableProductRepositoryParams >( buildProductURL, VariableProduct, httpClient, transformer ),
restDelete< VariableProductRepositoryParams >( buildProductURL, httpClient ), restDelete< VariableProductRepositoryParams >( deleteProductURL, httpClient ),
); );
} }