whmcs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,195 @@
1
+ module WHMCS
2
+ # WHMCS::Invoice is the class for managing invoices
3
+ class Invoice < Base
4
+
5
+ # Get invoices
6
+ #
7
+ # Parameters:
8
+ #
9
+ # * <tt>:userid</tt> - the client ID to retrieve invoices for
10
+ # * <tt>:status</tt> - the status to filter for, Paid, Unpaid, Cancelled, etc...
11
+ # * <tt>:limitstart</tt> - the offset number to start at when returning matches (optional, default 0)
12
+ # * <tt>:limitnum</tt> - the number of records to return (optional, default 25)
13
+ #
14
+ # See:
15
+ #
16
+ # http://wiki.whmcs.com/API:Get_Invoices
17
+ def self.get_invoices(params = {})
18
+ params.merge!(:action => 'getinvoices')
19
+ send_request(params)
20
+ end
21
+
22
+ # Get an invoice
23
+ #
24
+ # Parameters:
25
+ #
26
+ # * <tt>:invoiceid</tt> - should be the invoice id you wish to retrieve
27
+ #
28
+ # See:
29
+ #
30
+ # http://wiki.whmcs.com/API:Get_Invoice
31
+ def self.get_invoice(params = {})
32
+ params.merge!(:action => 'getinvoice')
33
+ send_request(params)
34
+ end
35
+
36
+ # Create a new invoice
37
+ #
38
+ # Parameters:
39
+ #
40
+ # * <tt>:userid</tt> - should contain the user id of the client you wish to create the invoice for
41
+ # * <tt>:date</tt> - the date the invoice is created in the format YYYYMMDD
42
+ # * <tt>:duedate</tt> - the date the invoice is due in the format YYYYMMDD
43
+ # * <tt>:taxrate</tt> - the rate of tax that should be charged
44
+ # * <tt>:paymentmethod</tt> - the payment method for the invoice eg. banktransfer
45
+ # * <tt>:notes</tt> - any additional notes the invoice should display to the customer
46
+ # * <tt>:sendinvoice</tt> - set to true to send the "Invoice Created" email to the customer
47
+ #
48
+ # * <tt>:itemdescription1</tt> - item 1 description
49
+ # * <tt>:itemamount1</tt> - item 1 amount
50
+ # * <tt>:itemtaxed1</tt> - set to true if item 1 should be taxed
51
+ # * <tt>:itemdescription2</tt> - item 2 description
52
+ # * <tt>:itemamount2</tt> - item 2 amount
53
+ # * <tt>:itemtaxed2</tt> - set to true if item 2 should be taxed
54
+ #
55
+ # etc...
56
+ #
57
+ # See:
58
+ #
59
+ # http://wiki.whmcs.com/API:Create_Invoice
60
+ def self.create_invoice(params = {})
61
+ params.merge!(:action => 'createinvoice')
62
+ send_request(params)
63
+ end
64
+
65
+ # Update an existing invoice
66
+ #
67
+ # Parameters:
68
+ #
69
+ # * <tt>:invoiceid</tt> - The ID of the invoice to update
70
+ # * <tt>:itemdescription</tt> - Array of existing line item descriptions to update. Line ID from database needed
71
+ # * <tt>:itemamount</tt> - Array of existing line item amounts to update
72
+ # * <tt>:itemtaxed</tt> - Array of existing line items taxed or not
73
+ # * <tt>:newitemdescription</tt> - Array of new line item descriptipons to add
74
+ # * <tt>:newitemamount</tt> - Array of new line item amounts
75
+ # * <tt>:newitemtaxed</tt> - Array of new line items taxed or not
76
+ # * <tt>:date</tt> - date of invoice format yyyymmdd
77
+ # * <tt>:duedate</tt> - duedate of invoice format yyyymmdd
78
+ # * <tt>:datepaid</tt> - date invoice was paid format yyyymmdd
79
+ # * <tt>:status</tt> - status of invoice. Unpaid, Paid, Cancelled, Collection, Refunded
80
+ # * <tt>:paymentmethod</tt> - payment method of invoice eg paypal, banktransfer
81
+ #
82
+ # Other than invoiceid, no other fields are required
83
+ #
84
+ # See:
85
+ #
86
+ # http://wiki.whmcs.com/API:Update_Invoice
87
+ def self.update_invoice(params = {})
88
+ params.merge!(:action => 'updateinvoice')
89
+ send_request(params)
90
+ end
91
+
92
+ # Add an invoice payment
93
+ #
94
+ # Parameters:
95
+ #
96
+ # * <tt>:invoiceid</tt> - should contact the ID number of the invoice to add the payment to
97
+ # * <tt>:transid</tt> - should contain the transaction number for the payment
98
+ # * <tt>:amount</tt> - should contact the amount paid, can be left blank to take full amount of invoice
99
+ # * <tt>:fees</tt> - optional, if set defines how much fees were involved in the transaction
100
+ # * <tt>:gateway</tt> - should contain the gateway used in system name format, eg. paypal, authorize, etc...
101
+ # * <tt>:noemail</tt> - set to true to not send an email if the payment marks the invoice paid
102
+ # * <tt>:date</tt> - optional, if set defines the date the payment was made
103
+ #
104
+ # See:
105
+ #
106
+ # http://wiki.whmcs.com/API:Add_Invoice_Payment
107
+ def self.add_invoice_payment(params = {})
108
+ params.merge!(:action => 'addinvoicepayment')
109
+ send_request(params)
110
+ end
111
+
112
+ # Attempt to capture payment for an invoice
113
+ #
114
+ # Parameters:
115
+ #
116
+ # * <tt>:invoiceid</tt> - the ID of the invoice the capture is to be attempted for
117
+ # * <tt>:cvv</tt> - optionally can be used to pass the cards verification value in the payment request
118
+ #
119
+ # See:
120
+ #
121
+ # http://wiki.whmcs.com/API:Capture_Payment
122
+ def self.capture_payment(params = {})
123
+ params.merge!(:action => 'capturepayment')
124
+ send_request(params)
125
+ end
126
+
127
+ # Add a new billable item
128
+ #
129
+ # Parameters:
130
+ #
131
+ # * <tt>:clientid</tt>
132
+ # * <tt>:description</tt>
133
+ # * <tt>:amount</tt>
134
+ # * <tt>:recur</tt> - frequency to recur - 1,2,3,etc...
135
+ # * <tt>:recurcycle</tt> - Days, Weeks, Months or Years
136
+ # * <tt>:recurfor</tt> - number of times to repeat
137
+ # * <tt>:invoiceaction</tt> - noinvoice, nextcron, nextinvoice, duedate, recur
138
+ # * <tt>:duedate</tt> - date the invoice should be due
139
+ #
140
+ # See:
141
+ #
142
+ # http://wiki.whmcs.com/API:Add_Billable_Item
143
+ def self.add_billable_item(params = {})
144
+ params.merge!(:action => 'addbillableitem')
145
+ send_request(params)
146
+ end
147
+
148
+ # Add a credit to client's account
149
+ #
150
+ # Parameters:
151
+ #
152
+ # * <tt>:clientid</tt> - the ID of the client the credit is to be added to
153
+ # * <tt>:description</tt> - reason for credit being added (stored in admin credit log)
154
+ # * <tt>:amount</tt> - the amount to be added
155
+ #
156
+ # See:
157
+ #
158
+ # http://wiki.whmcs.com/API:Add_Credit
159
+ def self.add_credit(params = {})
160
+ params.merge!(:action => 'addcredit')
161
+ send_request(params)
162
+ end
163
+
164
+ # Add transaction
165
+ #
166
+ # Parameters:
167
+ #
168
+ # * <tt>:userid</tt> - Optional Add Transaction to a user
169
+ # * <tt>:invoiceid</tt> - Optional Add transaction to a particular invoice
170
+ # * <tt>:description</tt> - Description of the transaction
171
+ # * <tt>:amountin</tt> - amount to add to the account
172
+ # * <tt>:amountout</tt> - if an outgoing enter this
173
+ # * <tt>:fees</tt> - transaction fee you were charged
174
+ # * <tt>:paymentmethod</tt> - gateway used in WHMCS
175
+ # * <tt>:transid</tt> - Transaction ID you wish to assign
176
+ # * <tt>:date</tt> - date of transaction (same format as your WHMCS eg DD/MM/YYYY)
177
+ #
178
+ # See:
179
+ #
180
+ # http://wiki.whmcs.com/API:Add_Transaction
181
+ def self.add_transaction(params = {})
182
+ params.merge!(:action => 'addtransaction')
183
+ send_request(params)
184
+ end
185
+
186
+ # Get configured payment methods
187
+ #
188
+ # See:
189
+ #
190
+ # http://wiki.whmcs.com/API:Get_Payment_Methods
191
+ def self.get_payment_methods
192
+ send_request(:action => 'getpaymentmethods')
193
+ end
194
+ end
195
+ end
data/lib/whmcs/misc.rb ADDED
@@ -0,0 +1,168 @@
1
+ module WHMCS
2
+ # The WHMCS::Misc class contains miscelaneous WHMCS API functions
3
+ class Misc < Base
4
+
5
+ # Perform a whois lookup for a domain name
6
+ #
7
+ # Parameters:
8
+ #
9
+ # * <tt>:domain</tt> - the domain to check
10
+ #
11
+ # See:
12
+ #
13
+ # http://wiki.whmcs.com/API:Domain_WHOIS
14
+ def self.domain_whois(params = {})
15
+ params.merge!(:action => 'domainwhois')
16
+ send_request(params)
17
+ end
18
+
19
+ # Get activity log
20
+ #
21
+ # Parameters:
22
+ #
23
+ # * <tt>:limitstart</tt> - Which User ID to start at (default = 0)
24
+ # * <tt>:limitnum</tt> - Limit by number (default = 25)
25
+ #
26
+ # See:
27
+ #
28
+ # http://wiki.whmcs.com/API:Get_Activity_Log
29
+ def self.get_activity_log(params = {})
30
+ params.merge!(:action => 'getactivitylog')
31
+ send_request(params)
32
+ end
33
+
34
+ # Get administrator details
35
+ #
36
+ # See:
37
+ #
38
+ # http://wiki.whmcs.com/API:Get_Admin_Details
39
+ def self.get_admin_details
40
+ send_request(:action => 'getadmindetails')
41
+ end
42
+
43
+ # Update administrator notes
44
+ #
45
+ # Parameters:
46
+ #
47
+ # * <tt>:notes</tt> - notes to enter
48
+ #
49
+ # See:
50
+ #
51
+ # http://wiki.whmcs.com/API:Update_Admin_Notes
52
+ def self.update_admin_notes(params = {})
53
+ params.merge!(:action => 'updateadminnotes')
54
+ send_request(params)
55
+ end
56
+
57
+ # Get allowed currencies
58
+ #
59
+ # See:
60
+ #
61
+ # http://wiki.whmcs.com/API:Get_Currencies
62
+ def self.get_currencies
63
+ send_request(:action => 'getcurrencies')
64
+ end
65
+
66
+ # Get promotions
67
+ #
68
+ # Note: WHMCS has this listed under Misc as well as invoices. It's
69
+ # aliased here for consistancy with their API docs
70
+ #
71
+ # Parameters:
72
+ #
73
+ # * <tt>:code</tt> - the specific promotion code to return information for (optional)
74
+ #
75
+ # See:
76
+ #
77
+ # http://wiki.whmcs.com/API:Get_Promotions
78
+ def self.get_promotions(params = {})
79
+ Invoice.get_promotions(params)
80
+ end
81
+
82
+ # Get email templates
83
+ #
84
+ # Parameters:
85
+ #
86
+ # * <tt>:type</tt> - optional - from product,domain,support,general,invoice,affiliate
87
+ # * <tt>:language</tt> - optional - only required for additional languages
88
+ #
89
+ # See:
90
+ #
91
+ # http://wiki.whmcs.com/API:Get_Email_Templates
92
+ def self.get_email_templates(params = {})
93
+ params.merge!(:action => 'getemailtemplates')
94
+ send_request(params)
95
+ end
96
+
97
+ # Get todo items
98
+ #
99
+ # Parameters:
100
+ #
101
+ # * <tt>:status</tt> - optional - from New,Pending,In Progress,Completed,Postponed
102
+ #
103
+ # See:
104
+ #
105
+ # http://wiki.whmcs.com/API:Get_To-Do_Items
106
+ def self.get_todo_items(params = {})
107
+ params.merge!(:action => 'gettodoitems')
108
+ send_request(params)
109
+ end
110
+
111
+ # Get configured todo item statuses
112
+ #
113
+ # See:
114
+ #
115
+ # http://wiki.whmcs.com/API:Get_To-Do_Items_Statuses
116
+ def self.get_todo_item_statuses
117
+ send_request(:action => 'gettodoitemstatuses')
118
+ end
119
+
120
+ # Get staff online
121
+ #
122
+ # See:
123
+ #
124
+ # http://wiki.whmcs.com/API:Get_Staff_Online
125
+ def self.get_staff_online
126
+ send_request(:action => 'getstaffonline')
127
+ end
128
+
129
+ # Get stats
130
+ #
131
+ # See:
132
+ #
133
+ # http://wiki.whmcs.com/API:Get_Stats
134
+ def self.get_stats
135
+ send_request(:action => 'getstats')
136
+ end
137
+
138
+ # Encrypt a password with the WHMCS algorithm
139
+ #
140
+ # Parameters:
141
+ #
142
+ # * <tt>:password2</tt> - should contain the string you want encrypting
143
+ #
144
+ # See:
145
+ #
146
+ # http://wiki.whmcs.com/API:Encrypt_Password
147
+ def self.encrypt_password(params = {})
148
+ params.merge!(:action => 'encryptpassword')
149
+ send_request(params)
150
+ end
151
+
152
+ # Decrypt a string with the WHMCS algorithm
153
+ #
154
+ # NOTE: This cannot be used to decrypt the clients password.
155
+ #
156
+ # Parameters:
157
+ #
158
+ # * <tt>:password2</tt> - should contain the string you want decrypting
159
+ #
160
+ # See:
161
+ #
162
+ # http://wiki.whmcs.com/API:Decrypt_Password
163
+ def self.decrypt_password(params = {})
164
+ params.merge!(:action => 'decryptpassword')
165
+ send_request(params)
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,62 @@
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://wiki.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
+ # * <tt>:suspendreason</tt> - an explanation of why the suspension has been made shown to clients & staff
25
+ #
26
+ # See:
27
+ #
28
+ # http://wiki.whmcs.com/API:Module_Suspend
29
+ def self.module_suspend(params = {})
30
+ params.merge!(:action => 'modulesuspend')
31
+ send_request(params)
32
+ end
33
+
34
+ # Run the module unsuspend command
35
+ #
36
+ # Parameters:
37
+ #
38
+ # * <tt>:accountid</tt> - the unique id number of the account in the tblhosting table
39
+ #
40
+ # See:
41
+ #
42
+ # http://wiki.whmcs.com/API:Module_Unsuspend
43
+ def self.module_unsuspend(params = {})
44
+ params.merge!(:action => 'moduleunsuspend')
45
+ send_request(params)
46
+ end
47
+
48
+ # Run the module terminate command
49
+ #
50
+ # Parameters:
51
+ #
52
+ # * <tt>:accountid</tt> - the unique id number of the account in the tblhosting table
53
+ #
54
+ # See:
55
+ #
56
+ # http://wiki.whmcs.com/API:Module_Terminate
57
+ def self.module_terminate(params = {})
58
+ params.merge!(:action => 'moduleterminate')
59
+ send_request(params)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,166 @@
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>:addons</tt> - comma seperated list of addon ids
14
+ # * <tt>:customfields</tt> - a base64 encoded serialized array of custom field values
15
+ # * <tt>:configoptions</tt> - a base64 encoded serialized array of configurable product options
16
+ # * <tt>:domaintype</tt> - set for domain registration - register or transfer
17
+ # * <tt>:regperiod</tt> - 1,2,3,etc...
18
+ # * <tt>:dnsmanagement</tt> - true to enable
19
+ # * <tt>:emailforwarding</tt> - true to enable
20
+ # * <tt>:idprotection</tt> - true to enable
21
+ # * <tt>:eppcode</tt> - if transfer
22
+ # * <tt>:nameserver1</tt> - first nameserver (req for domain reg only)
23
+ # * <tt>:nameserver2</tt> - second nameserver
24
+ # * <tt>:nameserver3</tt> - third nameserver
25
+ # * <tt>:nameserver4</tt> - fourth nameserver
26
+ # * <tt>:paymentmethod</tt> - paypal, authorize, etc...
27
+ # * <tt>:promocode</tt> - pass coupon code to apply to the order (optional)
28
+ # * <tt>:affid</tt> - affiliate ID if you want to assign the order to an affiliate (optional)
29
+ # * <tt>:noinvoice</tt> - set true to not generate an invoice for this order
30
+ # * <tt>:noemail</tt> - set true to surpress the order confirmation email
31
+ # * <tt>:clientip</tt> - can be used to pass the customers IP (optional)
32
+ #
33
+ # See:
34
+ #
35
+ # http://wiki.whmcs.com/API:Add_Order
36
+ def self.add_order(params = {})
37
+ params.merge!(:action => 'addorder')
38
+ send_request(params)
39
+ end
40
+
41
+ # Get orders
42
+ #
43
+ # Parameters:
44
+ #
45
+ # * <tt>:limitstart</tt> - The record number to start at (default = 0)
46
+ # * <tt>:limitnum</tt> - The number of order records to return (default = 25)
47
+ #
48
+ # See:
49
+ #
50
+ # http://wiki.whmcs.com/API:Get_Orders
51
+ def self.get_orders(params = {})
52
+ params.merge!(:action => 'getorders')
53
+ send_request(params)
54
+ end
55
+
56
+ # Get products
57
+ #
58
+ # Parameters:
59
+ #
60
+ # * <tt>:pid</tt> - can be used to just retrieve the details of a specific product ID
61
+ # * <tt>:gid</tt> - can be passed to just retrieve products in a specific group
62
+ # * <tt>:module</tt> - can be passed to just retrieve products assigned to a specific module
63
+ #
64
+ # See:
65
+ #
66
+ # http://wiki.whmcs.com/API:Get_Products
67
+ def self.get_products(params = {})
68
+ params.merge!(:action => 'getproducts')
69
+ send_request(params)
70
+ end
71
+
72
+ # Get promotions
73
+ #
74
+ # Parameters:
75
+ #
76
+ # * <tt>:code</tt> - the specific promotion code to return information for (optional)
77
+ #
78
+ # See:
79
+ #
80
+ # http://wiki.whmcs.com/API:Get_Promotions
81
+ def self.get_promotions(params = {})
82
+ params.merge!(:action => 'getpromotions')
83
+ send_request(params)
84
+ end
85
+
86
+ # Get order statuses
87
+ #
88
+ # See:
89
+ #
90
+ # http://wiki.whmcs.com/API:Get_Order_Statuses
91
+ def self.get_order_statuses
92
+ params.merge!(:action => 'getorderstatuses')
93
+ send_request(params)
94
+ end
95
+
96
+ # Accept an order
97
+ #
98
+ # Parameters:
99
+ #
100
+ # * <tt>:orderid</tt> - the Order ID
101
+ #
102
+ # See:
103
+ #
104
+ # http://wiki.whmcs.com/API:Accept_Order
105
+ def self.accept_order(params = {})
106
+ params.merge!(:action => 'acceptorder')
107
+ send_request(params)
108
+ end
109
+
110
+ # Place an order in pending
111
+ #
112
+ # Parameters:
113
+ #
114
+ # * <tt>:orderid</tt> - the Order ID
115
+ #
116
+ # See:
117
+ #
118
+ # http://wiki.whmcs.com/API:Pending_Order
119
+ def self.pending_order(params = {})
120
+ params.merge!(:action => 'pendingorder')
121
+ send_request(params)
122
+ end
123
+
124
+ # Cancel an order
125
+ #
126
+ # Parameters:
127
+ #
128
+ # * <tt>:orderid</tt> - the Order ID
129
+ #
130
+ # See:
131
+ #
132
+ # http://wiki.whmcs.com/API:Cancel_Order
133
+ def self.cancel_order(params = {})
134
+ params.merge!(:action => 'cancelorder')
135
+ send_request(params)
136
+ end
137
+
138
+ # Mark an order as fraud
139
+ #
140
+ # Parameters:
141
+ #
142
+ # * <tt>:orderid</tt> - the Order ID
143
+ #
144
+ # See:
145
+ #
146
+ # http://wiki.whmcs.com/API:Fraud_Order
147
+ def self.fraud_order(params = {})
148
+ params.merge!(:action => 'fraudorder')
149
+ send_request(params)
150
+ end
151
+
152
+ # Delete an order
153
+ #
154
+ # Parameters:
155
+ #
156
+ # * <tt>:orderid</tt> - the Order ID
157
+ #
158
+ # See:
159
+ #
160
+ # http://wiki.whmcs.com/API:Delete_Order
161
+ def self.delete_order(params = {})
162
+ params.merge!(:action => 'deleteorder')
163
+ send_request(params)
164
+ end
165
+ end
166
+ end