The customers http client now has a save helper method.
This commit is contained in:
parent
00c3aebef0
commit
d585dd550e
1 changed files with 20 additions and 8 deletions
|
@ -11,7 +11,18 @@
|
||||||
|
|
||||||
App.Http.Customers = (function () {
|
App.Http.Customers = (function () {
|
||||||
/**
|
/**
|
||||||
* Create an customer.
|
* Save (create or update) a customer.
|
||||||
|
*
|
||||||
|
* @param {Object} customer
|
||||||
|
*
|
||||||
|
* @return {Object}
|
||||||
|
*/
|
||||||
|
function save(customer) {
|
||||||
|
return customer.id ? update(customer) : create(customer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a customer.
|
||||||
*
|
*
|
||||||
* @param {Object} customer
|
* @param {Object} customer
|
||||||
*
|
*
|
||||||
|
@ -29,7 +40,7 @@ App.Http.Customers = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update an customer.
|
* Update a customer.
|
||||||
*
|
*
|
||||||
* @param {Object} customer
|
* @param {Object} customer
|
||||||
*
|
*
|
||||||
|
@ -47,7 +58,7 @@ App.Http.Customers = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an customer.
|
* Delete a customer.
|
||||||
*
|
*
|
||||||
* @param {Number} customerId
|
* @param {Number} customerId
|
||||||
*
|
*
|
||||||
|
@ -68,13 +79,13 @@ App.Http.Customers = (function () {
|
||||||
* Search customers by keyword.
|
* Search customers by keyword.
|
||||||
*
|
*
|
||||||
* @param {String} keyword
|
* @param {String} keyword
|
||||||
* @param {Number} limit
|
* @param {Number} [limit]
|
||||||
* @param {Number} offset
|
* @param {Number} [offset]
|
||||||
* @param {String} orderBy
|
* @param {String} [orderBy]
|
||||||
*
|
*
|
||||||
* @return {Object}
|
* @return {Object}
|
||||||
*/
|
*/
|
||||||
function search(keyword, limit, offset, orderBy) {
|
function search(keyword, limit = null, offset = null, orderBy = null) {
|
||||||
const url = App.Utils.Url.siteUrl('customers/search');
|
const url = App.Utils.Url.siteUrl('customers/search');
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
@ -89,7 +100,7 @@ App.Http.Customers = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find an customer.
|
* Find a customer.
|
||||||
*
|
*
|
||||||
* @param {Number} customerId
|
* @param {Number} customerId
|
||||||
*
|
*
|
||||||
|
@ -107,6 +118,7 @@ App.Http.Customers = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
save,
|
||||||
create,
|
create,
|
||||||
update,
|
update,
|
||||||
destroy,
|
destroy,
|
||||||
|
|
Loading…
Reference in a new issue