whmcs-api 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +37 -0
- data/Rakefile +17 -0
- data/lib/whmcs.rb +33 -0
- data/lib/whmcs/announcement.rb +69 -0
- data/lib/whmcs/base.rb +75 -0
- data/lib/whmcs/client.rb +607 -0
- data/lib/whmcs/config.rb +24 -0
- data/lib/whmcs/domain.rb +214 -0
- data/lib/whmcs/invoice.rb +253 -0
- data/lib/whmcs/misc.rb +266 -0
- data/lib/whmcs/module.rb +99 -0
- data/lib/whmcs/order.rb +195 -0
- data/lib/whmcs/quote.rb +127 -0
- data/lib/whmcs/ticket.rb +227 -0
- data/lib/whmcs/version.rb +3 -0
- data/test/test_helper.rb +27 -0
- data/test/whmcs_announcement_test.rb +29 -0
- data/test/whmcs_test.rb +16 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b6e986d4bb28d588b2c7b31935e004d36bdcb9d7
|
4
|
+
data.tar.gz: a44d73732ff8465d7d6f678482a9033ed9e20212
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e9bb016462637d9aca2f23864ed30f6402293fb70cb5df27ebfd755983527cc468372127f195579a4f5b8f5f3740ac8e938011ef8f97dec53d0ff0c48d2dfe91
|
7
|
+
data.tar.gz: 06e723247c4e86ec384cf05dcd8616853c6ba091709f57aa415dbd6076629414d99fdd32e40fde7881bcc469d6ab4d72fcd2d530f9e3bb663efc1cbf6ac5e8d8
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# whmcs-ruby
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/jujav4ik/whmcs-api.svg?branch=master)](https://travis-ci.org/jujav4ik/whmcs-api) | [![Coverage Status](https://coveralls.io/repos/jujav4ik/whmcs-api/badge.png)](https://coveralls.io/r/jujav4ik/whmcs-api)
|
4
|
+
|
5
|
+
whmcs-api provides Ruby bindings for the [WHMCS API](http://docs.whmcs.com/API#External_API).
|
6
|
+
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
require 'whmcs-api'
|
12
|
+
|
13
|
+
WHMCS.configure do |config|
|
14
|
+
config.api_url = 'http://example.com/includes/api.php'
|
15
|
+
config.api_username = 'someusername'
|
16
|
+
config.api_password = 'c4ca4238a0b923820dcc509a6f75849b' # md5 hash
|
17
|
+
# optionally add access key
|
18
|
+
config.api_key = 'YetAnotherAPIAccessKeyForWHMCS'
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
WHMCS::Client.get_clients_details(:clientid => '1')
|
23
|
+
```
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
## Useful links
|
29
|
+
|
30
|
+
* [Demo Credentials for WHMCS](http://www.whmcs.com/demo/)
|
31
|
+
* [WHMCS API](http://docs.whmcs.com/API#External_API)
|
32
|
+
|
33
|
+
## Copyright
|
34
|
+
|
35
|
+
Copyright (c) 2014 anvyst.com, under MIT License. Have fun!
|
36
|
+
|
37
|
+
Copyright (c) 2011 DotBlock.com, see LICENSE in this repo for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
$:.unshift 'lib'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
# See: http://www.whmcs.com/demo/
|
5
|
+
ENV['WHMCS_USER'] = 'Admin'
|
6
|
+
ENV['WHMCS_URL'] = 'http://demo.whmcs.com/includes/api.php'
|
7
|
+
ENV['WHMCS_PASS'] = 'fe01ce2a7fbac8fafaed7c982a04e229' #md5('demo')
|
8
|
+
ENV['WHMCS_KEY'] = 'whmcsdemo'
|
9
|
+
|
10
|
+
Rake::TestTask.new(:test) do |test|
|
11
|
+
test.libs << 'lib' << 'test' << '.'
|
12
|
+
test.pattern = 'test/**/*_test.rb'
|
13
|
+
test.verbose = true
|
14
|
+
test.warning = true
|
15
|
+
end
|
16
|
+
|
17
|
+
task :default => :test
|
data/lib/whmcs.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module WHMCS
|
2
|
+
autoload :Version, "whmcs/version"
|
3
|
+
autoload :Config, "whmcs/config"
|
4
|
+
autoload :Base, "whmcs/base"
|
5
|
+
autoload :Client, "whmcs/client"
|
6
|
+
autoload :Domain, "whmcs/domain"
|
7
|
+
autoload :Invoice, "whmcs/invoice"
|
8
|
+
autoload :Misc, "whmcs/misc"
|
9
|
+
autoload :Module, "whmcs/module"
|
10
|
+
autoload :Order, "whmcs/order"
|
11
|
+
autoload :Quote, "whmcs/quote"
|
12
|
+
autoload :Ticket, "whmcs/ticket"
|
13
|
+
autoload :Announcement, "whmcs/announcement"
|
14
|
+
|
15
|
+
class << self
|
16
|
+
attr_accessor :config
|
17
|
+
end
|
18
|
+
|
19
|
+
self.config ||= Config.new
|
20
|
+
|
21
|
+
# Pass a block to configure the WHMCS API
|
22
|
+
#
|
23
|
+
# WHMCS.configure do |config|
|
24
|
+
# config.api_username = 'apiuser'
|
25
|
+
# config.api_password = 'c4ca4238a0b923820dcc509a6f75849b'
|
26
|
+
# config.api_url = 'http://example.com/includes/api.php
|
27
|
+
# config.api_key = '123nifuasdfasdf97' # if any
|
28
|
+
# end
|
29
|
+
def self.configure
|
30
|
+
yield config
|
31
|
+
config
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module WHMCS
|
2
|
+
class Announcement < Base
|
3
|
+
# Add Announcement
|
4
|
+
# This command is used to Add a new announcement to the system
|
5
|
+
#
|
6
|
+
# Parameters:
|
7
|
+
# * <tt>:date</tt> - Date of the announcement in format yyyymmdd
|
8
|
+
# * <tt>:title</tt> - Title of the announcement
|
9
|
+
# * <tt>:announcement</tt> - Announcement text
|
10
|
+
# * <tt>:published</tt> - on/off
|
11
|
+
#
|
12
|
+
# Returns:
|
13
|
+
# * <tt>:result</tt>
|
14
|
+
# * <tt>:announcementid</tt>
|
15
|
+
# See:
|
16
|
+
#
|
17
|
+
# http://docs.whmcs.com/API:Add_Announcement
|
18
|
+
def self.add_announcement(params = {})
|
19
|
+
params.merge!(:action => 'addannouncement')
|
20
|
+
send_request(params)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Update Announcement
|
24
|
+
#
|
25
|
+
# Parameters:
|
26
|
+
# * <tt>:announcementid</tt> - ID of the announcement to edit
|
27
|
+
# * <tt>:date</tt> - Date of the announcement in format yyyymmdd
|
28
|
+
# * <tt>:title</tt> - Title of the announcement
|
29
|
+
# * <tt>:announcement</tt> - Announcement text
|
30
|
+
# * <tt>:published</tt> - on/off
|
31
|
+
#
|
32
|
+
# See:
|
33
|
+
#
|
34
|
+
# http://docs.whmcs.com/API:Update_Announcement
|
35
|
+
def self.update_announcement(params = {})
|
36
|
+
params.merge!(:action => 'updateannouncement')
|
37
|
+
send_request(params)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Get Announcements
|
41
|
+
# This command is used to get a list of the announcements in XML format
|
42
|
+
#
|
43
|
+
# Parameters:
|
44
|
+
# * <tt>:limitstart</tt> - used for pagination, start at a certain ID
|
45
|
+
# * <tt>:limitnum</tt> - restrict number of records
|
46
|
+
#
|
47
|
+
# See:
|
48
|
+
#
|
49
|
+
# http://docs.whmcs.com/API:Get_Announcements
|
50
|
+
def self.get_announcements(params ={})
|
51
|
+
params.merge!(:action => 'getannouncements')
|
52
|
+
send_request(params)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Delete Announcement
|
56
|
+
#
|
57
|
+
# Parameters:
|
58
|
+
# * <tt>:announcementid</tt> - The ID of the announcement to delete
|
59
|
+
#
|
60
|
+
# See:
|
61
|
+
#
|
62
|
+
# http://docs.whmcs.com/API:Delete_Announcement
|
63
|
+
def self.delete_announcement(params = {})
|
64
|
+
params.merge!(:action => 'deleteannouncement')
|
65
|
+
send_request(params)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
data/lib/whmcs/base.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
require 'crack'
|
4
|
+
|
5
|
+
module WHMCS
|
6
|
+
# WHMCS::Base is the main class used to subclass WHMCS API resources
|
7
|
+
class Base
|
8
|
+
|
9
|
+
# Sends an API request to the WHMCS API
|
10
|
+
#
|
11
|
+
# Parameters:
|
12
|
+
# * <tt>:action</tt> - The API action to perform
|
13
|
+
#
|
14
|
+
# All other paramters are passed along as HTTP POST variables
|
15
|
+
def self.send_request(params = {})
|
16
|
+
if params[:action].empty?
|
17
|
+
raise "No API action set"
|
18
|
+
end
|
19
|
+
|
20
|
+
params.merge!(
|
21
|
+
:username => WHMCS.config.api_username,
|
22
|
+
:password => WHMCS.config.api_password
|
23
|
+
)
|
24
|
+
|
25
|
+
# alternative API access
|
26
|
+
if( !WHMCS.config.api_key.nil? )
|
27
|
+
params.merge!( :accesskey => WHMCS.config.api_key )
|
28
|
+
end
|
29
|
+
|
30
|
+
url = URI.parse(WHMCS.config.api_url)
|
31
|
+
|
32
|
+
http = Net::HTTP.new(url.host, url.port)
|
33
|
+
|
34
|
+
if url.port == 443
|
35
|
+
http.use_ssl = true
|
36
|
+
end
|
37
|
+
|
38
|
+
req = Net::HTTP::Post.new(url.path)
|
39
|
+
req.set_form_data(params)
|
40
|
+
res = http.start { |http| http.request(req) }
|
41
|
+
parse_response(res.body)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Converts the API response to a Hash
|
45
|
+
def self.parse_response(raw)
|
46
|
+
result = {}
|
47
|
+
return result if raw.to_s.empty?
|
48
|
+
|
49
|
+
if raw.match(/xml version/)
|
50
|
+
Crack::XML.parse(raw)
|
51
|
+
else
|
52
|
+
# in case of password encrypt/decrypt - '=' should be properly parsed
|
53
|
+
raw.split(';').map do |line|
|
54
|
+
m = /^(\w+)\=(.*)$/.match(line)
|
55
|
+
result[ m[1] ] = m[2]
|
56
|
+
end
|
57
|
+
result
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Fix Net::HTTP so we dont get
|
64
|
+
# warning: peer certificate won't be verified in this SSL session
|
65
|
+
module Net #:nodoc:all
|
66
|
+
class HTTP
|
67
|
+
alias_method :old_initialize, :initialize
|
68
|
+
|
69
|
+
def initialize(*args)
|
70
|
+
old_initialize(*args)
|
71
|
+
@ssl_context = OpenSSL::SSL::SSLContext.new
|
72
|
+
@ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/whmcs/client.rb
ADDED
@@ -0,0 +1,607 @@
|
|
1
|
+
module WHMCS
|
2
|
+
# WHMCS::Client is the class for managing clients
|
3
|
+
class Client < Base
|
4
|
+
|
5
|
+
# Create a new client
|
6
|
+
#
|
7
|
+
# Parameters:
|
8
|
+
# * <tt>:firstname</tt>
|
9
|
+
# * <tt>:lastname</tt>
|
10
|
+
# * <tt>:email</tt>
|
11
|
+
# * <tt>:address1</tt>
|
12
|
+
# * <tt>:city</tt>
|
13
|
+
# * <tt>:state</tt>
|
14
|
+
# * <tt>:postcode</tt>
|
15
|
+
# * <tt>:country</tt> - two letter ISO country code
|
16
|
+
# * <tt>:phonenumber</tt>
|
17
|
+
# * <tt>:password2</tt> - password for new user account
|
18
|
+
#
|
19
|
+
# Optional attributes:
|
20
|
+
# * <tt>:companyname</tt>
|
21
|
+
# * <tt>:address2</tt>
|
22
|
+
# * <tt>:currency</tt> - the ID of the currency to set the user to
|
23
|
+
# * <tt>:clientip</tt> - pass the client IP address
|
24
|
+
# * <tt>:language</tt> - the language to assign to the client
|
25
|
+
# * <tt>:groupid</tt> - used to assign the client to a client group
|
26
|
+
# * <tt>:securityqid</tt> - the ID of the security question for the user
|
27
|
+
# * <tt>:securityqans</tt> - the answer to the client security question
|
28
|
+
# * <tt>:notes</tt>
|
29
|
+
# * <tt>:cctype</tt> - Visa, Mastercard, etc...
|
30
|
+
# * <tt>:cardnum</tt>
|
31
|
+
# * <tt>:expdate</tt>
|
32
|
+
# * <tt>:startdate</tt>
|
33
|
+
# * <tt>:issuenumber</tt>
|
34
|
+
# * <tt>:customfields</tt> - a base64 encoded serialized array of custom field values
|
35
|
+
# * <tt>:noemail</tt> - pass as true to surpress the client signup welcome email sending
|
36
|
+
# * <tt>:skipvalidation</tt> - set true to not validate or check required fields
|
37
|
+
#
|
38
|
+
# *Note*: All client required fields can be optional if "skipvalidation" is passed
|
39
|
+
# See:
|
40
|
+
# http://docs.whmcs.com/API:Add_Client
|
41
|
+
def self.add_client(params = {})
|
42
|
+
params.merge!(:action => 'addclient')
|
43
|
+
send_request(params)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Add Client Note
|
47
|
+
# This command is used to add the Client Note to a specific Client
|
48
|
+
#
|
49
|
+
# Parameters:
|
50
|
+
# * <tt>:userid</tt> - UserID for the note
|
51
|
+
# * <tt>:notes</tt> - The note to add
|
52
|
+
#
|
53
|
+
# See:
|
54
|
+
# http://docs.whmcs.com/API:Add_Client_Note
|
55
|
+
def self.add_client_note(params = {})
|
56
|
+
params.merge!(:action => 'addclientnote')
|
57
|
+
send_request(params)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Close a client account
|
61
|
+
#
|
62
|
+
# Parameters:
|
63
|
+
# * <tt>:clientid</tt>
|
64
|
+
#
|
65
|
+
# See:
|
66
|
+
#
|
67
|
+
# http://docs.whmcs.com/API:Close_Client
|
68
|
+
def self.close_client(params = {})
|
69
|
+
params.merge!(:action => 'closeclient')
|
70
|
+
send_request(params)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Update a client's info
|
74
|
+
# Parameters:
|
75
|
+
# * <tt>:clientid</tt> - Client you wish to update
|
76
|
+
#
|
77
|
+
# Optional attributes:
|
78
|
+
# * <tt>:firstname</tt>
|
79
|
+
# * <tt>:lastname</tt>
|
80
|
+
# * <tt>:companyname</tt>
|
81
|
+
# * <tt>:email</tt>
|
82
|
+
# * <tt>:address1</tt>
|
83
|
+
# * <tt>:address2</tt>
|
84
|
+
# * <tt>:city</tt>
|
85
|
+
# * <tt>:state</tt>
|
86
|
+
# * <tt>:postcode</tt>
|
87
|
+
# * <tt>:country</tt> - two letter ISO country code
|
88
|
+
# * <tt>:phonenumber</tt>
|
89
|
+
# * <tt>:password2</tt>
|
90
|
+
# * <tt>:credit</tt> - credit balance
|
91
|
+
# * <tt>:taxexempt</tt> - true to enable
|
92
|
+
# * <tt>:notes</tt>
|
93
|
+
# * <tt>:cardtype</tt> - visa, mastercard, etc...
|
94
|
+
# * <tt>:cardnum</tt> - cc number
|
95
|
+
# * <tt>:expdate</tt> - cc expiry date
|
96
|
+
# * <tt>:startdate</tt> - cc start date
|
97
|
+
# * <tt>:issuenumber</tt> - cc issue number
|
98
|
+
# * <tt>:language</tt> - default language
|
99
|
+
# * <tt>:status</tt> - active or inactive
|
100
|
+
# * <tt>:latefeeoveride</tt> - true/false
|
101
|
+
# * <tt>:overideduenotices</tt> - true/false
|
102
|
+
# * <tt>:separateinvoices</tt> - true/false
|
103
|
+
# * <tt>:disableautocc</tt> - true/false
|
104
|
+
#
|
105
|
+
# See:
|
106
|
+
#
|
107
|
+
# http://docs.whmcs.com/API:Update_Client
|
108
|
+
def self.update_client(params = {})
|
109
|
+
params.merge!(:action => 'updateclient')
|
110
|
+
send_request(params)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Update Client Addon
|
114
|
+
#
|
115
|
+
# Parameters:
|
116
|
+
#
|
117
|
+
# * <tt>:id</tt> - ID of addon to update tblhostingaddons.id
|
118
|
+
#
|
119
|
+
# Optional attributes:
|
120
|
+
#
|
121
|
+
# * <tt>:addonid</tt> - Update the defined addon id - tbladdons.id
|
122
|
+
# * <tt>:name</tt> - Custom name to define for the addon
|
123
|
+
# * <tt>:setupfee</tt> - Setup fee cost. No symbol,i.e xx.xx
|
124
|
+
# * <tt>:recurring</tt> - Setup fee cost. No symbol,i.e xx.xx
|
125
|
+
# * <tt>:billingcycle</tt> - One of Free Account, One Time, Monthly, Quarterly, Semi-Annually, Annually, Biennially or Triennially
|
126
|
+
# * <tt>:nextduedate</tt> - Update the next due date yyyymmdd
|
127
|
+
# * <tt>:nextinvoicedate</tt> - Update the next invoice date yyyymmdd
|
128
|
+
# * <tt>:notes</tt> - add custom notes to the addon
|
129
|
+
# * <tt>:status</tt> - Pending, Active, Suspended, Cancelled, Terminated, Fraud
|
130
|
+
#
|
131
|
+
# See:
|
132
|
+
# http://docs.whmcs.com/API:Update_Client_Addon
|
133
|
+
def self.update_client_addon(params = {})
|
134
|
+
params.merge!(:action => 'updateclientaddon')
|
135
|
+
send_request(params)
|
136
|
+
end
|
137
|
+
|
138
|
+
# Update Client Domain
|
139
|
+
#
|
140
|
+
# Parameters:
|
141
|
+
# * <tt>:domainid</tt> - ID of domain to update tbldomains.id
|
142
|
+
# * <tt>:domain</tt> - instead of domainid
|
143
|
+
#
|
144
|
+
# Optional attributes:
|
145
|
+
# * <tt>:type</tt> - Register or Transfer
|
146
|
+
# * <tt>:autorecalc</tt> - automatically recalculate the recurring price. Will override recurringamount
|
147
|
+
# * <tt>:regdate</tt> - Update the reg date yyyymmdd
|
148
|
+
# * <tt>:domain</tt> - Update the domain name
|
149
|
+
# * <tt>:firstpaymentamount</tt> - Set the first payment amount. No symbol, i.e xx.xx
|
150
|
+
# * <tt>:recurringamount</tt> - Setup fee cost. No symbol, i.e xx.xx
|
151
|
+
# * <tt>:registrar</tt> - Update the registrar assigned to the domain
|
152
|
+
# * <tt>:billingcycle</tt> - One of Free Account, One Time, Monthly, Quarterly, Semi-Annually, Annually, Biennially or Triennially
|
153
|
+
# * <tt>:status</tt> - One of Active, Pending, Pending Transfer, Expired, Cancelled, Fraud
|
154
|
+
# * <tt>:nextduedate</tt> - Update the next due date yyyymmdd
|
155
|
+
# * <tt>:nextinvoicedate</tt> - Update the next invoice date yyyymmdd
|
156
|
+
# * <tt>:expirydate</tt> - Update the expiry date yyyymmdd
|
157
|
+
# * <tt>:regperiod</tt> - Update the reg period for the domain. 1-10
|
158
|
+
# * <tt>:paymentmethod</tt> - set the payment method
|
159
|
+
# * <tt>:subscriptionid</tt> - allocate a subscription ID
|
160
|
+
# * <tt>:dnsmanagement</tt> - enable/disable DNS Management
|
161
|
+
# * <tt>:emailforwarding</tt> - enable/disable Email Forwarding
|
162
|
+
# * <tt>:idprotection</tt> - enable/disable ID Protection status
|
163
|
+
# * <tt>:donotrenew</tt> - enable/disable Do Not Renew
|
164
|
+
# * <tt>:updatens</tt> - Set to true to update Nameservers
|
165
|
+
# * <tt>:nsX</tt> - X should be 1-5, nameservers to send. Minimum 1&2 required
|
166
|
+
# * <tt>:notes</tt> - add custom notes to the addon
|
167
|
+
#
|
168
|
+
# See:
|
169
|
+
# http://docs.whmcs.com/API:Update_Client_Domain
|
170
|
+
def self.update_client_domain(params = {})
|
171
|
+
params.merge!(:action => 'updateclientdomain')
|
172
|
+
send_request(params)
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
# Delete a client
|
177
|
+
#
|
178
|
+
# Parameters:
|
179
|
+
#
|
180
|
+
# * <tt>:clientid</tt> - ID Number of the client to delete
|
181
|
+
#
|
182
|
+
# See:
|
183
|
+
#
|
184
|
+
# http://docs.whmcs.com/API:Delete_Client
|
185
|
+
def self.delete_client(params = {})
|
186
|
+
params.merge!(:action => 'deleteclient')
|
187
|
+
send_request(params)
|
188
|
+
end
|
189
|
+
|
190
|
+
# Get multiple clients
|
191
|
+
#
|
192
|
+
# Parameters:
|
193
|
+
#
|
194
|
+
# * <tt>:limitstart</tt> - Record to start at (default = 0)
|
195
|
+
# * <tt>:limitnum</tt> - Number of records to return (default = 25)
|
196
|
+
# * <tt>:search</tt> - Can be passed to filter for clients with a name/email matching the term entered
|
197
|
+
#
|
198
|
+
# See:
|
199
|
+
#
|
200
|
+
# http://docs.whmcs.com/API:Get_Clients
|
201
|
+
def self.get_clients(params = {})
|
202
|
+
params.merge!(:action => 'getclients')
|
203
|
+
send_request(params)
|
204
|
+
end
|
205
|
+
|
206
|
+
# Get Client Credits
|
207
|
+
#
|
208
|
+
# Parameters:
|
209
|
+
# * <tt>:clientid</tt>
|
210
|
+
#
|
211
|
+
# See:
|
212
|
+
# http://docs.whmcs.com/API:Get_Credits
|
213
|
+
def self.get_credits(params = {})
|
214
|
+
params.merge!(:action => 'getcredits')
|
215
|
+
send_request(params)
|
216
|
+
end
|
217
|
+
|
218
|
+
# Get Clients Addons
|
219
|
+
#
|
220
|
+
# Parameters:
|
221
|
+
# * <tt>:clientid</tt> - The Client ID you wish to obtain the results for
|
222
|
+
# * <tt>:addonid</tt> - The specific addonid you wish to find
|
223
|
+
# * <tt>:serviceid</tt> - The specific, or comma separated list of, service(s)
|
224
|
+
#
|
225
|
+
# See:
|
226
|
+
# http://docs.whmcs.com/API:Get_Clients_Addons
|
227
|
+
def get_clients_addons(params = {})
|
228
|
+
params.merge!(:action => 'getclientsaddons')
|
229
|
+
send_request(params)
|
230
|
+
end
|
231
|
+
|
232
|
+
# Get a client's info
|
233
|
+
#
|
234
|
+
# Parameters:
|
235
|
+
#
|
236
|
+
# * <tt>:clientid</tt> - the id number of the client
|
237
|
+
# * <tt>:email</tt> - the email address of the client
|
238
|
+
#
|
239
|
+
# Optional attributes:
|
240
|
+
# * <tt>:stats</tt> - true - If the responsetype of your API call is not XML,
|
241
|
+
# stats are not returned unless this variable is passed
|
242
|
+
#
|
243
|
+
# See:
|
244
|
+
# http://docs.whmcs.com/API:Get_Clients_Details
|
245
|
+
def self.get_clients_details(params = {})
|
246
|
+
params.merge!(:action => 'getclientsdetails')
|
247
|
+
send_request(params)
|
248
|
+
end
|
249
|
+
|
250
|
+
# Get a hash of a client's password
|
251
|
+
#
|
252
|
+
# Parameters:
|
253
|
+
# * <tt>:userid</tt> - should contain the user id of the client you wish to get the password for
|
254
|
+
#
|
255
|
+
# Optional attributes:
|
256
|
+
# * <tt>:email</tt> - send email address instead of userid
|
257
|
+
#
|
258
|
+
# See:
|
259
|
+
#
|
260
|
+
# http://docs.whmcs.com/API:Get_Clients_Password
|
261
|
+
def self.get_clients_password(params = {})
|
262
|
+
params.merge!(:action => 'getclientpassword')
|
263
|
+
send_request(params)
|
264
|
+
end
|
265
|
+
|
266
|
+
# Add a client contact
|
267
|
+
#
|
268
|
+
# Parameters:
|
269
|
+
#
|
270
|
+
# * <tt>:clientid</tt> - the client ID to add the contact to
|
271
|
+
#
|
272
|
+
# Optional attributes:
|
273
|
+
# * <tt>:firstname</tt>
|
274
|
+
# * <tt>:lastname</tt>
|
275
|
+
# * <tt>:companyname</tt>
|
276
|
+
# * <tt>:email</tt>
|
277
|
+
# * <tt>:address1</tt>
|
278
|
+
# * <tt>:address2</tt>
|
279
|
+
# * <tt>:city</tt>
|
280
|
+
# * <tt>:state</tt>
|
281
|
+
# * <tt>:postcode</tt>
|
282
|
+
# * <tt>:country</tt> - two letter ISO country code
|
283
|
+
# * <tt>:phonenumber</tt>
|
284
|
+
# * <tt>:password2</tt> - if creating a sub-account
|
285
|
+
# * <tt>:permissions</tt> - can specify sub-account permissions eg manageproducts,managedomains
|
286
|
+
# * <tt>:generalemails</tt> - set true to receive general email types
|
287
|
+
# * <tt>:productemails</tt> - set true to receive product related emails
|
288
|
+
# * <tt>:domainemails</tt> - set true to receive domain related emails
|
289
|
+
# * <tt>:invoiceemails</tt> - set true to receive billing related emails
|
290
|
+
# * <tt>:supportemails</tt> - set true to receive support ticket related emails
|
291
|
+
#
|
292
|
+
# See:
|
293
|
+
#
|
294
|
+
# http://docs.whmcs.com/API:Add_Contact
|
295
|
+
def self.add_contact(params = {})
|
296
|
+
params.merge!(:action => 'addcontact')
|
297
|
+
send_request(params)
|
298
|
+
end
|
299
|
+
|
300
|
+
# Add Cancel Request
|
301
|
+
# This command is used to Add Cancellation Request for a specific product
|
302
|
+
#
|
303
|
+
# Parameters:
|
304
|
+
# * <tt>:serviceid</tt> - Service ID to be cancelled
|
305
|
+
# * <tt>:type</tt> - 'Immediate' OR 'End of Billing Period'
|
306
|
+
#
|
307
|
+
# Optional attributes:
|
308
|
+
# * <tt>:reason</tt> - Reason for cancel
|
309
|
+
#
|
310
|
+
# See:
|
311
|
+
# http://docs.whmcs.com/API:Add_Cancel_Request
|
312
|
+
def self.add_cancel_request(params = {})
|
313
|
+
params.merge!(:action => 'addcancelrequest')
|
314
|
+
send_request(params)
|
315
|
+
end
|
316
|
+
|
317
|
+
# Get client's contacts
|
318
|
+
#
|
319
|
+
# Optional attributes:
|
320
|
+
#
|
321
|
+
# * <tt>:limitstart</tt> - Record to start at (default = 0)
|
322
|
+
# * <tt>:limitnum</tt> - Number of records to return (default = 25)
|
323
|
+
# * <tt>:userid</tt>
|
324
|
+
# * <tt>:firstname</tt>
|
325
|
+
# * <tt>:lastname</tt>
|
326
|
+
# * <tt>:companyname</tt>
|
327
|
+
# * <tt>:email</tt>
|
328
|
+
# * <tt>:address1</tt>
|
329
|
+
# * <tt>:address2</tt>
|
330
|
+
# * <tt>:city</tt>
|
331
|
+
# * <tt>:state</tt>
|
332
|
+
# * <tt>:postcode</tt>
|
333
|
+
# * <tt>:country</tt>
|
334
|
+
# * <tt>:phonenumber</tt>
|
335
|
+
# * <tt>:subaccount</tt> - true/false
|
336
|
+
#
|
337
|
+
# See:
|
338
|
+
#
|
339
|
+
# http://docs.whmcs.com/API:Get_Contacts
|
340
|
+
def self.get_contacts(params = {})
|
341
|
+
params.merge!(:action => 'getcontacts')
|
342
|
+
send_request(params)
|
343
|
+
end
|
344
|
+
|
345
|
+
# Update a client's contact
|
346
|
+
#
|
347
|
+
# Parameters:
|
348
|
+
#
|
349
|
+
# * <tt>:contactid</tt> - The ID of the contact to delete
|
350
|
+
#
|
351
|
+
# Optional attributes:
|
352
|
+
# * <tt>:generalemails</tt> - set to true to receive general emails
|
353
|
+
# * <tt>:productemails</tt> - set to true to receive product emails
|
354
|
+
# * <tt>:domainemails</tt> - set to true to receive domain emails
|
355
|
+
# * <tt>:invoiceemails</tt> - set to true to receive invoice emails
|
356
|
+
# * <tt>:supportemails</tt> - set to true to receive support emails
|
357
|
+
# * <tt>:firstname</tt> - change the firstname
|
358
|
+
# * <tt>:lastname</tt> - change the lastname
|
359
|
+
# * <tt>:companyname</tt> - change the companyname
|
360
|
+
# * <tt>:email</tt> - change the email address
|
361
|
+
# * <tt>:address1</tt> - change address1
|
362
|
+
# * <tt>:address2</tt> - change address2
|
363
|
+
# * <tt>:city</tt> - change city
|
364
|
+
# * <tt>:state</tt> - change state
|
365
|
+
# * <tt>:postcode</tt> - change postcode
|
366
|
+
# * <tt>:country</tt> - change country
|
367
|
+
# * <tt>:phonenumber</tt> - change phonenumber
|
368
|
+
# * <tt>:subaccount</tt> - enable subaccount
|
369
|
+
# * <tt>:password2</tt> - change the password
|
370
|
+
# * <tt>:permissions</tt> - set permissions eg manageproducts,managedomains
|
371
|
+
#
|
372
|
+
# Only send fields you wish to update
|
373
|
+
#
|
374
|
+
# See:
|
375
|
+
#
|
376
|
+
# http://docs.whmcs.com/API:Update_Contact
|
377
|
+
def self.update_contact(params = {})
|
378
|
+
params.merge!(:action => 'updatecontact')
|
379
|
+
send_request(params)
|
380
|
+
end
|
381
|
+
|
382
|
+
# Upgrade Product
|
383
|
+
#
|
384
|
+
# This command allows you to calculate the cost for an upgrade or downgrade of a product/service, and create an order for it.
|
385
|
+
#
|
386
|
+
# Parameters:
|
387
|
+
# * <tt>:clientid</tt> - the client ID to be upgraded
|
388
|
+
# * <tt>:serviceid</tt> - the service ID to be upgraded
|
389
|
+
# * <tt>:type</tt> - either "product" or "configoptions"
|
390
|
+
# * <tt>:newproductid</tt> - if upgrade type = product, the new product ID to upgrade to
|
391
|
+
# * <tt>:newproductbillingcycle</tt> - monthly, quarterly, etc...
|
392
|
+
# * <tt>:configoptions[x]</tt> - if upgrade type = configoptions, an array of config options
|
393
|
+
# * <tt>:paymentmethod</tt> - the payment method for the order (paypal, authorize, etc...)
|
394
|
+
#
|
395
|
+
# Optional attributes:
|
396
|
+
# * <tt>:promocode</tt> - associate a promotion code with the upgrade
|
397
|
+
# * <tt>:calconly</tt> - set true to validate upgrade and get price, false to actually create order
|
398
|
+
# * <tt>:ordernotes</tt> - any admin notes to add to the order
|
399
|
+
# See:
|
400
|
+
#
|
401
|
+
# http://docs.whmcs.com/API:Upgrade_Product
|
402
|
+
def self.upgrade_product(params = {})
|
403
|
+
params.merge!(:action => 'upgradeproduct')
|
404
|
+
send_request(params)
|
405
|
+
end
|
406
|
+
|
407
|
+
|
408
|
+
# Delete a client's contact
|
409
|
+
#
|
410
|
+
# Parameters:
|
411
|
+
#
|
412
|
+
# * <tt>:contactid</tt> - The ID of the contact to delete
|
413
|
+
#
|
414
|
+
# See:
|
415
|
+
#
|
416
|
+
# http://docs.whmcs.com/API:Delete_Contact
|
417
|
+
def self.delete_contact(params = {})
|
418
|
+
params.merge!(:action => 'deletecontact')
|
419
|
+
send_request(params)
|
420
|
+
end
|
421
|
+
|
422
|
+
# Get client's products
|
423
|
+
#
|
424
|
+
# Optional attributes:
|
425
|
+
#
|
426
|
+
# * <tt>:clientid</tt> - the ID of the client to retrieve products for
|
427
|
+
# * <tt>:serviceid</tt> - the ID of the service to retrieve details for
|
428
|
+
# * <tt>:domain</tt> - the domain of the service to retrieve details for
|
429
|
+
# * <tt>:pid</tt> - the product ID of the services to retrieve products for
|
430
|
+
# * <tt>:username2</tt> - the service username to retrieve details for
|
431
|
+
# * <tt>:limitstart</tt> - where to start the records. Used for pagination
|
432
|
+
# * <tt>:limitnum</tt> - the number of records to retrieve. Default = 999999
|
433
|
+
#
|
434
|
+
# See:
|
435
|
+
#
|
436
|
+
# http://docs.whmcs.com/API:Get_Clients_Products
|
437
|
+
def self.get_clients_products(params = {})
|
438
|
+
params.merge!(:action => 'getclientsproducts')
|
439
|
+
send_request(params)
|
440
|
+
end
|
441
|
+
|
442
|
+
# Get Clients Domains
|
443
|
+
#
|
444
|
+
# * <tt>:clientid</tt> - the ID of the client to retrieve products for
|
445
|
+
#
|
446
|
+
# Optional attributes:
|
447
|
+
# * <tt>:domainid</tt> - the ID of the domain to retrieve details for
|
448
|
+
# * <tt>:domain</tt> - the domain of the service to retrieve details for
|
449
|
+
# * <tt>:limitstart</tt> - where to start the records. Used for pagination
|
450
|
+
# * <tt>:limitnum</tt> - the number of records to retrieve. Default = 25
|
451
|
+
# * <tt>:getnameservers</tt> - retrieve nameservers in the response
|
452
|
+
#
|
453
|
+
# See:
|
454
|
+
#
|
455
|
+
# http://docs.whmcs.com/API:Get_Clients_Domains
|
456
|
+
def self.get_clients_domains(params = {})
|
457
|
+
params.merge!(:action => 'getclientsdomains')
|
458
|
+
send_request(params)
|
459
|
+
end
|
460
|
+
|
461
|
+
# Update client's product
|
462
|
+
#
|
463
|
+
# Parameters:
|
464
|
+
#
|
465
|
+
# * <tt>:serviceid</tt> - the ID of the service to be updated
|
466
|
+
#
|
467
|
+
# Optional attributes:
|
468
|
+
# * <tt>:pid</tt>
|
469
|
+
# * <tt>:serverid</tt>
|
470
|
+
# * <tt>:regdate</tt> - Format: YYYY-MM-DD
|
471
|
+
# * <tt>:nextduedate</tt> - Format: YYYY-MM-DD
|
472
|
+
# * <tt>:domain</tt>
|
473
|
+
# * <tt>:firstpaymentamount</tt>
|
474
|
+
# * <tt>:recurringamount</tt>
|
475
|
+
# * <tt>:billingcycle</tt>
|
476
|
+
# * <tt>:paymentmethod</tt>
|
477
|
+
# * <tt>:status</tt>
|
478
|
+
# * <tt>:serviceusername</tt>
|
479
|
+
# * <tt>:servicepassword</tt>
|
480
|
+
# * <tt>:subscriptionid</tt>
|
481
|
+
# * <tt>:promoid</tt>
|
482
|
+
# * <tt>:overideautosuspend</tt> - on/off
|
483
|
+
# * <tt>:overidesuspenduntil</tt> - Format: YYYY-MM-DD
|
484
|
+
# * <tt>:ns1</tt>
|
485
|
+
# * <tt>:ns2</tt>
|
486
|
+
# * <tt>:dedicatedip</tt>
|
487
|
+
# * <tt>:assignedips</tt>
|
488
|
+
# * <tt>:notes</tt>
|
489
|
+
# * <tt>:autorecalc</tt> - pass true to auto set price based on product ID or billing cycle change
|
490
|
+
# * <tt>:customfields</tt> - a base64 encoded serialized array of custom field values
|
491
|
+
# * <tt>:configoptions</tt> - a base64 encoded serialized array of configurable options values
|
492
|
+
#
|
493
|
+
# See:
|
494
|
+
#
|
495
|
+
# http://docs.whmcs.com/API:Update_Client_Product
|
496
|
+
def self.update_client_product(params = {})
|
497
|
+
params.merge!(:action => 'updateclientproduct')
|
498
|
+
send_request(params)
|
499
|
+
end
|
500
|
+
|
501
|
+
# Validate client login info
|
502
|
+
#
|
503
|
+
# Parameters:
|
504
|
+
#
|
505
|
+
# * <tt>:email</tt> - the email address of the user trying to login
|
506
|
+
# * <tt>:password2</tt> - the password they supply for authentication
|
507
|
+
#
|
508
|
+
# See:
|
509
|
+
#
|
510
|
+
# http://docs.whmcs.com/API:Validate_Login
|
511
|
+
def self.validate_login(params = {})
|
512
|
+
params.merge!(:action => 'validatelogin')
|
513
|
+
send_request(params)
|
514
|
+
end
|
515
|
+
|
516
|
+
# Send email to client
|
517
|
+
#
|
518
|
+
# Parameters:
|
519
|
+
#
|
520
|
+
# * <tt>:messagename</tt> - unique name of the email template to send from WHMCS
|
521
|
+
# * <tt>:id</tt> - related ID number to send message for
|
522
|
+
# (for a general email type a client ID, for a product email type the products Service ID, etc...)
|
523
|
+
#
|
524
|
+
# Optional attributes:
|
525
|
+
# * <tt>:customtype</tt> - The type of email: general, product, domain or invoice
|
526
|
+
# * <tt>:customsubject</tt> - Subject for the custom email being sent
|
527
|
+
# * <tt>:custommessage</tt> - Content to send as an email, this will override 'messagename' if set
|
528
|
+
# * <tt>:customvars</tt> - serialized base64 encoded array of custom variables
|
529
|
+
#
|
530
|
+
# See:
|
531
|
+
#
|
532
|
+
# http://docs.whmcs.com/API:Send_Email
|
533
|
+
def self.send_email(params = {})
|
534
|
+
params.merge!(:action => 'sendemail')
|
535
|
+
send_request(params)
|
536
|
+
end
|
537
|
+
|
538
|
+
# Get Emails
|
539
|
+
# This command is used to get a list of the client emails in XML format
|
540
|
+
#
|
541
|
+
# Parameters:
|
542
|
+
# * <tt>:clientid</tt> - ID of the client to obtain the credit list for
|
543
|
+
#
|
544
|
+
# Optional attributes:
|
545
|
+
# * <tt>:date</tt> - date to obtain emails for. Can be YYYYMMDD, YYYYMM, MMDD, DD or MM
|
546
|
+
# * <tt>:subject</tt> - to obtain email with a specific subject
|
547
|
+
# * <tt>:limitstart</tt> - for pagination, specify an ID to start at (default = 0)
|
548
|
+
# * <tt>:limitnum</tt> - to restrict the number of results returned (default = 25)
|
549
|
+
def self.get_emails(params = {})
|
550
|
+
params.merge!(:action => 'getemails')
|
551
|
+
send_request(params)
|
552
|
+
end
|
553
|
+
|
554
|
+
|
555
|
+
# Get Transactions
|
556
|
+
# This command is used to obtain an XML list of transactions from your WHMCS
|
557
|
+
#
|
558
|
+
# Optional attributes:
|
559
|
+
# * <tt>:clientid</tt> - User ID to obtain details for
|
560
|
+
# * <tt>:invoiceid</tt> - Obtain transactions for a specific invoice
|
561
|
+
# * <tt>:transid</tt> - Obtain details for a specific transaction ID
|
562
|
+
#
|
563
|
+
# See:
|
564
|
+
# http://docs.whmcs.com/API:Get_Transactions
|
565
|
+
def self.get_transactions(params = {})
|
566
|
+
params.merge!(:action => 'gettransactions')
|
567
|
+
send_request(params)
|
568
|
+
end
|
569
|
+
|
570
|
+
|
571
|
+
# Get Quotes
|
572
|
+
#
|
573
|
+
# Parameters:
|
574
|
+
# * <tt>:userid</tt>
|
575
|
+
#
|
576
|
+
# Optional attributes:
|
577
|
+
# * <tt>:quoteid</tt> - specific quote to obtain
|
578
|
+
# * <tt>:userid</tt> - obtain quotes for a specific user
|
579
|
+
# * <tt>:datecreated</tt> - Format YYYYMMDD
|
580
|
+
# * <tt>:astmodified</tt> - Format YYYYMMDD
|
581
|
+
# * <tt>:validuntil</tt> - Format YYYYMMDD
|
582
|
+
# * <tt>:stage</tt> - Specific stage to retrieve quotes for
|
583
|
+
# * <tt>:subject</tt> - to obtain quotes with a specific subject
|
584
|
+
# * <tt>:limitstart</tt> - for pagination, specify an ID to start at
|
585
|
+
# * <tt>:limitnum</tt> - to restrict the number of results returned
|
586
|
+
#
|
587
|
+
# See:
|
588
|
+
#
|
589
|
+
# http://docs.whmcs.com/API:Get_Quotes
|
590
|
+
def self.get_quotes(params = {})
|
591
|
+
params.merge!(:action => 'getquotes')
|
592
|
+
send_request(params)
|
593
|
+
end
|
594
|
+
|
595
|
+
# Get Client Groups
|
596
|
+
#
|
597
|
+
# This command is used to get a list of the client groups in XML format
|
598
|
+
#
|
599
|
+
# See:
|
600
|
+
#
|
601
|
+
# http://docs.whmcs.com/API:Get_Client_Groups
|
602
|
+
def self.get_client_groups
|
603
|
+
send_request(:action => 'getclientgroups')
|
604
|
+
end
|
605
|
+
|
606
|
+
end
|
607
|
+
end
|