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

Methods inherited from Base

parse_response, send_request

Class Method Details

.add_client(params = {}) ⇒ Object

Create a new client

Parameters:

  • :firstname

  • :lastname

  • :companyname - optional

  • :email

  • :address1

  • :address2 - optional

  • :city

  • :state

  • :postcode

  • :country - two letter ISO country code

  • :phonenumber

  • :password2 - password for the new user account

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

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

  • :notes

  • :cctype - Visa, Mastercard, etc…

  • :cardnum

  • :expdate - in the format MMYY

  • :startdate

  • :issuenumber

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

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

See:

wiki.whmcs.com/API:Add_Client



35
36
37
38
# File 'lib/whmcs/client.rb', line 35

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

.add_contact(params = {}) ⇒ Object

Add a client contact

Parameters:

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

  • :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:

wiki.whmcs.com/API:Add_Contact



161
162
163
164
# File 'lib/whmcs/client.rb', line 161

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

.delete_client(params = {}) ⇒ Object

Delete a client

Parameters:

  • :clientid - ID Number of the client to delete

See:

wiki.whmcs.com/API:Delete_Client



84
85
86
87
# File 'lib/whmcs/client.rb', line 84

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:

wiki.whmcs.com/API:Delete_Contact



238
239
240
241
# File 'lib/whmcs/client.rb', line 238

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

.get_clients(params = {}) ⇒ Object

Get multiple clients

Parameters:

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

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

  • :search - Can be passed to filter for clients with a name/email matching the term entered

See:

wiki.whmcs.com/API:Get_Clients



100
101
102
103
# File 'lib/whmcs/client.rb', line 100

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

See:

wiki.whmcs.com/API:Get_Clients_Details



115
116
117
118
# File 'lib/whmcs/client.rb', line 115

def self.get_clients_details(params = {})
  params.merge!(:action => 'getclientsdetails')
  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

See:

wiki.whmcs.com/API:Get_Clients_Password



129
130
131
132
# File 'lib/whmcs/client.rb', line 129

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

.get_clients_products(params = {}) ⇒ Object

Get client’s products

Parameters:

  • :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

See:

wiki.whmcs.com/API:Get_Clients_Products



255
256
257
258
# File 'lib/whmcs/client.rb', line 255

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

.get_contacts(params = {}) ⇒ Object

Get client’s contacts

Parameters:

  • :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:

wiki.whmcs.com/API:Get_Contacts



189
190
191
192
# File 'lib/whmcs/client.rb', line 189

def self.get_contacts(params = {})
  params.merge!(:action => 'getcontacts')
  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

See:

wiki.whmcs.com/API:Send_Email



321
322
323
324
# File 'lib/whmcs/client.rb', line 321

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

.update_client(params = {}) ⇒ Object

Update a client’s info

Parameters:

  • :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

See:

wiki.whmcs.com/API:Update_Client



70
71
72
73
# File 'lib/whmcs/client.rb', line 70

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

.update_client_product(params = {}) ⇒ Object

Update client’s product

Parameters:

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

  • :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

See:

wiki.whmcs.com/API:Update_Client_Product



291
292
293
294
# File 'lib/whmcs/client.rb', line 291

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

  • :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

  • :password - change the password

  • :permissions - set permissions eg manageproducts,managedomains

Only send fields you wish to update

See:

wiki.whmcs.com/API:Update_Contact



224
225
226
227
# File 'lib/whmcs/client.rb', line 224

def self.update_contact(params = {})
  params.merge!(:action => 'updatecontact')
  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:

wiki.whmcs.com/API:Validate_Login



306
307
308
309
# File 'lib/whmcs/client.rb', line 306

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