whmcs-api 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,266 @@
1
+ module WHMCS
2
+ # The WHMCS::Misc class contains miscelaneous WHMCS API functions
3
+ class Misc < Base
4
+
5
+ # Get activity log
6
+ #
7
+ # Optional attributes:
8
+ #
9
+ # * <tt>:limitstart</tt> - Which User ID to start at (default = 0)
10
+ # * <tt>:limitnum</tt> - Limit by number (default = 25)
11
+ #
12
+ # See:
13
+ #
14
+ # http://docs.whmcs.com/API:Get_Activity_Log
15
+ def self.get_activity_log(params = {})
16
+ params.merge!(:action => 'getactivitylog')
17
+ send_request(params)
18
+ end
19
+
20
+ # Get administrator details
21
+ #
22
+ # See:
23
+ #
24
+ # http://docs.whmcs.com/API:Get_Admin_Details
25
+ def self.get_admin_details
26
+ send_request(:action => 'getadmindetails')
27
+ end
28
+
29
+ # Update administrator notes
30
+ #
31
+ # Parameters:
32
+ #
33
+ # * <tt>:notes</tt> - notes to enter
34
+ #
35
+ # See:
36
+ #
37
+ # http://docs.whmcs.com/API:Update_Admin_Notes
38
+ def self.update_admin_notes(params = {})
39
+ params.merge!(:action => 'updateadminnotes')
40
+ send_request(params)
41
+ end
42
+
43
+ # Up To-Do Item
44
+ #
45
+ # Parameter:
46
+ # * <tt>:itemid</tt> - ID of the ToDo in WHMCS to update
47
+ # * <tt>:adminid</tt> - Admin ID to update the To Do item to
48
+ #
49
+ # Optional attributes:
50
+ # * <tt>:date</tt> - open date of the To Do YYYYMMDD
51
+ # * <tt>:title</tt> - Title of the to do
52
+ # * <tt>:description</tt> - Text of the To Do
53
+ # * <tt>:status</tt> - Status - New, Pending, In Progress, Completed, Postponed
54
+ # * <tt>:duedate</tt> - due date of the To Do YYYYMMDD
55
+ #
56
+ # See:
57
+ #
58
+ # http://docs.whmcs.com/API:Update_To-Do_Item
59
+ def self.update_todo_item(params = {})
60
+ params.merge!(:action => 'updatetodoitem')
61
+ send_request(params)
62
+ end
63
+
64
+ # Get allowed currencies
65
+ #
66
+ # See:
67
+ #
68
+ # http://docs.whmcs.com/API:Get_Currencies
69
+ def self.get_currencies
70
+ params.merge!(:action => 'getcurrencies')
71
+ send_request(params)
72
+ end
73
+
74
+ # Get promotions
75
+ #
76
+ # Note: WHMCS has this listed under Misc as well as invoices. It's
77
+ # aliased here for consistancy with their API docs
78
+ #
79
+ # Parameters:
80
+ #
81
+ # * <tt>:code</tt> - the specific promotion code to return information for (optional)
82
+ #
83
+ # See:
84
+ #
85
+ # http://docs.whmcs.com/API:Get_Promotions
86
+ def self.get_promotions(params = {})
87
+ params.merge!(:action => 'getpromotions')
88
+ send_request(params)
89
+ end
90
+
91
+ # Get email templates
92
+ #
93
+ # Optional attributes:
94
+ #
95
+ # * <tt>:type</tt> - optional - from product,domain,support,general,invoice,affiliate
96
+ # * <tt>:language</tt> - optional - only required for additional languages
97
+ #
98
+ # See:
99
+ #
100
+ # http://docs.whmcs.com/API:Get_Email_Templates
101
+ def self.get_email_templates(params = {})
102
+ params.merge!(:action => 'getemailtemplates')
103
+ send_request(params)
104
+ end
105
+
106
+ # Get todo items
107
+ #
108
+ # Optional attributes:
109
+ # * <tt>:status</tt> - optional - from New,Pending,In Progress,Completed,Postponed
110
+ # * <tt>:limitstart</tt> - where to start the output. Used for pagination. (default = 0)
111
+ # * <tt>:limitnum</tt> - limit the number of records returned (default = 25)
112
+ #
113
+ # See:
114
+ #
115
+ # http://docs.whmcs.com/API:Get_To-Do_Items
116
+ def self.get_todo_items(params = {})
117
+ params.merge!(:action => 'gettodoitems')
118
+ send_request(params)
119
+ end
120
+
121
+ # Get configured todo item statuses
122
+ #
123
+ # See:
124
+ #
125
+ # http://docs.whmcs.com/API:Get_To-Do_Items_Statuses
126
+ def self.get_todo_item_statuses
127
+ send_request(:action => 'gettodoitemstatuses')
128
+ end
129
+
130
+ # Get staff online
131
+ #
132
+ # See:
133
+ #
134
+ # http://docs.whmcs.com/API:Get_Staff_Online
135
+ def self.get_staff_online
136
+ send_request(:action => 'getstaffonline')
137
+ end
138
+
139
+ # Get stats
140
+ #
141
+ # See:
142
+ #
143
+ # http://docs.whmcs.com/API:Get_Stats
144
+ def self.get_stats
145
+ send_request(:action => 'getstats')
146
+ end
147
+
148
+ # Encrypt a password with the WHMCS algorithm
149
+ #
150
+ # Parameters:
151
+ #
152
+ # * <tt>:password2</tt> - should contain the string you want encrypting
153
+ #
154
+ # See:
155
+ #
156
+ # http://docs.whmcs.com/API:Encrypt_Password
157
+ def self.encrypt_password(params = {})
158
+ params.merge!(:action => 'encryptpassword')
159
+ send_request(params)
160
+ end
161
+
162
+ # Decrypt a string with the WHMCS algorithm
163
+ #
164
+ # This command is used to decrypt a string using the WHMCS encryption algorithm.
165
+ # This cannot be used to decrypt the clients password when using the MD5 Client passwords.
166
+ #
167
+ # Parameters:
168
+ #
169
+ # * <tt>:password2</tt> - should contain the string you want decrypting
170
+ #
171
+ # See:
172
+ #
173
+ # http://docs.whmcs.com/API:Decrypt_Password
174
+ def self.decrypt_password(params = {})
175
+ params.merge!(:action => 'decryptpassword')
176
+ send_request(params)
177
+ end
178
+
179
+ # Add Product
180
+ #
181
+ # Parameters:
182
+ # * <tt>:type</tt> one of hostingaccount, reselleraccount, server or other
183
+ # * <tt>:gid</tt> - the product group ID to add it to
184
+ # * <tt>:name</tt> - the product name
185
+ # * <tt>:paytype</tt> - free, onetime or recurring
186
+ #
187
+ # Optional attributes:
188
+ # * <tt>:description</tt> - the product description
189
+ # * <tt>:hidden</tt> - set true to hide
190
+ # * <tt>:showdomainoptions</tt> - set true to show
191
+ # * <tt>:welcomeemail</tt> - the email template ID for a welcome email
192
+ # * <tt>:qty</tt> - set quantity to enable stock control
193
+ # * <tt>:proratadate</tt>
194
+ # * <tt>:proratachargenextmonth</tt>
195
+ # * <tt>:autosetup</tt> - on, payment, order or blank for none
196
+ # * <tt>:module</tt> - module name
197
+ # * <tt>:servergroupid</tt> - server group ID
198
+ # * <tt>:subdomain</tt> - subdomain to offer with product
199
+ # * <tt>:tax</tt> - set true to apply tax
200
+ # * <tt>:order</tt> - display sort order to override default
201
+ # * <tt>:configoption1</tt>
202
+ # * <tt>:configoption2</tt>
203
+ # * <tt>:pricing</tt>
204
+ #
205
+ # See:
206
+ #
207
+ # http://docs.whmcs.com/API:Add_Product
208
+ def self.add_product(params = {})
209
+ params.merge!(:action => 'addproduct')
210
+ send_request(params)
211
+ end
212
+
213
+ # Log Activity
214
+ #
215
+ # Parameters:
216
+ # * <tt>:description</tt> - Text to add to the log
217
+ # Optional attributes:
218
+ # * <tt>:userid</tt> - UserID to assign the log to in order to appear in Client Log
219
+ #
220
+ # See:
221
+ #
222
+ # http://docs.whmcs.com/API:Log_Activity
223
+ def self.log_activity(params = {})
224
+ params.merge!(:action => 'logactivity')
225
+ send_request(params)
226
+ end
227
+
228
+ # Add Banned IP
229
+ #
230
+ # Parameters:
231
+ # * <tt>:ip</tt> - IP address to ban
232
+ # Optional attributes:
233
+ # * <tt>:reason</tt> - reason for ban
234
+ # * <tt>:days</tt> - number of days to ban for. If not submitted defaults to 7 (not required)
235
+ # * <tt>:expires</tt> - in YYYY-MM-DD HH:II:SS format eg: 2011-06-06 01:12:34 (optional in place of "days")
236
+ #
237
+ # See:
238
+ #
239
+ # http://docs.whmcs.com/API:Add_Banned_IP
240
+ def self.add_banned_ip(params = {})
241
+ params.merge!(:action => 'addbannedip')
242
+ send_request(params)
243
+ end
244
+
245
+ # Send Admin Email
246
+ # This command is used to send an email to Admin users
247
+ #
248
+ # Parameters:
249
+ # * <tt>:messagename</tt> - Name of the Admin email template to send
250
+ # * <tt>:mergefields</tt> - array of merge fields to populate the template being sent
251
+ # * <tt>:type</tt> - Who to send the email to. One of system, account or support. Default: system
252
+ #
253
+ # Optional attributes:
254
+ # * <tt>:customsubject</tt> - Subject for a custommessage being sent
255
+ # * <tt>:custommessage</tt> - Send a custom email to admin users, this will override 'messagename'
256
+ # * <tt>:deptid</tt> - If type = support, the users of a department to send email to
257
+ #
258
+ # See:
259
+ #
260
+ # http://docs.whmcs.com/API:Send_Admin_Email
261
+ def self.send_admin_email(params = {})
262
+ params.merge!(:action => 'sendadminemail')
263
+ send_request(params)
264
+ end
265
+ end
266
+ end
@@ -0,0 +1,99 @@
1
+ module WHMCS
2
+ # WHMCS::Module is the class for working with hosting account modules
3
+ class Module < Base
4
+
5
+ # Run the module create command
6
+ #
7
+ # Parameters:
8
+ #
9
+ # * <tt>:accountid</tt> - the unique id number of the account in the tblhosting table
10
+ #
11
+ # See:
12
+ #
13
+ # http://docs.whmcs.com/API:Module_Create
14
+ def self.module_create(params = {})
15
+ params.merge!(:action => 'modulecreate')
16
+ send_request(params)
17
+ end
18
+
19
+ # Run the module suspend command
20
+ #
21
+ # Parameters:
22
+ #
23
+ # * <tt>:accountid</tt> - the unique id number of the account in the tblhosting table
24
+ #
25
+ # Optional attributes:
26
+ # * <tt>:suspendreason</tt> - an explanation of why the suspension has been made shown to clients & staff
27
+ #
28
+ # See:
29
+ #
30
+ # http://docs.whmcs.com/API:Module_Suspend
31
+ def self.module_suspend(params = {})
32
+ params.merge!(:action => 'modulesuspend')
33
+ send_request(params)
34
+ end
35
+
36
+ # Run the module unsuspend command
37
+ #
38
+ # Parameters:
39
+ #
40
+ # * <tt>:accountid</tt> - the unique id number of the account in the tblhosting table
41
+ #
42
+ # See:
43
+ #
44
+ # http://docs.whmcs.com/API:Module_Unsuspend
45
+ def self.module_unsuspend(params = {})
46
+ params.merge!(:action => 'moduleunsuspend')
47
+ send_request(params)
48
+ end
49
+
50
+ # Run the module terminate command
51
+ #
52
+ # Parameters:
53
+ #
54
+ # * <tt>:accountid</tt> - the unique id number of the account in the tblhosting table
55
+ #
56
+ # See:
57
+ #
58
+ # http://docs.whmcs.com/API:Module_Terminate
59
+ def self.module_terminate(params = {})
60
+ params.merge!(:action => 'moduleterminate')
61
+ send_request(params)
62
+ end
63
+
64
+ # Module Change Package
65
+ #
66
+ # This command is used to run the change package module command
67
+ #
68
+ # Parameters:
69
+ #
70
+ # *<tt>:serviceid</tt> - ID of the service in WHMCS to run the module command
71
+ #
72
+ # See:
73
+ #
74
+ # http://docs.whmcs.com/API:Module_Change_Package
75
+ def self.module_change_package(params = {})
76
+ params.merge!(:action => 'modulechangepackage')
77
+ send_request(params)
78
+ end
79
+
80
+ # Module Change Password
81
+ #
82
+ # This command is used to issue the change password command to the module for a service.
83
+ #
84
+ # Params:
85
+ # * <tt>:serviceid</tt> - the unique id of the service to perform the action on (aka tblhosting.id)
86
+ #
87
+ # Optional attributes:
88
+ #
89
+ # * <tt>:servicepassword</tt> - Specify to update the password on the service before calling
90
+ #
91
+ # See:
92
+ #
93
+ # http://docs.whmcs.com/API:Module_Change_Password
94
+ def self.module_change_password(params = {})
95
+ params.merge!(:action => 'modulechangepw')
96
+ send_request(params)
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,195 @@
1
+ module WHMCS
2
+ # WHMCS::Order is the class for managing orders
3
+ class Order < Base
4
+
5
+ # Create a new order
6
+ #
7
+ # Parameters:
8
+ #
9
+ # * <tt>:clientid</tt> - client id for order
10
+ # * <tt>:pid</tt> - product id
11
+ # * <tt>:domain</tt> - domain name
12
+ # * <tt>:billingcycle</tt> - onetime, monthly, quarterly, semiannually, etc..
13
+ # * <tt>:domaintype</tt> - set for domain registration - register or transfer
14
+ # * <tt>:regperiod</tt> - 1,2,3,etc...
15
+ # * <tt>:eppcode</tt> - if transfer
16
+ # * <tt>:nameserver1</tt> - first nameserver (req for domain reg only)
17
+ # * <tt>:paymentmethod</tt> - paypal, authorize, etc...
18
+ #
19
+ # Optional attributes:
20
+ # * <tt>:customfields</tt> - a base64 encoded serialized array of custom field values
21
+ # * <tt>:configoptions</tt> - a base64 encoded serialized array of configurable product options
22
+ # * <tt>:priceoverride</tt> - allows you to pass in a custom price override for the product
23
+ # * <tt>:promocode</tt> - pass coupon code to apply to the order (optional)
24
+ # * <tt>:promooverride</tt> - pass this to override the products a coupon applies to (like through the admin area)
25
+ # * <tt>:affid</tt> - affiliate ID if you want to assign the order to an affiliate (optional)
26
+ # * <tt>:noinvoice</tt> - set true to not generate an invoice for this order
27
+ # * <tt>:noinvoiceemail</tt> - set true to generate but not send the invoice notification email
28
+ # * <tt>:noemail</tt> - set true to surpress the order confirmation email
29
+ # * <tt>:clientip</tt> - can be used to pass the customers IP (optional)
30
+ # * <tt>:addons</tt> - comma seperated list of addon ids
31
+ #
32
+ # For VPS/Dedicated Server Orders only:
33
+ # * <tt>:hostname</tt> - The hostname of the server. This will be added to domain automatically
34
+ # * <tt>:ns1prefix</tt> - the prefix to be used for the NS1 nameserver
35
+ # * <tt>:ns2prefix</tt> - the prefix to be used for the NS2 nameserver
36
+ # * <tt>:rootpw</tt> - The root password for the server
37
+ #
38
+ # For Domain registration only:
39
+ # * <tt>:contactid</tt> - the ID of a contact to use for the domain registrant details
40
+ # * <tt>:dnsmanagement</tt> - true to enable
41
+ # * <tt>:domainfields</tt> - a base64 encoded serialized array of the TLD specific field values
42
+ # * <tt>:emailforwarding</tt> - true to enable
43
+ # * <tt>:idprotection</tt> - true to enable
44
+ # * <tt>:nameserver2</tt> - second nameserver
45
+ # * <tt>:nameserver3</tt> - third nameserver
46
+ # * <tt>:nameserver4</tt> - fourth nameserver
47
+ #
48
+ # For domain renewals:
49
+ # * <tt>:domainrenewals</tt> - This is a name -> value array of domain -> regperiod
50
+ #
51
+ # See:
52
+ #
53
+ # http://docs.whmcs.com/API:Add_Order
54
+ def self.add_order(params = {})
55
+ params.merge!(:action => 'addorder')
56
+ send_request(params)
57
+ end
58
+
59
+ # Get orders
60
+ #
61
+ # Optional attributes:
62
+ # * <tt>:id</tt> - to get a specific order ID only
63
+ # * <tt>:userid</tt> - to get all orders for a specific client ID
64
+ # * <tt>:status</tt> - to get all orders in a specific status: Pending, Active, Fraud, Cancelled
65
+ # * <tt>:limitstart</tt> - The record number to start at (default = 0)
66
+ # * <tt>:limitnum</tt> - The number of order records to return (default = 25)
67
+ #
68
+ # See:
69
+ #
70
+ # http://docs.whmcs.com/API:Get_Orders
71
+ def self.get_orders(params = {})
72
+ params.merge!(:action => 'getorders')
73
+ send_request(params)
74
+ end
75
+
76
+ # Get products
77
+ #
78
+ # Parameters:
79
+ #
80
+ # * <tt>:pid</tt> - can be used to just retrieve the details of a specific product ID
81
+ # * <tt>:gid</tt> - can be passed to just retrieve products in a specific group
82
+ # * <tt>:module</tt> - can be passed to just retrieve products assigned to a specific module
83
+ #
84
+ # See:
85
+ #
86
+ # http://docs.whmcs.com/API:Get_Products
87
+ def self.get_products(params = {})
88
+ params.merge!(:action => 'getproducts')
89
+ send_request(params)
90
+ end
91
+
92
+ # Get promotions
93
+ #
94
+ # Optional attributes:
95
+ #
96
+ # * <tt>:code</tt> - the specific promotion code to return information for (optional)
97
+ #
98
+ # See:
99
+ #
100
+ # http://docs.whmcs.com/API:Get_Promotions
101
+ def self.get_promotions(params = {})
102
+ params.merge!(:action => 'getpromotions')
103
+ send_request(params)
104
+ end
105
+
106
+ # Get order statuses
107
+ #
108
+ # See:
109
+ #
110
+ # http://docs.whmcs.com/API:Get_Order_Statuses
111
+ def self.get_order_statuses
112
+ params.merge!(:action => 'getorderstatuses')
113
+ send_request(params)
114
+ end
115
+
116
+ # Accept an order
117
+ #
118
+ # Parameters:
119
+ #
120
+ # * <tt>:orderid</tt> - the Order ID
121
+ #
122
+ # Optional attributes:
123
+ # * <tt>:serverid</tt> - the Server ID to provision any hosting products in the order to, overrides default
124
+ # * <tt>:serviceusername</tt> - the Username to assign for provisioning, overrides default
125
+ # * <tt>:servicepassword</tt> - the Password to assign for products being provisioned, overrides auto generation
126
+ # * <tt>:registrar</tt> - the domain registrar module to assign any domains to
127
+ # * <tt>:autosetup</tt> - true/false - determines whether product provisioning is performed
128
+ # * <tt>:sendregistrar</tt> - true/false determines whether domain automation is performed
129
+ # * <tt>:sendemail</tt> - true/false - sets if welcome emails for products and registration confirmation emails for domains should be sent
130
+ #
131
+ # See:
132
+ #
133
+ # http://docs.whmcs.com/API:Accept_Order
134
+ def self.accept_order(params = {})
135
+ params.merge!(:action => 'acceptorder')
136
+ send_request(params)
137
+ end
138
+
139
+ # Place an order in pending
140
+ #
141
+ # Parameters:
142
+ #
143
+ # * <tt>:orderid</tt> - the Order ID
144
+ #
145
+ # See:
146
+ #
147
+ # http://docs.whmcs.com/API:Pending_Order
148
+ def self.pending_order(params = {})
149
+ params.merge!(:action => 'pendingorder')
150
+ send_request(params)
151
+ end
152
+
153
+ # Cancel an order
154
+ #
155
+ # Parameters:
156
+ #
157
+ # * <tt>:orderid</tt> - the Order ID
158
+ #
159
+ # See:
160
+ #
161
+ # http://docs.whmcs.com/API:Cancel_Order
162
+ def self.cancel_order(params = {})
163
+ params.merge!(:action => 'cancelorder')
164
+ send_request(params)
165
+ end
166
+
167
+ # Mark an order as fraud
168
+ #
169
+ # Parameters:
170
+ #
171
+ # * <tt>:orderid</tt> - the Order ID
172
+ #
173
+ # See:
174
+ #
175
+ # http://docs.whmcs.com/API:Fraud_Order
176
+ def self.fraud_order(params = {})
177
+ params.merge!(:action => 'fraudorder')
178
+ send_request(params)
179
+ end
180
+
181
+ # Delete an order
182
+ #
183
+ # Parameters:
184
+ #
185
+ # * <tt>:orderid</tt> - the Order ID
186
+ #
187
+ # See:
188
+ #
189
+ # http://docs.whmcs.com/API:Delete_Order
190
+ def self.delete_order(params = {})
191
+ params.merge!(:action => 'deleteorder')
192
+ send_request(params)
193
+ end
194
+ end
195
+ end