Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

First commit

  • Loading branch information...
commit 9418f3b3c2b0afd54dffb2d0314c12d643f6e040 0 parents
Joshua Priddle itspriddle authored
1  Gemfile
@@ -0,0 +1 @@
+gemspec
17 Gemfile.lock
@@ -0,0 +1,17 @@
+PATH
+ remote: .
+ specs:
+ whmcs-ruby (0.0.1)
+ crack (= 0.1.8)
+
+GEM
+ specs:
+ crack (0.1.8)
+ shoulda (2.11.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ shoulda
+ whmcs-ruby!
21 LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2011 DotBlock.com
+
+Permission is hereby granted, free of charge, to any person ob-
+taining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without restric-
+tion, including without limitation the rights to use, copy, modi-
+fy, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is fur-
+nished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONIN-
+FRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
29 README.markdown
@@ -0,0 +1,29 @@
+# whmcs-ruby
+
+whmcs-ruby provides Ruby bindings for the [WHMCS API](http://wiki.whmcs.com/API:Functions).
+
+
+## Usage
+
+ require 'whmcs'
+
+ WHMCS.configure do |config|
+ config.api_url = 'http://example.com/includes/api.php'
+ config.api_username = 'someusername'
+ config.api_password = 'c4ca4238a0b923820dcc509a6f75849b' # md5 hash
+ end
+
+ WHMCS::Client.get_clients_details(:clientid => '1')
+
+See the [documentation](http://dotblock.github.com/whmcs-ruby/) for more
+details.
+
+
+## Installation
+
+ gem install whmcs-ruby
+
+
+## Copyright
+
+Copyright (c) 2011 DotBlock.com, see LICENSE in this repo for details.
31 Rakefile
@@ -0,0 +1,31 @@
+$:.unshift 'lib'
+
+task :default => :test
+
+require 'rake/testtask'
+Rake::TestTask.new(:test) do |test|
+ test.libs << 'lib' << 'test' << '.'
+ test.pattern = 'test/**/*_test.rb'
+ test.verbose = true
+end
+
+desc "Open an irb session preloaded with this library"
+task :console do
+ sh "irb -rubygems -r ./lib/whmcs.rb -I ./lib"
+end
+
+require 'sdoc_helpers'
+desc "Push a new version to Gemcutter"
+task :publish do
+ require 'whmcs/version'
+
+ ver = WHMCS::Version
+
+ sh "gem build whmcs-ruby.gemspec"
+ sh "gem push whmcs-ruby-#{ver}.gem"
+ sh "git tag -a -m 'whmcs-ruby v#{ver}' v#{ver}"
+ sh "git push origin v#{ver}"
+ sh "git push origin master"
+ sh "git clean -fd"
+ sh "rake pages"
+end
30 lib/whmcs.rb
@@ -0,0 +1,30 @@
+module WHMCS
+ autoload :Version, "whmcs/version"
+ autoload :Config, "whmcs/config"
+ autoload :Base, "whmcs/base"
+ autoload :Client, "whmcs/client"
+ autoload :Invoice, "whmcs/invoice"
+ autoload :Misc, "whmcs/misc"
+ autoload :Module, "whmcs/module"
+ autoload :Order, "whmcs/order"
+ autoload :Quote, "whmcs/quote"
+ autoload :Ticket, "whmcs/ticket"
+
+ class << self
+ attr_accessor :config
+ end
+
+ self.config ||= Config.new
+
+ # Pass a block to configure the WHMCS API
+ #
+ # WHMCS.configure do |config|
+ # config.api_username = 'apiuser'
+ # config.api_password = 'c4ca4238a0b923820dcc509a6f75849b'
+ # config.api_url = 'http://example.com/includes/api.php
+ # end
+ def self.configure
+ yield config
+ config
+ end
+end
69 lib/whmcs/base.rb
@@ -0,0 +1,69 @@
+require 'net/http'
+require 'net/https'
+require 'crack'
+
+module WHMCS
+ # WHMCS::Base is the main class used to subclass WHMCS API resources
+ class Base
+
+ # Sends an API request to the WHMCS API
+ #
+ # Parameters:
+ # * <tt>:action</tt> - The API action to perform
+ #
+ # All other paramters are passed along as HTTP POST variables
+ def self.send_request(params = {})
+ if params[:action].blank?
+ raise "No API action set"
+ end
+
+ params.merge!(
+ :username => WHMCS.config.api_username,
+ :password => WHMCS.config.api_password
+ )
+
+ url = URI.parse(WHMCS.config.api_url)
+
+ http = Net::HTTP.new(url.host, url.port)
+
+ if url.port == 443
+ http.use_ssl = true
+ end
+
+ req = Net::HTTP::Post.new(url.path)
+ req.set_form_data(params)
+
+ res = http.start { |http| http.request(req) }
+ parse_response(res.body)
+ end
+
+ # Converts the API response to a Hash
+ def self.parse_response(raw)
+ return {} if raw.to_s.blank?
+
+ if raw.match(/xml version/)
+ Crack::XML.parse(raw)
+ else
+ Hash[raw.split(';').map { |line| line.split('=') }]
+ end
+ end
+ end
+end
+
+# Fix Net::HTTP so we dont get
+# warning: peer certificate won't be verified in this SSL session
+#
+# See:
+#
+# http://www.5dollarwhitebox.org/drupal/node/64
+module Net #:nodoc:all
+ class HTTP
+ alias_method :old_initialize, :initialize
+
+ def initialize(*args)
+ old_initialize(*args)
+ @ssl_context = OpenSSL::SSL::SSLContext.new
+ @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
+ end
+ end
+end
326 lib/whmcs/client.rb
@@ -0,0 +1,326 @@
+module WHMCS
+ # WHMCS::Client is the class for managing clients
+ class Client < Base
+
+ # Create a new client
+ #
+ # Parameters:
+ #
+ # * <tt>:firstname</tt>
+ # * <tt>:lastname</tt>
+ # * <tt>:companyname</tt> - optional
+ # * <tt>:email</tt>
+ # * <tt>:address1</tt>
+ # * <tt>:address2</tt> - optional
+ # * <tt>:city</tt>
+ # * <tt>:state</tt>
+ # * <tt>:postcode</tt>
+ # * <tt>:country</tt> - two letter ISO country code
+ # * <tt>:phonenumber</tt>
+ # * <tt>:password2</tt> - password for the new user account
+ # * <tt>:currency</tt> - the ID of the currency to set the user to
+ # * <tt>:groupid</tt> - used to assign the client to a client group
+ # * <tt>:notes</tt>
+ # * <tt>:cctype</tt> - Visa, Mastercard, etc...
+ # * <tt>:cardnum</tt>
+ # * <tt>:expdate</tt> - in the format MMYY
+ # * <tt>:startdate</tt>
+ # * <tt>:issuenumber</tt>
+ # * <tt>:customfields</tt> - a base64 encoded serialized array of custom field values
+ # * <tt>:noemail</tt> - pass as true to surpress the client signup welcome email sending
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Add_Client
+ def self.add_client(params = {})
+ params.merge!(:action => 'addclient')
+ send_request(params)
+ end
+
+ # Update a client's info
+ #
+ # Parameters:
+ #
+ # * <tt>:firstname</tt>
+ # * <tt>:lastname</tt>
+ # * <tt>:companyname</tt>
+ # * <tt>:email</tt>
+ # * <tt>:address1</tt>
+ # * <tt>:address2</tt>
+ # * <tt>:city</tt>
+ # * <tt>:state</tt>
+ # * <tt>:postcode</tt>
+ # * <tt>:country</tt> - two letter ISO country code
+ # * <tt>:phonenumber</tt>
+ # * <tt>:password2</tt>
+ # * <tt>:credit</tt> - credit balance
+ # * <tt>:taxexempt</tt> - true to enable
+ # * <tt>:notes</tt>
+ # * <tt>:cardtype</tt> - visa, mastercard, etc...
+ # * <tt>:cardnum</tt> - cc number
+ # * <tt>:expdate</tt> - cc expiry date
+ # * <tt>:startdate</tt> - cc start date
+ # * <tt>:issuenumber</tt> - cc issue number
+ # * <tt>:language</tt> - default language
+ # * <tt>:status</tt> - active or inactive
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Update_Client
+ def self.update_client(params = {})
+ params.merge!(:action => 'updateclient')
+ send_request(params)
+ end
+
+ # Delete a client
+ #
+ # Parameters:
+ #
+ # * <tt>:clientid</tt> - ID Number of the client to delete
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Delete_Client
+ def self.delete_client(params = {})
+ params.merge!(:action => 'deleteclient')
+ send_request(params)
+ end
+
+ # Get multiple clients
+ #
+ # Parameters:
+ #
+ # * <tt>:limitstart</tt> - Record to start at (default = 0)
+ # * <tt>:limitnum</tt> - Number of records to return (default = 25)
+ # * <tt>:search</tt> - Can be passed to filter for clients with a name/email matching the term entered
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Clients
+ def self.get_clients(params = {})
+ params.merge!(:action => 'getclients')
+ send_request(params)
+ end
+
+ # Get a client's info
+ #
+ # Parameters:
+ #
+ # * <tt>:clientid</tt> - the id number of the client
+ # * <tt>:email</tt> - the email address of the client
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Clients_Details
+ def self.get_clients_details(params = {})
+ params.merge!(:action => 'getclientsdetails')
+ send_request(params)
+ end
+
+ # Get a hash of a client's password
+ #
+ # Parameters:
+ #
+ # * <tt>:userid</tt> - should contain the user id of the client you wish to get the password for
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Clients_Password
+ def self.get_clients_password(params = {})
+ params.merge!(:action => 'getclientpassword')
+ send_request(params)
+ end
+
+ # Add a client contact
+ #
+ # Parameters:
+ #
+ # * <tt>:clientid</tt> - the client ID to add the contact to
+ # * <tt>:firstname</tt>
+ # * <tt>:lastname</tt>
+ # * <tt>:companyname</tt>
+ # * <tt>:email</tt>
+ # * <tt>:address1</tt>
+ # * <tt>:address2</tt>
+ # * <tt>:city</tt>
+ # * <tt>:state</tt>
+ # * <tt>:postcode</tt>
+ # * <tt>:country</tt> - two letter ISO country code
+ # * <tt>:phonenumber</tt>
+ # * <tt>:password2</tt> - if creating a sub-account
+ # * <tt>:permissions</tt> - can specify sub-account permissions eg manageproducts,managedomains
+ # * <tt>:generalemails</tt> - set true to receive general email types
+ # * <tt>:productemails</tt> - set true to receive product related emails
+ # * <tt>:domainemails</tt> - set true to receive domain related emails
+ # * <tt>:invoiceemails</tt> - set true to receive billing related emails
+ # * <tt>:supportemails</tt> - set true to receive support ticket related emails
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Add_Contact
+ def self.add_contact(params = {})
+ params.merge!(:action => 'addcontact')
+ send_request(params)
+ end
+
+ # Get client's contacts
+ #
+ # Parameters:
+ #
+ # * <tt>:limitstart</tt> - Record to start at (default = 0)
+ # * <tt>:limitnum</tt> - Number of records to return (default = 25)
+ # * <tt>:userid</tt>
+ # * <tt>:firstname</tt>
+ # * <tt>:lastname</tt>
+ # * <tt>:companyname</tt>
+ # * <tt>:email</tt>
+ # * <tt>:address1</tt>
+ # * <tt>:address2</tt>
+ # * <tt>:city</tt>
+ # * <tt>:state</tt>
+ # * <tt>:postcode</tt>
+ # * <tt>:country</tt>
+ # * <tt>:phonenumber</tt>
+ # * <tt>:subaccount</tt> - true/false
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Contacts
+ def self.get_contacts(params = {})
+ params.merge!(:action => 'getcontacts')
+ send_request(params)
+ end
+
+ # Update a client's contact
+ #
+ # Parameters:
+ #
+ # * <tt>:contactid</tt> - The ID of the contact to delete
+ # * <tt>:generalemails</tt> - set to true to receive general emails
+ # * <tt>:productemails</tt> - set to true to receive product emails
+ # * <tt>:domainemails</tt> - set to true to receive domain emails
+ # * <tt>:invoiceemails</tt> - set to true to receive invoice emails
+ # * <tt>:supportemails</tt> - set to true to receive support emails
+ # * <tt>:firstname</tt> - change the firstname
+ # * <tt>:lastname</tt> - change the lastname
+ # * <tt>:companyname</tt> - change the companyname
+ # * <tt>:email</tt> - change the email address
+ # * <tt>:address1</tt> - change address1
+ # * <tt>:address2</tt> - change address2
+ # * <tt>:city</tt> - change city
+ # * <tt>:state</tt> - change state
+ # * <tt>:postcode</tt> - change postcode
+ # * <tt>:country</tt> - change country
+ # * <tt>:phonenumber</tt> - change phonenumber
+ # * <tt>:subaccount</tt> - enable subaccount
+ # * <tt>:password</tt> - change the password
+ # * <tt>:permissions</tt> - set permissions eg manageproducts,managedomains
+ #
+ # Only send fields you wish to update
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Update_Contact
+ def self.update_contact(params = {})
+ params.merge!(:action => 'updatecontact')
+ send_request(params)
+ end
+
+ # Delete a client's contact
+ #
+ # Parameters:
+ #
+ # * <tt>:contactid</tt> - The ID of the contact to delete
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Delete_Contact
+ def self.delete_contact(params = {})
+ params.merge!(:action => 'deletecontact')
+ send_request(params)
+ end
+
+ # Get client's products
+ #
+ # Parameters:
+ #
+ # * <tt>:clientid</tt> - the ID of the client to retrieve products for
+ # * <tt>:serviceid</tt> - the ID of the service to retrieve details for
+ # * <tt>:domain</tt> - the domain of the service to retrieve details for
+ # * <tt>:pid</tt> - the product ID of the services to retrieve products for
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Clients_Products
+ def self.get_clients_products(params = {})
+ params.merge!(:action => 'getclientsproducts')
+ send_request(params)
+ end
+
+ # Update client's product
+ #
+ # Parameters:
+ #
+ # * <tt>:serviceid</tt> - the ID of the service to be updated
+ # * <tt>:pid</tt>
+ # * <tt>:serverid</tt>
+ # * <tt>:regdate</tt> - Format: YYYY-MM-DD
+ # * <tt>:nextduedate</tt> - Format: YYYY-MM-DD
+ # * <tt>:domain</tt>
+ # * <tt>:firstpaymentamount</tt>
+ # * <tt>:recurringamount</tt>
+ # * <tt>:billingcycle</tt>
+ # * <tt>:paymentmethod</tt>
+ # * <tt>:status</tt>
+ # * <tt>:serviceusername</tt>
+ # * <tt>:servicepassword</tt>
+ # * <tt>:subscriptionid</tt>
+ # * <tt>:promoid</tt>
+ # * <tt>:overideautosuspend</tt> - on/off
+ # * <tt>:overidesuspenduntil</tt> - Format: YYYY-MM-DD
+ # * <tt>:ns1</tt>
+ # * <tt>:ns2</tt>
+ # * <tt>:dedicatedip</tt>
+ # * <tt>:assignedips</tt>
+ # * <tt>:notes</tt>
+ # * <tt>:autorecalc</tt> - pass true to auto set price based on product ID or billing cycle change
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Update_Client_Product
+ def self.update_client_product(params = {})
+ params.merge!(:action => 'updateclientproduct')
+ send_request(params)
+ end
+
+ # Validate client login info
+ #
+ # Parameters:
+ #
+ # * <tt>:email</tt> - the email address of the user trying to login
+ # * <tt>:password2</tt> - the password they supply for authentication
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Validate_Login
+ def self.validate_login(params = {})
+ params.merge!(:action => 'validatelogin')
+ send_request(params)
+ end
+
+ # Send email to client
+ #
+ # Parameters:
+ #
+ # * <tt>:messagename</tt> - unique name of the email template to send from WHMCS
+ # * <tt>:id</tt> - related ID number to send message for
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Send_Email
+ def self.send_email(params = {})
+ params.merge!(:action => 'sendemail')
+ send_request(params)
+ end
+ end
+end
20 lib/whmcs/config.rb
@@ -0,0 +1,20 @@
+module WHMCS
+ # WHMCS::Config stores configuration data for connecting to the WHMCS API
+ class Config
+ # The WHMCS API username
+ attr_accessor :api_username
+
+ # The WHMCS API password
+ attr_accessor :api_password
+
+ # The WHMCS API URL
+ attr_accessor :api_url
+
+ # Create a new config object
+ def initialize
+ @api_username = 'example_api_user'
+ @api_password = 'example_api_pass'
+ @api_url = 'http://example.com/api.php'
+ end
+ end
+end
194 lib/whmcs/invoice.rb
@@ -0,0 +1,194 @@
+module WHMCS
+ # WHMCS::Invoice is the class for managing invoices
+ class Invoice < Base
+
+ # Get invoices
+ #
+ # Parameters:
+ #
+ # * <tt>:userid</tt> - the client ID to retrieve invoices for
+ # * <tt>:status</tt> - the status to filter for, Paid, Unpaid, Cancelled, etc...
+ # * <tt>:limitstart</tt> - the offset number to start at when returning matches (optional, default 0)
+ # * <tt>:limitnum</tt> - the number of records to return (optional, default 25)
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Invoices
+ def self.get_invoices(params = {})
+ params.merge!(:action => 'getinvoices')
+ send_request(params)
+ end
+
+ # Get an invoice
+ #
+ # Parameters:
+ #
+ # * <tt>:invoiceid</tt> - should be the invoice id you wish to retrieve
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Invoice
+ def self.get_invoice(params = {})
+ params.merge!(:action => 'getinvoice')
+ send_request(params)
+ end
+
+ # Create a new invoice
+ #
+ # Parameters:
+ #
+ # * <tt>:userid</tt> - should contain the user id of the client you wish to create the invoice for
+ # * <tt>:date</tt> - the date the invoice is created in the format YYYYMMDD
+ # * <tt>:duedate</tt> - the date the invoice is due in the format YYYYMMDD
+ # * <tt>:taxrate</tt> - the rate of tax that should be charged
+ # * <tt>:paymentmethod</tt> - the payment method for the invoice eg. banktransfer
+ # * <tt>:notes</tt> - any additional notes the invoice should display to the customer
+ # * <tt>:sendinvoice</tt> - set to true to send the "Invoice Created" email to the customer
+ #
+ # * <tt>:itemdescription1</tt> - item 1 description
+ # * <tt>:itemamount1</tt> - item 1 amount
+ # * <tt>:itemtaxed1</tt> - set to true if item 1 should be taxed
+ # * <tt>:itemdescription2</tt> - item 2 description
+ # * <tt>:itemamount2</tt> - item 2 amount
+ # * <tt>:itemtaxed2</tt> - set to true if item 2 should be taxed
+ #
+ # etc...
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Create_Invoice
+ def self.create_invoice(params = {})
+ params.merge!(:action => 'createinvoice')
+ send_request(params)
+ end
+
+ # Update an existing invoice
+ #
+ # Parameters:
+ #
+ # * <tt>:invoiceid</tt> - The ID of the invoice to update
+ # * <tt>:itemdescription</tt> - Array of existing line item descriptions to update. Line ID from database needed
+ # * <tt>:itemamount</tt> - Array of existing line item amounts to update
+ # * <tt>:itemtaxed</tt> - Array of existing line items taxed or not
+ # * <tt>:newitemdescription</tt> - Array of new line item descriptipons to add
+ # * <tt>:newitemamount</tt> - Array of new line item amounts
+ # * <tt>:newitemtaxed</tt> - Array of new line items taxed or not
+ # * <tt>:date</tt> - date of invoice format yyyymmdd
+ # * <tt>:duedate</tt> - duedate of invoice format yyyymmdd
+ # * <tt>:datepaid</tt> - date invoice was paid format yyyymmdd
+ # * <tt>:status</tt> - status of invoice. Unpaid, Paid, Cancelled, Collection, Refunded
+ # * <tt>:paymentmethod</tt> - payment method of invoice eg paypal, banktransfer
+ #
+ # Other than invoiceid, no other fields are required
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Update_Invoice
+ def self.update_invoice(params = {})
+ params.merge!(:action => 'updateinvoice')
+ send_request(params)
+ end
+
+ # Add an invoice payment
+ #
+ # Parameters:
+ #
+ # * <tt>:invoiceid</tt> - should contact the ID number of the invoice to add the payment to
+ # * <tt>:transid</tt> - should contain the transaction number for the payment
+ # * <tt>:amount</tt> - should contact the amount paid, can be left blank to take full amount of invoice
+ # * <tt>:fees</tt> - optional, if set defines how much fees were involved in the transaction
+ # * <tt>:gateway</tt> - should contain the gateway used in system name format, eg. paypal, authorize, etc...
+ # * <tt>:noemail</tt> - set to true to not send an email if the payment marks the invoice paid
+ # * <tt>:date</tt> - optional, if set defines the date the payment was made
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Add_Invoice_Payment
+ def self.add_invoice_payment(params = {})
+ params.merge!(:action => 'addinvoicepayment')
+ send_request(params)
+ end
+
+ # Attempt to capture payment for an invoice
+ #
+ # Parameters:
+ #
+ # * <tt>:invoiceid</tt> - the ID of the invoice the capture is to be attempted for
+ # * <tt>:cvv</tt> - optionally can be used to pass the cards verification value in the payment request
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Capture_Payment
+ def self.capture_payment(params = {})
+ params.merge!(:action => 'capturepayment')
+ send_request(params)
+ end
+
+ # Add a new billable item
+ #
+ # Parameters:
+ #
+ # * <tt>:clientid</tt>
+ # * <tt>:description</tt>
+ # * <tt>:amount</tt>
+ # * <tt>:recur</tt> - frequency to recur - 1,2,3,etc...
+ # * <tt>:recurcycle</tt> - Days, Weeks, Months or Years
+ # * <tt>:recurfor</tt> - number of times to repeat
+ # * <tt>:invoiceaction</tt> - noinvoice, nextcron, nextinvoice, duedate, recur
+ # * <tt>:duedate</tt> - date the invoice should be due
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Add_Billable_Item
+ def self.add_billable_item(params = {})
+ params.merge!(:action => 'addbillableitem')
+ send_request(params)
+ end
+
+ # Add a credit to client's account
+ #
+ # Parameters:
+ #
+ # * <tt>:clientid</tt> - the ID of the client the credit is to be added to
+ # * <tt>:description</tt> - reason for credit being added (stored in admin credit log)
+ # * <tt>:amount</tt> - the amount to be added
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Add_Credit
+ def self.add_credit(params = {})
+ params.merge!(:action => 'addcredit')
+ send_request(params)
+ end
+
+ # Add transaction
+ #
+ # Parameters:
+ #
+ # * <tt>:userid</tt> - Optional Add Transaction to a user
+ # * <tt>:invoiceid</tt> - Optional Add transaction to a particular invoice
+ # * <tt>:description</tt> - Description of the transaction
+ # * <tt>:amountin</tt> - amount to add to the account
+ # * <tt>:amountout</tt> - if an outgoing enter this
+ # * <tt>:fees</tt> - transaction fee you were charged
+ # * <tt>:paymentmethod</tt> - gateway used in WHMCS
+ # * <tt>:transid</tt> - Transaction ID you wish to assign
+ # * <tt>:date</tt> - date of transaction (same format as your WHMCS eg DD/MM/YYYY)
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Add_Transaction
+ def self.add_transaction(params = {})
+ send_request(params.merge(:action => 'addtransaction'))
+ end
+
+ # Get configured payment methods
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Payment_Methods
+ def self.get_payment_methods
+ send_request(:action => 'getpaymentmethods')
+ end
+ end
+end
168 lib/whmcs/misc.rb
@@ -0,0 +1,168 @@
+module WHMCS
+ # The WHMCS::Misc class contains miscelaneous WHMCS API functions
+ class Misc < Base
+
+ # Perform a whois lookup for a domain name
+ #
+ # Parameters:
+ #
+ # * <tt>:domain</tt> - the domain to check
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Domain_WHOIS
+ def self.domain_whois(params = {})
+ params.merge!(:action => 'domainwhois')
+ send_request(params)
+ end
+
+ # Get activity log
+ #
+ # Parameters:
+ #
+ # * <tt>:limitstart</tt> - Which User ID to start at (default = 0)
+ # * <tt>:limitnum</tt> - Limit by number (default = 25)
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Activity_Log
+ def self.get_activity_log(params = {})
+ params.merge!(:action => 'getactivitylog')
+ send_request(params)
+ end
+
+ # Get administrator details
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Admin_Details
+ def self.get_admin_details
+ send_request(:action => 'getadmindetails')
+ end
+
+ # Update administrator notes
+ #
+ # Parameters:
+ #
+ # * <tt>:notes</tt> - notes to enter
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Update_Admin_Notes
+ def self.update_admin_notes(params = {})
+ params.merge!(:action => 'updateadminnotes')
+ send_request(params)
+ end
+
+ # Get allowed currencies
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Currencies
+ def self.get_currencies
+ send_request(:action => 'getcurrencies')
+ end
+
+ # Get promotions
+ #
+ # Note: WHMCS has this listed under Misc as well as invoices. It's
+ # aliased here for consistancy with their API docs
+ #
+ # Parameters:
+ #
+ # * <tt>:code</tt> - the specific promotion code to return information for (optional)
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Promotions
+ def self.get_promotions(params = {})
+ Invoice.get_promotions(params)
+ end
+
+ # Get email templates
+ #
+ # Parameters:
+ #
+ # * <tt>:type</tt> - optional - from product,domain,support,general,invoice,affiliate
+ # * <tt>:language</tt> - optional - only required for additional languages
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Email_Templates
+ def self.get_email_templates(params = {})
+ params.merge!(:action => 'getemailtemplates')
+ send_request(params)
+ end
+
+ # Get todo items
+ #
+ # Parameters:
+ #
+ # * <tt>:status</tt> - optional - from New,Pending,In Progress,Completed,Postponed
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_To-Do_Items
+ def self.get_todo_items(params = {})
+ params.merge!(:action => 'gettodoitems')
+ send_request(params)
+ end
+
+ # Get configured todo item statuses
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_To-Do_Items_Statuses
+ def self.get_todo_item_statuses
+ send_request(:action => 'gettodoitemstatuses')
+ end
+
+ # Get staff online
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Staff_Online
+ def self.get_staff_online
+ send_request(:action => 'getstaffonline')
+ end
+
+ # Get stats
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Stats
+ def self.get_stats
+ send_request(:action => 'getstats')
+ end
+
+ # Encrypt a password with the WHMCS algorithm
+ #
+ # Parameters:
+ #
+ # * <tt>:password2</tt> - should contain the string you want encrypting
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Encrypt_Password
+ def self.encrypt_password(params = {})
+ params.merge!(:action => 'encryptpassword')
+ send_request(params)
+ end
+
+ # Decrypt a string with the WHMCS algorithm
+ #
+ # NOTE: This cannot be used to decrypt the clients password.
+ #
+ # Parameters:
+ #
+ # * <tt>:password2</tt> - should contain the string you want decrypting
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Decrypt_Password
+ def self.decrypt_password(params = {})
+ params.merge!(:action => 'decryptpassword')
+ send_request(params)
+ end
+ end
+end
62 lib/whmcs/module.rb
@@ -0,0 +1,62 @@
+module WHMCS
+ # WHMCS::Module is the class for working with hosting account modules
+ class Module < Base
+
+ # Run the module create command
+ #
+ # Parameters:
+ #
+ # * <tt>:accountid</tt> - the unique id number of the account in the tblhosting table
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Module_Create
+ def self.module_create(params = {})
+ params.merge!(:action => 'modulecreate')
+ send_request(params)
+ end
+
+ # Run the module suspend command
+ #
+ # Parameters:
+ #
+ # * <tt>:accountid</tt> - the unique id number of the account in the tblhosting table
+ # * <tt>:suspendreason</tt> - an explanation of why the suspension has been made shown to clients & staff
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Module_Suspend
+ def self.module_suspend(params = {})
+ params.merge!(:action => 'modulesuspend')
+ send_request(params)
+ end
+
+ # Run the module unsuspend command
+ #
+ # Parameters:
+ #
+ # * <tt>:accountid</tt> - the unique id number of the account in the tblhosting table
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Module_Unsuspend
+ def self.module_unsuspend(params = {})
+ params.merge!(:action => 'moduleunsuspend')
+ send_request(params)
+ end
+
+ # Run the module terminate command
+ #
+ # Parameters:
+ #
+ # * <tt>:accountid</tt> - the unique id number of the account in the tblhosting table
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Module_Terminate
+ def self.module_terminate(params = {})
+ params.merge!(:action => 'moduleterminate')
+ send_request(params)
+ end
+ end
+end
166 lib/whmcs/order.rb
@@ -0,0 +1,166 @@
+module WHMCS
+ # WHMCS::Order is the class for managing orders
+ class Order < Base
+
+ # Create a new order
+ #
+ # Parameters:
+ #
+ # * <tt>:clientid</tt> - client id for order
+ # * <tt>:pid</tt> - product id
+ # * <tt>:domain</tt> - domain name
+ # * <tt>:billingcycle</tt> - onetime, monthly, quarterly, semiannually, etc..
+ # * <tt>:addons</tt> - comma seperated list of addon ids
+ # * <tt>:customfields</tt> - a base64 encoded serialized array of custom field values
+ # * <tt>:configoptions</tt> - a base64 encoded serialized array of configurable product options
+ # * <tt>:domaintype</tt> - set for domain registration - register or transfer
+ # * <tt>:regperiod</tt> - 1,2,3,etc...
+ # * <tt>:dnsmanagement</tt> - true to enable
+ # * <tt>:emailforwarding - true to enable
+ # * <tt>:idprotection</tt> - true to enable
+ # * <tt>:eppcode</tt> - if transfer
+ # * <tt>:nameserver1</tt> - first nameserver (req for domain reg only)
+ # * <tt>:nameserver2</tt> - second nameserver
+ # * <tt>:nameserver3</tt> - third nameserver
+ # * <tt>:nameserver4</tt> - fourth nameserver
+ # * <tt>:paymentmethod</tt> - paypal, authorize, etc...
+ # * <tt>:promocode</tt> - pass coupon code to apply to the order (optional)
+ # * <tt>:affid</tt> - affiliate ID if you want to assign the order to an affiliate (optional)
+ # * <tt>:noinvoice</tt> - set true to not generate an invoice for this order
+ # * <tt>:noemail</tt> - set true to surpress the order confirmation email
+ # * <tt>:clientip</tt> - can be used to pass the customers IP (optional)
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Add_Order
+ def self.add_order(params = {})
+ params.merge!(:action => 'addorder')
+ send_request(params)
+ end
+
+ # Get orders
+ #
+ # Parameters:
+ #
+ # * <tt>:limitstart</tt> - The record number to start at (default = 0)
+ # * <tt>:limitnum</tt> - The number of order records to return (default = 25)
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Orders
+ def self.get_orders(params = {})
+ params.merge!(:action => 'getorders')
+ send_request(params)
+ end
+
+ # Get products
+ #
+ # Parameters:
+ #
+ # * <tt>:pid</tt> - can be used to just retrieve the details of a specific product ID
+ # * <tt>:gid</tt> - can be passed to just retrieve products in a specific group
+ # * <tt>:module</tt> - can be passed to just retrieve products assigned to a specific module
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Products
+ def self.get_products(params = {})
+ params.merge!(:action => 'getproducts')
+ send_request(params)
+ end
+
+ # Get promotions
+ #
+ # Parameters:
+ #
+ # * <tt>:code</tt> - the specific promotion code to return information for (optional)
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Promotions
+ def self.get_promotions(params = {})
+ params.merge!(:action => 'getpromotions')
+ send_request(params)
+ end
+
+ # Get order statuses
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Order_Statuses
+ def self.get_order_statuses
+ params.merge!(:action => 'getorderstatuses')
+ send_request(params)
+ end
+
+ # Accept an order
+ #
+ # Parameters:
+ #
+ # * <tt>:orderid</tt> - the Order ID
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Accept_Order
+ def self.accept_order(params = {})
+ params.merge!(:action => 'acceptorder')
+ send_request(params)
+ end
+
+ # Place an order in pending
+ #
+ # Parameters:
+ #
+ # * <tt>:orderid</tt> - the Order ID
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Pending_Order
+ def self.pending_order(params = {})
+ params.merge!(:action => 'pendingorder')
+ send_request(params)
+ end
+
+ # Cancel an order
+ #
+ # Parameters:
+ #
+ # * <tt>:orderid</tt> - the Order ID
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Cancel_Order
+ def self.cancel_order(params = {})
+ params.merge!(:action => 'cancelorder')
+ send_request(params)
+ end
+
+ # Mark an order as fraud
+ #
+ # Parameters:
+ #
+ # * <tt>:orderid</tt> - the Order ID
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Fraud_Order
+ def self.fraud_order(params = {})
+ params.merge!(:action => 'fraudorder')
+ send_request(params)
+ end
+
+ # Delete an order
+ #
+ # Parameters:
+ #
+ # * <tt>:orderid</tt> - the Order ID
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Delete_Order
+ def self.delete_order(params = {})
+ params.merge!(:action => 'deleteorder')
+ send_request(params)
+ end
+ end
+end
125 lib/whmcs/quote.rb
@@ -0,0 +1,125 @@
+module WHMCS
+ # WHMCS::Quote is the class for managing quotes
+ class Quote < Base
+
+ # Create a new quote
+ #
+ # Parameters:
+ #
+ # * <tt>:userid</tt> - the unique id number of the client in the tblclients table
+ # * <tt>:firstname</tt> - optional - only required if userid is not specified
+ # * <tt>:lastname</tt> - optional - only required if userid is not specified
+ # * <tt>:companyname</tt> - optional - only required if userid is not specified
+ # * <tt>:email</tt> - optional - only required if userid is not specified
+ # * <tt>:address1</tt> - optional - only required if userid is not specified
+ # * <tt>:address2</tt> - optional - only required if userid is not specified
+ # * <tt>:city</tt> - optional - only required if userid is not specified
+ # * <tt>:state</tt> - optional - only required if userid is not specified
+ # * <tt>:postcode</tt> - optional - only required if userid is not specified
+ # * <tt>:country</tt> - optional - only required if userid is not specified
+ # * <tt>:phonenumber</tt> - optional - only required if userid is not specified
+ # * <tt>:currency</tt> - optional - only required if userid is not specified
+ # * <tt>:subject</tt> - Subject of the quote
+ # * <tt>:stage</tt> - Draft,Delivered,On Hold,Accepted,Lost,Dead
+ # * <tt>:validuntil</tt> - In format set in Localisation
+ # * <tt>:datecreated</tt> - Optional - In format set in Localisation
+ # * <tt>:customernotes</tt> - notes that are viewable by the client
+ # * <tt>:adminnotes</tt> - notes that are admin only
+ # * <tt>:lineitems</tt> - a base64 encoded serialized array containing:
+ # * <tt>:desc</tt> - The line description
+ # * <tt>:qty</tt> - The quantity being quoted
+ # * <tt>:up</tt> - unit price
+ # * <tt>:discount</tt> - discount amount in %
+ # * <tt>:taxable</tt> - true or false
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Create_Quote
+ def self.create_quote(params = {})
+ params.merge!(:action => 'createquote')
+ send_request(params)
+ end
+
+ # Update an existing quote
+ #
+ # Parameters:
+ #
+ # * <tt>:quoteid</tt> - the id number of the quote in tblquotes
+ # * <tt>:userid</tt> - the unique id number of the client in the tblclients table
+ # * <tt>:firstname</tt> - optional - only required if userid is not specified
+ # * <tt>:lastname</tt> - optional - only required if userid is not specified
+ # * <tt>:companyname</tt> - optional - only required if userid is not specified
+ # * <tt>:email</tt> - optional - only required if userid is not specified
+ # * <tt>:address1</tt> - optional - only required if userid is not specified
+ # * <tt>:address2</tt> - optional - only required if userid is not specified
+ # * <tt>:city</tt> - optional - only required if userid is not specified
+ # * <tt>:state</tt> - optional - only required if userid is not specified
+ # * <tt>:postcode</tt> - optional - only required if userid is not specified
+ # * <tt>:country</tt> - optional - only required if userid is not specified
+ # * <tt>:phonenumber</tt> - optional - only required if userid is not specified
+ # * <tt>:currency</tt> - optional - only required if userid is not specified
+ # * <tt>:subject</tt> - Subject of the quote
+ # * <tt>:stage</tt> - Draft,Delivered,On Hold,Accepted,Lost,Dead
+ # * <tt>:validuntil</tt> - In format set in Localisation
+ # * <tt>:datecreated</tt> - Optional - In format set in Localisation
+ # * <tt>:customernotes</tt> - notes that are viewable by the client
+ # * <tt>:adminnotes</tt> - notes that are admin only
+ # * <tt>:lineitems</tt> - a base64 encoded serialized array containing:
+ # * <tt>:id</tt> - existing lineid only required to update existing lines
+ # * <tt>:desc</tt> - The line description
+ # * <tt>:qty</tt> - The quantity being quoted
+ # * <tt>:up</tt> - unit price
+ # * <tt>:discount</tt> - discount amount in %
+ # * <tt>:taxable</tt> - true or false
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Update_Quote
+ def self.update_quote(params = {})
+ params.merge!(:action => 'updatequote')
+ send_request(params)
+ end
+
+ # Delete a quote
+ #
+ # Parameters:
+ #
+ # * <tt>:quoteid</tt> - the id number of the quote in tblquotes
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Delete_Quote
+ def self.delete_quote(params = {})
+ params.merge!(:action => 'deletequote')
+ send_request(params)
+ end
+
+ # Send a quote to client
+ #
+ # Parameters:
+ #
+ # * <tt>:quoteid</tt> - the id number of the quote in tblquotes
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Send_Quote
+ def self.send_quote(params = {})
+ params.merge!(:action => 'sendquote')
+ send_request(params)
+ end
+
+ # Accept a quote
+ #
+ # Parameters:
+ #
+ # * <tt>:quoteid</tt> - the id number of the quote in tblquotes
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Accept_Quote
+ def self.accept_quote(params = {})
+ params.merge!(:action => 'acceptquote')
+ send_request(params)
+ end
+ end
+end
172 lib/whmcs/ticket.rb
@@ -0,0 +1,172 @@
+module WHMCS
+ # WHMCS::Ticket is the class for managing support tickets
+ class Ticket < Base
+
+ # Open a new ticket
+ #
+ # Parameters:
+ #
+ # * <tt>:clientid</tt> - the ID of the client the ticket belongs to
+ # * <tt>:name</tt> - only required if not a registered client (clientid must be sent as 0)
+ # * <tt>:email</tt> - only required if not a registered client
+ # * <tt>:deptid</tt> - the ID of the ticket department
+ # * <tt>:subject</tt>
+ # * <tt>:message</tt>
+ # * <tt>:priority</tt> - can be "Low", "Medium" or "High"
+ # * <tt>:serviceid</tt> - the ID if the ticket relates to a specific product
+ # * <tt>:customfields</tt> - a base 64 serialized array of field IDs => values
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Open_Ticket
+ def self.open_ticket(params = {})
+ params.merge!(:action => 'openticket')
+ send_request(params)
+ end
+
+ # Reply to ticket
+ #
+ # Parameters:
+ #
+ # * <tt>:ticketid</tt> - the ID of the ticket to add the reply to
+ # * <tt>:clientid</tt> - if adding reply as a client
+ # * <tt>:name</tt> - only required if not a registered client (clientid must be sent as 0)
+ # * <tt>:email</tt> - only required if not a registered client
+ # * <tt>:adminusername</tt> - if adding reply as an admin, name to show
+ # * <tt>:message</tt>
+ # * <tt>:status</tt> - specify if you want to set the status to On Hold or In Progress after reply
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Reply_Ticket
+ def self.reply_ticket(params = {})
+ params.merge!(:action => 'addticketreply')
+ send_request(params)
+ end
+
+ # Get tickets
+ #
+ # Parameters:
+ #
+ # * <tt>:limitstart</tt> - Optional start at which result (default 0)
+ # * <tt>:limitnum</tt> - Optional limit at how many results (default 25)
+ # * <tt>:clientid</tt> - Optional search for a particular client's tickets
+ # * <tt>:deptid</tt> - Optional search in a particular department
+ # * <tt>:status</tt> - Optional search a particular status
+ # * <tt>:subject</tt> - Optional search for a word in the subject
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Tickets
+ def self.get_tickets(params = {})
+ params.merge!(:action => 'gettickets')
+ send_request(params)
+ end
+
+ # Get a ticket
+ #
+ # Parameters:
+ #
+ # * <tt>:ticketid</tt> - Ticket id to retrieve
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Ticket
+ def self.get_ticket(params = {})
+ params.merge!(:action => 'getticket')
+ send_request(params)
+ end
+
+ # Update an existing ticket
+ #
+ # Parameters:
+ #
+ # * <tt>:ticketid</tt> - Ticket ID to be updated
+ # * <tt>:subject</tt>
+ # * <tt>:priority</tt> - Low, Medium or High
+ # * <tt>:status</tt> - Open, Answered, Closed, etc...
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Update_Ticket
+ def self.update_ticket(params = {})
+ params.merge!(:action => 'updateticket')
+ send_request(params)
+ end
+
+ # Add a note to an existing ticket
+ #
+ # Parameters:
+ #
+ # * <tt>:ticketid</tt> - Ticket ID the note is to be added
+ # * <tt>:message</tt> - The not to add
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Add_Ticket_Note
+ def self.add_ticket_note(params = {})
+ params.merge!(:action => 'addticketnote')
+ send_request(params)
+ end
+
+ # Delete an existing ticket
+ #
+ # Parameters:
+ #
+ # * <tt>:ticketid</tt> - Ticket ID to be deleted
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Delete_Ticket
+ def self.delete_ticket(params = {})
+ params.merge!(:action => 'deleteticket')
+ send_request(params)
+ end
+
+ # Get support departments
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Support_Departments
+ def self.get_support_departments
+ send_request(:action => 'getsupportdepartments')
+ end
+
+ # Get support statuses
+ #
+ # Parameters:
+ #
+ # * <tt>:deptid</tt> - Optional - Send a Department ID to limit results
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Support_Statuses
+ def self.get_support_statuses(params = {})
+ params.merge!(:action => 'getsupportstatuses')
+ send_request(params)
+ end
+
+ # Get ticket predefined categories
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Ticket_Predefined_Cats
+ def self.get_ticket_predefined_cats
+ send_request(:action => 'getticketpredefinedcats')
+ end
+
+ # Get ticket predefined replies
+ #
+ # Parameters:
+ #
+ # * <tt>:catid</tt> - Optional Select category to browse
+ #
+ # See:
+ #
+ # http://wiki.whmcs.com/API:Get_Ticket_Predefined_Replies
+ def self.get_ticket_predefined_repies(params = {})
+ params.merge!(:action => 'getsupportstatuses')
+ send_request(params)
+ end
+ end
+end
3  lib/whmcs/version.rb
@@ -0,0 +1,3 @@
+module WHMCS #:nodoc:
+ VERSION = Version = '0.0.1'
+end
16 test/test_helper.rb
@@ -0,0 +1,16 @@
+require 'rubygems'
+require 'test/unit'
+require 'shoulda'
+
+begin
+ require 'turn'
+rescue LoadError
+end
+
+require 'whmcs'
+
+WHMCS.configure do |config|
+ config.api_username = ENV['WHMCS_USER'] or raise "You must set the env variable WHMCS_USER"
+ config.api_password = ENV['WHMCS_PASS'] or raise "You must set the env variable WHMCS_PASS"
+ config.api_url = ENV['WHMCS_URL'] or raise "You must set the env variable WHMCS_URL"
+end
17 test/whmcs_test.rb
@@ -0,0 +1,17 @@
+require File.dirname(__FILE__) + '/test_helper.rb'
+
+class WHMCSTest < Test::Unit::TestCase
+ context "WHMCS::Base.send_request" do
+
+ should "raise an error if params[:action] is not set" do
+ assert_raise RuntimeError do
+ WHMCS::Base.send_request
+ end
+ end
+
+ should "return a hash" do
+ res = WHMCS::Client.get_clients_details(:clientid => '1')
+ assert res.is_a?(Hash)
+ end
+ end
+end
29 whmcs-ruby.gemspec
@@ -0,0 +1,29 @@
+$:.unshift 'lib'
+
+require 'whmcs/version'
+
+Gem::Specification.new do |s|
+ s.name = 'whmcs-ruby'
+ s.version = WHMCS::Version
+ s.date = Time.now.strftime('%Y-%m-%d')
+ s.summary = 'whmcs-ruby: Ruby bindings for the WHMCS API'
+ s.homepage = 'https://github.com/dotblock/whmcs-ruby'
+ s.authors = ['Joshua Priddle']
+ s.email = 'jpriddle@nevercraft.net'
+
+ s.files = %w[ Rakefile README.markdown ]
+
+ s.files += Dir['lib/**/*']
+ s.files += Dir['test/**/*']
+
+ s.add_dependency('crack', '= 0.1.8')
+
+ s.add_development_dependency('shoulda')
+
+ s.extra_rdoc_files = ['README.markdown']
+ s.rdoc_options = ["--charset=UTF-8"]
+
+ s.description = <<-DESC
+ whmcs-ruby: Ruby bindings for the WHMCS API
+ DESC
+end
Please sign in to comment.
Something went wrong with that request. Please try again.