Permalink
Browse files

feat(Rest): Add patch method, update docs for criteria implementation

  • Loading branch information...
nevercast authored and doktordirk committed Feb 12, 2016
1 parent 03fc292 commit a0328aad4db47ffca9393af22b4e1a09b890dd76
Showing with 27 additions and 7 deletions.
  1. +27 −7 src/rest.js
@@ -85,10 +85,10 @@ export class Rest {
/**
* Update a resource.
*
* @param {string} resource Resource to update
* @param {string|Number} criteria String / number of the id to update.
* @param {object} body New data for provided criteria.
* @param {{}} [options]
* @param {string} resource Resource to update
* @param {{}|string|Number} criteria Object for where clause, string / number for id.
* @param {object} body New data for provided criteria.
* @param {{}} [options]
*
* @return {Promise}
*/
@@ -102,12 +102,32 @@ export class Rest {
return this.request('put', requestPath, body, options);
}

/**
* Patch a resource.
*
* @param {string} resource Resource to patch
* @param {{}|string|Number} criteria Object for where clause, string / number for id.
* @param {object} body Data to patch for provided criteria.
* @param {{}} [options]
*
* @return {Promise}
*/
patch(resource, criteria, body, options) {
let requestPath = resource;

if (criteria) {
requestPath += typeof criteria !== 'object' ? `/${criteria}` : '?' + qs.stringify(criteria);
}

return this.request('patch', requestPath, body, options);
}

/**
* Delete a resource.
*
* @param {string} resource The resource to delete in
* @param {string|Number} criteria String / number of the id to delete.
* @param {{}} [options]
* @param {string} resource The resource to delete in
* @param {{}|string|Number} criteria Object for where clause, string / number for id.
* @param {{}} [options]
*
* @return {Promise}
*/

0 comments on commit a0328aa

Please sign in to comment.