Skip to content

Commit 79ba761

Browse files
committed
v0.3.3 contacts management
1 parent c23e2d1 commit 79ba761

File tree

3 files changed

+75
-18
lines changed

3 files changed

+75
-18
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ whmcs_client.customers.getCustomerEmails(clientid, {}, function(err, emails) {
6868
### Customers
6969

7070
- getContacts: function (clientid, callback)
71-
- createCustomer: function (ocustomer, callback)
71+
- createContact: function (options, callback)
72+
- deleteContact: function (contactid, callback)
73+
- updateContact: function (contactid, options, callback)
74+
- createCustomer: function (options, callback)
7275
- deleteCustomer: function (clientid, options, callback)
7376
- updateCustomer: function (clientid, options, callback)
7477
- updateCustomerDomain: function (domainid, options, [options], callback)

lib/customer.js

+70-16
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Customers.prototype.createCustomer = function (ocustomer, callback) {
1414

1515
options.action = 'addclient';
1616

17-
options.responsetype = "json";
17+
options.responsetype = 'json';
1818

1919
var createOptions = {
2020
client: this,
@@ -24,6 +24,60 @@ Customers.prototype.createCustomer = function (ocustomer, callback) {
2424
utils.modem(createOptions, callback);
2525
};
2626

27+
Customers.prototype.createContact = function (ocontact, callback) {
28+
var self = this;
29+
var options = {};
30+
31+
_.extend(options, ocontact);
32+
33+
options.action = 'addcontact';
34+
35+
options.responsetype = 'json';
36+
37+
var createOptions = {
38+
client: this,
39+
body: options
40+
};
41+
42+
utils.modem(createOptions, callback);
43+
};
44+
45+
Customers.prototype.deleteContact = function (contactid, callback) {
46+
var self = this;
47+
var options = {};
48+
49+
options.action = 'deletecontact';
50+
options.contactid = contactid;
51+
52+
options.responsetype = 'json';
53+
54+
var deleteOptions = {
55+
client: this,
56+
body: options
57+
};
58+
59+
utils.modem(deleteOptions, callback);
60+
};
61+
62+
Customers.prototype.updateContact = function (contactid, ocontact, callback) {
63+
var self = this;
64+
var options = {};
65+
66+
_.extend(options, ocontact);
67+
68+
options.action = 'updatecontact';
69+
70+
options.responsetype = 'json';
71+
options.contactid = contactid;
72+
73+
var updateOptions = {
74+
client: this,
75+
body: options
76+
};
77+
78+
utils.modem(updateOptions, callback);
79+
};
80+
2781
Customers.prototype.updateCustomer = function (clientid, ocustomer, callback) {
2882
var self = this;
2983
var options = {};
@@ -32,7 +86,7 @@ Customers.prototype.updateCustomer = function (clientid, ocustomer, callback) {
3286

3387
options.action = 'updateclient';
3488

35-
options.responsetype = "json";
89+
options.responsetype = 'json';
3690
options.clientid = clientid;
3791

3892
var createOptions = {
@@ -51,7 +105,7 @@ Customers.prototype.updateCustomerDomain = function (domainid, opts, callback) {
51105

52106
options.action = 'updateclientdomain';
53107

54-
options.responsetype = "json";
108+
options.responsetype = 'json';
55109
options.domainid = domainid;
56110

57111
var createOptions = {
@@ -77,7 +131,7 @@ Customers.prototype.getContacts = function (userid, opts, callback) {
77131

78132
options.action = 'getcontacts';
79133
options.userid = userid;
80-
options.responsetype = "json";
134+
options.responsetype = 'json';
81135

82136
var createOptions = {
83137
client: this,
@@ -103,7 +157,7 @@ Customers.prototype.getCustomer = function (clientid, opts, callback) {
103157
options.action = 'getclientsdetails';
104158
options.clientid = clientid;
105159
options.stats = true;
106-
options.responsetype = "json";
160+
options.responsetype = 'json';
107161

108162
var createOptions = {
109163
client: this,
@@ -129,7 +183,7 @@ Customers.prototype.getCustomerByEmail = function (email, opts, callback) {
129183
options.action = 'getclientsdetails';
130184
options.email = email;
131185
options.stats = true;
132-
options.responsetype = "json";
186+
options.responsetype = 'json';
133187

134188
var createOptions = {
135189
client: this,
@@ -154,7 +208,7 @@ Customers.prototype.deleteCustomer = function (clientid, opts, callback) {
154208

155209
options.action = 'deleteclient';
156210
options.clientid = clientid;
157-
options.responsetype = "json";
211+
options.responsetype = 'json';
158212

159213
var createOptions = {
160214
client: this,
@@ -186,7 +240,7 @@ Customers.prototype.getCustomerProducts = function (clientid, serviceid, opts, c
186240
options.serviceid = serviceid;
187241
}
188242

189-
options.responsetype = "json";
243+
options.responsetype = 'json';
190244

191245
var createOptions = {
192246
client: this,
@@ -205,7 +259,7 @@ Customers.prototype.updateCustomerProduct = function (serviceid, oservice, callb
205259

206260
options.action = 'updateclientproduct';
207261
options.serviceid = serviceid;
208-
options.responsetype = "json";
262+
options.responsetype = 'json';
209263

210264
var createOptions = {
211265
client: this,
@@ -231,7 +285,7 @@ Customers.prototype.sendEmail = function (id, email, opts, callback) {
231285
options.action = 'sendemail';
232286
options.id = id;
233287
options.messagename = email;
234-
options.responsetype = "json";
288+
options.responsetype = 'json';
235289

236290

237291
var createOptions = {
@@ -260,7 +314,7 @@ Customers.prototype.getCustomerDomains = function (clientid, domainid, opts, cal
260314
if(domainid !== undefined) {
261315
options.domainid = domainid;
262316
}
263-
options.responsetype = "json";
317+
options.responsetype = 'json';
264318

265319
var createOptions = {
266320
client: this,
@@ -285,7 +339,7 @@ Customers.prototype.getCustomerEmails = function (clientid, opts, callback) {
285339

286340
options.action = 'getemails';
287341
options.clientid = clientid;
288-
options.responsetype = "json";
342+
options.responsetype = 'json';
289343

290344
var createOptions = {
291345
client: this,
@@ -310,7 +364,7 @@ Customers.prototype.getCustomerInvoices = function (clientid, opts, callback) {
310364

311365
options.action = 'getinvoices';
312366
options.userid = clientid;
313-
options.responsetype = "json";
367+
options.responsetype = 'json';
314368

315369
var createOptions = {
316370
client: this,
@@ -335,7 +389,7 @@ Customers.prototype.getCustomerOrders = function (clientid, opts, callback) {
335389

336390
options.action = 'getorders';
337391
options.userid = clientid;
338-
options.responsetype = "json";
392+
options.responsetype = 'json';
339393

340394
var createOptions = {
341395
client: this,
@@ -363,7 +417,7 @@ Customers.prototype.getTickets = function (clientid, status, opts, callback) {
363417
if(status) {
364418
options.status = status;
365419
}
366-
options.responsetype = "json";
420+
options.responsetype = 'json';
367421

368422
var createOptions = {
369423
client: this,
@@ -389,7 +443,7 @@ Customers.prototype.validateLogin = function (email, password, opts, callback) {
389443
options.action = 'validatelogin';
390444
options.email = email;
391445
options.password2 = password;
392-
options.responsetype = "json";
446+
options.responsetype = 'json';
393447

394448
var createOptions = {
395449
client: this,

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "whmcs",
33
"description": "WHMCS API node implementation",
4-
"version": "0.3.2",
4+
"version": "0.3.3",
55
"author": "Pedro Dias <[email protected]>",
66
"maintainers": [
77
"apocas <[email protected]>"

0 commit comments

Comments
 (0)