Get all employees plugin (no-search-criteria)
Get all employees from Magento /V1/store-locator/employees rest endpoint.unknown
javascript
4 years ago
1.7 kB
13
Indexable
const SearchCriteria = require('magento-searchcriteria-builder');
/**
*
* API url:
/V1/store-locator/employees
*
*
searchCriteria[filterGroups][0][filters][0][field] = location_ids
searchCriteria[filterGroups][0][filters][0][value] = null
searchCriteria[filterGroups][0][filters][0][conditionType] = neq
*
*
* API response interface:
* {
"items": [
{
"entity_id": 0,
"created_at": "string",
"first_name": "string",
"last_name": "string",
"position_id": "string",
"email": "string",
"phone": "string",
"brand_ids": "string",
"location_ids": "string",
"image": "string",
"sort_order": 0,
"extension_attributes": {}
}
]
}
*
*
*/
module.exports = ({ config, db, router, cache, apiStatus, apiError, getRestApiClient }) => {
const url = '/store-locator/employees';
const createRestClient = () => {
const client = getRestApiClient();
client.addMethods('storeLocator', (restClient) => {
const module = {};
module.getAllEmployees = () => {
return restClient.get(url);
};
return module;
});
return client;
};
router.get('', async (req, res) => {
const client = createRestClient();
client.storeLocator.getAllEmployees()
.then(response => {
console.log('Magento response: ', response);
apiStatus(res, response, 200);
})
.catch(err => {
console.error('Magento error: ', err);
apiError(res, err);
});
});
return {
domainName: '@grupakmk',
pluginName: 'test-plugin',
route: '/test',
router
};
};
Editor is loading...