woocommerce/packages/js/api-core-tests/endpoints/shipping-zones.js

72 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-11-11 11:39:40 +00:00
/**
* Internal dependencies
*/
const {
getRequest,
postRequest,
putRequest,
2021-11-11 11:39:40 +00:00
deleteRequest,
} = require( '../utils/request' );
/**
2021-11-11 13:11:03 +00:00
* WooCommerce Shipping zone endpoints.
2021-11-11 11:39:40 +00:00
*
* https://woocommerce.github.io/woocommerce-rest-api-docs/#shipping-zones
*/
const shippingZonesApi = {
name: 'Shipping zones',
create: {
name: 'Create a shipping zone',
method: 'POST',
path: 'shipping/zones',
responseCode: 201,
shippingZone: async ( shippingZone ) =>
postRequest( `shipping/zones`, shippingZone ),
},
retrieve: {
name: 'Retrieve a shipping zone',
method: 'GET',
path: 'shipping/zones/<id>',
responseCode: 200,
shippingZone: async ( shippingZoneId ) =>
getRequest( `shipping/zones/${ shippingZoneId }` ),
},
listAll: {
name: 'List all shipping zones',
method: 'GET',
path: 'shipping/zones',
responseCode: 200,
2021-11-11 12:02:30 +00:00
shippingZones: async ( params = {} ) =>
getRequest( `shipping/zones`, params ),
2021-11-11 11:39:40 +00:00
},
update: {
name: 'Update a shipping zone',
method: 'PUT',
path: 'shipping/zones/<id>',
responseCode: 200,
shippingZone: async ( shippingZoneId, updatedShippingZone ) =>
putRequest(
`shipping/zones/${ shippingZoneId }`,
updatedShippingZone
),
},
2021-11-11 11:39:40 +00:00
delete: {
name: 'Delete a shipping zone',
method: 'DELETE',
path: 'shipping/zones/<id>',
responseCode: 200,
payload: {
force: false,
},
shippingZone: async ( shippingZoneId, deletePermanently ) =>
deleteRequest(
`shipping/zones/${ shippingZoneId }`,
deletePermanently
),
},
};
module.exports = {
shippingZonesApi,
};