|
| 1 | + |
| 2 | +/** |
| 3 | + * Module dependencies |
| 4 | + */ |
| 5 | + |
| 6 | +var util = require('util'); |
| 7 | +var Resource = require('./'); |
| 8 | + |
| 9 | +/** |
| 10 | + * Expose constructor |
| 11 | + */ |
| 12 | + |
| 13 | +module.exports = Customers; |
| 14 | + |
| 15 | +/** |
| 16 | + * Customers constructor |
| 17 | + */ |
| 18 | + |
| 19 | +function Customers(mango) { |
| 20 | + Resource.call(this, mango); |
| 21 | +} |
| 22 | + |
| 23 | +util.inherits(Customers, Resource); |
| 24 | + |
| 25 | +/** |
| 26 | + * Get customer |
| 27 | + * |
| 28 | + * @param {String} uid |
| 29 | + * @param {Function} callback |
| 30 | + * @api public |
| 31 | + */ |
| 32 | + |
| 33 | +Customers.prototype.get = function(uid, fn) { |
| 34 | + return this.request('get', '/customers/' + uid + '/', fn); |
| 35 | +}; |
| 36 | + |
| 37 | +/** |
| 38 | + * List customers |
| 39 | + * |
| 40 | + * @param {Object} options |
| 41 | + * @param {Function} callback |
| 42 | + * @api public |
| 43 | + */ |
| 44 | + |
| 45 | +Customers.prototype.list = function(options, fn) { |
| 46 | + return this.request('get', '/customers/', options, fn); |
| 47 | +}; |
| 48 | + |
| 49 | +/** |
| 50 | + * Create customer |
| 51 | + * |
| 52 | + * @param {Object} options |
| 53 | + * @param {Function} callback |
| 54 | + * @api public |
| 55 | + */ |
| 56 | + |
| 57 | +Customers.prototype.create = function(options, fn) { |
| 58 | + return this.request('post', '/customers/', options, fn); |
| 59 | +}; |
| 60 | + |
| 61 | +/** |
| 62 | + * Update customer |
| 63 | + * |
| 64 | + * @param {string} uid |
| 65 | + * @param {object} options |
| 66 | + * @param {function} callback |
| 67 | + * @api public |
| 68 | + */ |
| 69 | + |
| 70 | +Customers.prototype.update = function(uid, options, fn) { |
| 71 | + return this.request('patch', '/customers/' + uid + '/', options, fn); |
| 72 | +}; |
| 73 | + |
| 74 | +/** |
| 75 | + * Delete customer |
| 76 | + * |
| 77 | + * @param {string} uid |
| 78 | + * @param {function} callback |
| 79 | + * @api public |
| 80 | + */ |
| 81 | + |
| 82 | +Customers.prototype.del = function(uid, fn) { |
| 83 | + return this.request('delete', '/customers/' + uid + '/', fn); |
| 84 | +}; |
0 commit comments