Class: WHMCS::Client

Inherits:
Base
  • Object
show all
Defined in:
lib/whmcs/client.rb

Overview

WHMCS::Client is the class for managing clients

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

parse_response, send_request

Class Method Details

.add_cancel_request(params = {}) ⇒ Object

Add Cancel Request This command is used to Add Cancellation Request for a specific product

Parameters:

  • :serviceid - Service ID to be cancelled

  • :type - ‘Immediate’ OR ‘End of Billing Period’

Optional attributes:

  • :reason - Reason for cancel

See: docs.whmcs.com/API:Add_Cancel_Request



314
315
316
317
# File 'lib/whmcs/client.rb', line 314

def self.add_cancel_request(params = {})
	params.merge!(:action => 'addcancelrequest')
	send_request(params)
end

.add_client(params = {}) ⇒ Object

Create a new client

Parameters:

  • :firstname

  • :lastname

  • :email

  • :address1

  • :city

  • :state

  • :postcode

  • :country - two letter ISO country code

  • :phonenumber

  • :password2 - password for new user account

Optional attributes:

  • :companyname

  • :address2

  • :currency - the ID of the currency to set the user to

  • :clientip - pass the client IP address

  • :language - the language to assign to the client

  • :groupid - used to assign the client to a client group

  • :securityqid - the ID of the security question for the user

  • :securityqans - the answer to the client security question

  • :notes

  • :cctype - Visa, Mastercard, etc…

  • :cardnum

  • :expdate

  • :startdate

  • :issuenumber

  • :customfields - a base64 encoded serialized array of custom field values

  • :noemail - pass as true to surpress the client signup welcome email sending

  • :skipvalidation - set true to not validate or check required fields

Note: All client required fields can be optional if “skipvalidation” is passed See: docs.whmcs.com/API:Add_Client



41
42
43
44
# File 'lib/whmcs/client.rb', line 41

def self.add_client(params = {})
	params.merge!(:action => 'addclient')
	send_request(params)
end

.add_client_note(params = {}) ⇒ Object

Add Client Note This command is used to add the Client Note to a specific Client

Parameters:

  • :userid - UserID for the note

  • :notes - The note to add

See: docs.whmcs.com/API:Add_Client_Note



55
56
57
58
# File 'lib/whmcs/client.rb', line 55

def self.add_client_note(params = {})
	params.merge!(:action => 'addclientnote')
	send_request(params)
end

.add_contact(params = {}) ⇒ Object

Add a client contact

Parameters:

  • :clientid - the client ID to add the contact to

Optional attributes:

  • :firstname

  • :lastname

  • :companyname

  • :email

  • :address1

  • :address2

  • :city

  • :state

  • :postcode

  • :country - two letter ISO country code

  • :phonenumber

  • :password2 - if creating a sub-account

  • :permissions - can specify sub-account permissions eg manageproducts,managedomains

  • :generalemails - set true to receive general email types

  • :productemails - set true to receive product related emails

  • :domainemails - set true to receive domain related emails

  • :invoiceemails - set true to receive billing related emails

  • :supportemails - set true to receive support ticket related emails

See:

docs.whmcs.com/API:Add_Contact



297
298
299
300
# File 'lib/whmcs/client.rb', line 297

def self.add_contact(params = {})
	params.merge!(:action => 'addcontact')
	send_request(params)
end

.close_client(params = {}) ⇒ Object

Close a client account

Parameters:

  • :clientid

See:

docs.whmcs.com/API:Close_Client



68
69
70
71
# File 'lib/whmcs/client.rb', line 68

def self.close_client(params = {})
	params.merge!(:action => 'closeclient')
	send_request(params)
end

.delete_client(params = {}) ⇒ Object

Delete a client

Parameters:

  • :clientid - ID Number of the client to delete

See:

docs.whmcs.com/API:Delete_Client



185
186
187
188
# File 'lib/whmcs/client.rb', line 185

def self.delete_client(params = {})
	params.merge!(:action => 'deleteclient')
	send_request(params)
end

.delete_contact(params = {}) ⇒ Object

Delete a client’s contact

Parameters:

  • :contactid - The ID of the contact to delete

See:

docs.whmcs.com/API:Delete_Contact



419
420
421
422
# File 'lib/whmcs/client.rb', line 419

def self.delete_contact(params = {})
	params.merge!(:action => 'deletecontact')
	send_request(params)
end

.get_client_groupsObject

Get Client Groups

This command is used to get a list of the client groups in XML format

See:

docs.whmcs.com/API:Get_Client_Groups



604
605
606
# File 'lib/whmcs/client.rb', line 604

def self.get_client_groups
	send_request(:action => 'getclientgroups')
end

.get_clients(params = {}) ⇒ Object



203
204
205
206
# File 'lib/whmcs/client.rb', line 203

def self.get_clients(params = {})
	params.merge!(:action => 'getclients')
	send_request(params)
end

.get_clients_details(params = {}) ⇒ Object

Get a client’s info

Parameters:

  • :clientid - the id number of the client

  • :email - the email address of the client

Optional attributes:

  • :stats - true - If the responsetype of your API call is not XML,

stats are not returned unless this variable is passed

See: docs.whmcs.com/API:Get_Clients_Details



247
248
249
250
# File 'lib/whmcs/client.rb', line 247

def self.get_clients_details(params = {})
	params.merge!(:action => 'getclientsdetails')
	send_request(params)
end

.get_clients_domains(params = {}) ⇒ Object

Get Clients Domains

  • :clientid - the ID of the client to retrieve products for

Optional attributes:

  • :domainid - the ID of the domain to retrieve details for

  • :domain - the domain of the service to retrieve details for

  • :limitstart - where to start the records. Used for pagination

  • :limitnum - the number of records to retrieve. Default = 25

  • :getnameservers - retrieve nameservers in the response

See:

docs.whmcs.com/API:Get_Clients_Domains



458
459
460
461
# File 'lib/whmcs/client.rb', line 458

def self.get_clients_domains(params = {})
	params.merge!(:action => 'getclientsdomains')
	send_request(params)
end

.get_clients_password(params = {}) ⇒ Object

Get a hash of a client’s password

Parameters:

  • :userid - should contain the user id of the client you wish to get the password for

Optional attributes:

  • :email - send email address instead of userid

See:

docs.whmcs.com/API:Get_Clients_Password



263
264
265
266
# File 'lib/whmcs/client.rb', line 263

def self.get_clients_password(params = {})
	params.merge!(:action => 'getclientpassword')
	send_request(params)
end

.get_clients_products(params = {}) ⇒ Object

Get client’s products

Optional attributes:

  • :clientid - the ID of the client to retrieve products for

  • :serviceid - the ID of the service to retrieve details for

  • :domain - the domain of the service to retrieve details for

  • :pid - the product ID of the services to retrieve products for

  • :username2 - the service username to retrieve details for

  • :limitstart - where to start the records. Used for pagination

  • :limitnum - the number of records to retrieve. Default = 999999

See:

docs.whmcs.com/API:Get_Clients_Products



439
440
441
442
# File 'lib/whmcs/client.rb', line 439

def self.get_clients_products(params = {})
	params.merge!(:action => 'getclientsproducts')
	send_request(params)
end

.get_contacts(params = {}) ⇒ Object

Get client’s contacts

Optional attributes:

  • :limitstart - Record to start at (default = 0)

  • :limitnum - Number of records to return (default = 25)

  • :userid

  • :firstname

  • :lastname

  • :companyname

  • :email

  • :address1

  • :address2

  • :city

  • :state

  • :postcode

  • :country

  • :phonenumber

  • :subaccount - true/false

See:

docs.whmcs.com/API:Get_Contacts



342
343
344
345
# File 'lib/whmcs/client.rb', line 342

def self.get_contacts(params = {})
	params.merge!(:action => 'getcontacts')
	send_request(params)
end

.get_credits(params = {}) ⇒ Object

Get Client Credits

Parameters:

  • :clientid

See: docs.whmcs.com/API:Get_Credits



215
216
217
218
# File 'lib/whmcs/client.rb', line 215

def self.get_credits(params = {})
	params.merge!(:action => 'getcredits')
	send_request(params)
end

.get_emails(params = {}) ⇒ Object

Get Emails This command is used to get a list of the client emails in XML format

Parameters:

  • :clientid - ID of the client to obtain the credit list for

Optional attributes:

  • :date - date to obtain emails for. Can be YYYYMMDD, YYYYMM, MMDD, DD or MM

  • :subject - to obtain email with a specific subject

  • :limitstart - for pagination, specify an ID to start at (default = 0)

  • :limitnum - to restrict the number of results returned (default = 25)



551
552
553
554
# File 'lib/whmcs/client.rb', line 551

def self.get_emails(params = {})
	params.merge!(:action => 'getemails')
	send_request(params)
end

.get_quotes(params = {}) ⇒ Object

Get Quotes

Parameters:

  • :userid

Optional attributes:

  • :quoteid - specific quote to obtain

  • :userid - obtain quotes for a specific user

  • :datecreated - Format YYYYMMDD

  • :astmodified - Format YYYYMMDD

  • :validuntil - Format YYYYMMDD

  • :stage - Specific stage to retrieve quotes for

  • :subject - to obtain quotes with a specific subject

  • :limitstart - for pagination, specify an ID to start at

  • :limitnum - to restrict the number of results returned

See:

docs.whmcs.com/API:Get_Quotes



592
593
594
595
# File 'lib/whmcs/client.rb', line 592

def self.get_quotes(params = {})
	params.merge!(:action => 'getquotes')
	send_request(params)
end

.get_transactions(params = {}) ⇒ Object

Get Transactions This command is used to obtain an XML list of transactions from your WHMCS

Optional attributes:

  • :clientid - User ID to obtain details for

  • :invoiceid - Obtain transactions for a specific invoice

  • :transid - Obtain details for a specific transaction ID

See: docs.whmcs.com/API:Get_Transactions



567
568
569
570
# File 'lib/whmcs/client.rb', line 567

def self.get_transactions(params = {})
	params.merge!(:action => 'gettransactions')
	send_request(params)
end

.send_email(params = {}) ⇒ Object

Send email to client

Parameters:

  • :messagename - unique name of the email template to send from WHMCS

  • :id - related ID number to send message for

(for a general email type a client ID, for a product email type the products Service ID, etc…)

Optional attributes:

  • :customtype - The type of email: general, product, domain or invoice

  • :customsubject - Subject for the custom email being sent

  • :custommessage - Content to send as an email, this will override ‘messagename’ if set

  • :customvars - serialized base64 encoded array of custom variables

See:

docs.whmcs.com/API:Send_Email



535
536
537
538
# File 'lib/whmcs/client.rb', line 535

def self.send_email(params = {})
	params.merge!(:action => 'sendemail')
	send_request(params)
end

.update_client(params = {}) ⇒ Object

Update a client’s info Parameters:

  • :clientid - Client you wish to update

Optional attributes:

  • :firstname

  • :lastname

  • :companyname

  • :email

  • :address1

  • :address2

  • :city

  • :state

  • :postcode

  • :country - two letter ISO country code

  • :phonenumber

  • :password2

  • :credit - credit balance

  • :taxexempt - true to enable

  • :notes

  • :cardtype - visa, mastercard, etc…

  • :cardnum - cc number

  • :expdate - cc expiry date

  • :startdate - cc start date

  • :issuenumber - cc issue number

  • :language - default language

  • :status - active or inactive

  • :latefeeoveride - true/false

  • :overideduenotices - true/false

  • :separateinvoices - true/false

  • :disableautocc - true/false

See:

docs.whmcs.com/API:Update_Client



108
109
110
111
# File 'lib/whmcs/client.rb', line 108

def self.update_client(params = {})
	params.merge!(:action => 'updateclient')
	send_request(params)
end

.update_client_addon(params = {}) ⇒ Object

Update Client Addon

Parameters:

  • :id - ID of addon to update tblhostingaddons.id

Optional attributes:

  • :addonid - Update the defined addon id - tbladdons.id

  • :name - Custom name to define for the addon

  • :setupfee - Setup fee cost. No symbol,i.e xx.xx

  • :recurring - Setup fee cost. No symbol,i.e xx.xx

  • :billingcycle - One of Free Account, One Time, Monthly, Quarterly, Semi-Annually, Annually, Biennially or Triennially

  • :nextduedate - Update the next due date yyyymmdd

  • :nextinvoicedate - Update the next invoice date yyyymmdd

  • :notes - add custom notes to the addon

  • :status - Pending, Active, Suspended, Cancelled, Terminated, Fraud

See: docs.whmcs.com/API:Update_Client_Addon



133
134
135
136
# File 'lib/whmcs/client.rb', line 133

def self.update_client_addon(params = {})
	params.merge!(:action => 'updateclientaddon')
	send_request(params)
end

.update_client_domain(params = {}) ⇒ Object

Update Client Domain

Parameters:

  • :domainid - ID of domain to update tbldomains.id

  • :domain - instead of domainid

Optional attributes:

  • :type - Register or Transfer

  • :autorecalc - automatically recalculate the recurring price. Will override recurringamount

  • :regdate - Update the reg date yyyymmdd

  • :domain - Update the domain name

  • :firstpaymentamount - Set the first payment amount. No symbol, i.e xx.xx

  • :recurringamount - Setup fee cost. No symbol, i.e xx.xx

  • :registrar - Update the registrar assigned to the domain

  • :billingcycle - One of Free Account, One Time, Monthly, Quarterly, Semi-Annually, Annually, Biennially or Triennially

  • :status - One of Active, Pending, Pending Transfer, Expired, Cancelled, Fraud

  • :nextduedate - Update the next due date yyyymmdd

  • :nextinvoicedate - Update the next invoice date yyyymmdd

  • :expirydate - Update the expiry date yyyymmdd

  • :regperiod - Update the reg period for the domain. 1-10

  • :paymentmethod - set the payment method

  • :subscriptionid - allocate a subscription ID

  • :dnsmanagement - enable/disable DNS Management

  • :emailforwarding - enable/disable Email Forwarding

  • :idprotection - enable/disable ID Protection status

  • :donotrenew - enable/disable Do Not Renew

  • :updatens - Set to true to update Nameservers

  • :nsX - X should be 1-5, nameservers to send. Minimum 1&2 required

  • :notes - add custom notes to the addon

See: docs.whmcs.com/API:Update_Client_Domain



170
171
172
173
# File 'lib/whmcs/client.rb', line 170

def self.update_client_domain(params = {})
	params.merge!(:action => 'updateclientdomain')
	send_request(params)
end

.update_client_product(params = {}) ⇒ Object

Update client’s product

Parameters:

  • :serviceid - the ID of the service to be updated

Optional attributes:

  • :pid

  • :serverid

  • :regdate - Format: YYYY-MM-DD

  • :nextduedate - Format: YYYY-MM-DD

  • :domain

  • :firstpaymentamount

  • :recurringamount

  • :billingcycle

  • :paymentmethod

  • :status

  • :serviceusername

  • :servicepassword

  • :subscriptionid

  • :promoid

  • :overideautosuspend - on/off

  • :overidesuspenduntil - Format: YYYY-MM-DD

  • :ns1

  • :ns2

  • :dedicatedip

  • :assignedips

  • :notes

  • :autorecalc - pass true to auto set price based on product ID or billing cycle change

  • :customfields - a base64 encoded serialized array of custom field values

  • :configoptions - a base64 encoded serialized array of configurable options values

See:

docs.whmcs.com/API:Update_Client_Product



498
499
500
501
# File 'lib/whmcs/client.rb', line 498

def self.update_client_product(params = {})
	params.merge!(:action => 'updateclientproduct')
	send_request(params)
end

.update_contact(params = {}) ⇒ Object

Update a client’s contact

Parameters:

  • :contactid - The ID of the contact to delete

Optional attributes:

  • :generalemails - set to true to receive general emails

  • :productemails - set to true to receive product emails

  • :domainemails - set to true to receive domain emails

  • :invoiceemails - set to true to receive invoice emails

  • :supportemails - set to true to receive support emails

  • :firstname - change the firstname

  • :lastname - change the lastname

  • :companyname - change the companyname

  • :email - change the email address

  • :address1 - change address1

  • :address2 - change address2

  • :city - change city

  • :state - change state

  • :postcode - change postcode

  • :country - change country

  • :phonenumber - change phonenumber

  • :subaccount - enable subaccount

  • :password2 - change the password

  • :permissions - set permissions eg manageproducts,managedomains

Only send fields you wish to update

See:

docs.whmcs.com/API:Update_Contact



379
380
381
382
# File 'lib/whmcs/client.rb', line 379

def self.update_contact(params = {})
	params.merge!(:action => 'updatecontact')
	send_request(params)
end

.upgrade_product(params = {}) ⇒ Object

Upgrade Product

This command allows you to calculate the cost for an upgrade or downgrade of a product/service, and create an order for it.

Parameters:

  • :clientid - the client ID to be upgraded

  • :serviceid - the service ID to be upgraded

  • :type - either “product” or “configoptions”

  • :newproductid - if upgrade type = product, the new product ID to upgrade to

  • :newproductbillingcycle - monthly, quarterly, etc…

  • :configoptions[x] - if upgrade type = configoptions, an array of config options

  • :paymentmethod - the payment method for the order (paypal, authorize, etc…)

Optional attributes:

  • :promocode - associate a promotion code with the upgrade

  • :calconly - set true to validate upgrade and get price, false to actually create order

  • :ordernotes - any admin notes to add to the order

See:

docs.whmcs.com/API:Upgrade_Product



404
405
406
407
# File 'lib/whmcs/client.rb', line 404

def self.upgrade_product(params = {})
	params.merge!(:action => 'upgradeproduct')
	send_request(params)
end

.validate_login(params = {}) ⇒ Object

Validate client login info

Parameters:

  • :email - the email address of the user trying to login

  • :password2 - the password they supply for authentication

See:

docs.whmcs.com/API:Validate_Login



513
514
515
516
# File 'lib/whmcs/client.rb', line 513

def self.(params = {})
	params.merge!(:action => 'validatelogin')
	send_request(params)
end

Instance Method Details

#get_clients_addons(params = {}) ⇒ Object

Get Clients Addons

Parameters:

  • :clientid - The Client ID you wish to obtain the results for

  • :addonid - The specific addonid you wish to find

  • :serviceid - The specific, or comma separated list of, service(s)

See: docs.whmcs.com/API:Get_Clients_Addons



229
230
231
232
# File 'lib/whmcs/client.rb', line 229

def get_clients_addons(params = {})
	params.merge!(:action => 'getclientsaddons')
	send_request(params)
end