whmcs-ruby 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,125 @@
1
+ module WHMCS
2
+ # WHMCS::Quote is the class for managing quotes
3
+ class Quote < Base
4
+
5
+ # Create a new quote
6
+ #
7
+ # Parameters:
8
+ #
9
+ # * <tt>:userid</tt> - the unique id number of the client in the tblclients table
10
+ # * <tt>:firstname</tt> - optional - only required if userid is not specified
11
+ # * <tt>:lastname</tt> - optional - only required if userid is not specified
12
+ # * <tt>:companyname</tt> - optional - only required if userid is not specified
13
+ # * <tt>:email</tt> - optional - only required if userid is not specified
14
+ # * <tt>:address1</tt> - optional - only required if userid is not specified
15
+ # * <tt>:address2</tt> - optional - only required if userid is not specified
16
+ # * <tt>:city</tt> - optional - only required if userid is not specified
17
+ # * <tt>:state</tt> - optional - only required if userid is not specified
18
+ # * <tt>:postcode</tt> - optional - only required if userid is not specified
19
+ # * <tt>:country</tt> - optional - only required if userid is not specified
20
+ # * <tt>:phonenumber</tt> - optional - only required if userid is not specified
21
+ # * <tt>:currency</tt> - optional - only required if userid is not specified
22
+ # * <tt>:subject</tt> - Subject of the quote
23
+ # * <tt>:stage</tt> - Draft,Delivered,On Hold,Accepted,Lost,Dead
24
+ # * <tt>:validuntil</tt> - In format set in Localisation
25
+ # * <tt>:datecreated</tt> - Optional - In format set in Localisation
26
+ # * <tt>:customernotes</tt> - notes that are viewable by the client
27
+ # * <tt>:adminnotes</tt> - notes that are admin only
28
+ # * <tt>:lineitems</tt> - a base64 encoded serialized array containing:
29
+ # * <tt>:desc</tt> - The line description
30
+ # * <tt>:qty</tt> - The quantity being quoted
31
+ # * <tt>:up</tt> - unit price
32
+ # * <tt>:discount</tt> - discount amount in %
33
+ # * <tt>:taxable</tt> - true or false
34
+ #
35
+ # See:
36
+ #
37
+ # http://wiki.whmcs.com/API:Create_Quote
38
+ def self.create_quote(params = {})
39
+ params.merge!(:action => 'createquote')
40
+ send_request(params)
41
+ end
42
+
43
+ # Update an existing quote
44
+ #
45
+ # Parameters:
46
+ #
47
+ # * <tt>:quoteid</tt> - the id number of the quote in tblquotes
48
+ # * <tt>:userid</tt> - the unique id number of the client in the tblclients table
49
+ # * <tt>:firstname</tt> - optional - only required if userid is not specified
50
+ # * <tt>:lastname</tt> - optional - only required if userid is not specified
51
+ # * <tt>:companyname</tt> - optional - only required if userid is not specified
52
+ # * <tt>:email</tt> - optional - only required if userid is not specified
53
+ # * <tt>:address1</tt> - optional - only required if userid is not specified
54
+ # * <tt>:address2</tt> - optional - only required if userid is not specified
55
+ # * <tt>:city</tt> - optional - only required if userid is not specified
56
+ # * <tt>:state</tt> - optional - only required if userid is not specified
57
+ # * <tt>:postcode</tt> - optional - only required if userid is not specified
58
+ # * <tt>:country</tt> - optional - only required if userid is not specified
59
+ # * <tt>:phonenumber</tt> - optional - only required if userid is not specified
60
+ # * <tt>:currency</tt> - optional - only required if userid is not specified
61
+ # * <tt>:subject</tt> - Subject of the quote
62
+ # * <tt>:stage</tt> - Draft,Delivered,On Hold,Accepted,Lost,Dead
63
+ # * <tt>:validuntil</tt> - In format set in Localisation
64
+ # * <tt>:datecreated</tt> - Optional - In format set in Localisation
65
+ # * <tt>:customernotes</tt> - notes that are viewable by the client
66
+ # * <tt>:adminnotes</tt> - notes that are admin only
67
+ # * <tt>:lineitems</tt> - a base64 encoded serialized array containing:
68
+ # * <tt>:id</tt> - existing lineid only required to update existing lines
69
+ # * <tt>:desc</tt> - The line description
70
+ # * <tt>:qty</tt> - The quantity being quoted
71
+ # * <tt>:up</tt> - unit price
72
+ # * <tt>:discount</tt> - discount amount in %
73
+ # * <tt>:taxable</tt> - true or false
74
+ #
75
+ # See:
76
+ #
77
+ # http://wiki.whmcs.com/API:Update_Quote
78
+ def self.update_quote(params = {})
79
+ params.merge!(:action => 'updatequote')
80
+ send_request(params)
81
+ end
82
+
83
+ # Delete a quote
84
+ #
85
+ # Parameters:
86
+ #
87
+ # * <tt>:quoteid</tt> - the id number of the quote in tblquotes
88
+ #
89
+ # See:
90
+ #
91
+ # http://wiki.whmcs.com/API:Delete_Quote
92
+ def self.delete_quote(params = {})
93
+ params.merge!(:action => 'deletequote')
94
+ send_request(params)
95
+ end
96
+
97
+ # Send a quote to client
98
+ #
99
+ # Parameters:
100
+ #
101
+ # * <tt>:quoteid</tt> - the id number of the quote in tblquotes
102
+ #
103
+ # See:
104
+ #
105
+ # http://wiki.whmcs.com/API:Send_Quote
106
+ def self.send_quote(params = {})
107
+ params.merge!(:action => 'sendquote')
108
+ send_request(params)
109
+ end
110
+
111
+ # Accept a quote
112
+ #
113
+ # Parameters:
114
+ #
115
+ # * <tt>:quoteid</tt> - the id number of the quote in tblquotes
116
+ #
117
+ # See:
118
+ #
119
+ # http://wiki.whmcs.com/API:Accept_Quote
120
+ def self.accept_quote(params = {})
121
+ params.merge!(:action => 'acceptquote')
122
+ send_request(params)
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,172 @@
1
+ module WHMCS
2
+ # WHMCS::Ticket is the class for managing support tickets
3
+ class Ticket < Base
4
+
5
+ # Open a new ticket
6
+ #
7
+ # Parameters:
8
+ #
9
+ # * <tt>:clientid</tt> - the ID of the client the ticket belongs to
10
+ # * <tt>:name</tt> - only required if not a registered client (clientid must be sent as 0)
11
+ # * <tt>:email</tt> - only required if not a registered client
12
+ # * <tt>:deptid</tt> - the ID of the ticket department
13
+ # * <tt>:subject</tt>
14
+ # * <tt>:message</tt>
15
+ # * <tt>:priority</tt> - can be "Low", "Medium" or "High"
16
+ # * <tt>:serviceid</tt> - the ID if the ticket relates to a specific product
17
+ # * <tt>:customfields</tt> - a base 64 serialized array of field IDs => values
18
+ #
19
+ # See:
20
+ #
21
+ # http://wiki.whmcs.com/API:Open_Ticket
22
+ def self.open_ticket(params = {})
23
+ params.merge!(:action => 'openticket')
24
+ send_request(params)
25
+ end
26
+
27
+ # Reply to ticket
28
+ #
29
+ # Parameters:
30
+ #
31
+ # * <tt>:ticketid</tt> - the ID of the ticket to add the reply to
32
+ # * <tt>:clientid</tt> - if adding reply as a client
33
+ # * <tt>:name</tt> - only required if not a registered client (clientid must be sent as 0)
34
+ # * <tt>:email</tt> - only required if not a registered client
35
+ # * <tt>:adminusername</tt> - if adding reply as an admin, name to show
36
+ # * <tt>:message</tt>
37
+ # * <tt>:status</tt> - specify if you want to set the status to On Hold or In Progress after reply
38
+ #
39
+ # See:
40
+ #
41
+ # http://wiki.whmcs.com/API:Reply_Ticket
42
+ def self.reply_ticket(params = {})
43
+ params.merge!(:action => 'addticketreply')
44
+ send_request(params)
45
+ end
46
+
47
+ # Get tickets
48
+ #
49
+ # Parameters:
50
+ #
51
+ # * <tt>:limitstart</tt> - Optional start at which result (default 0)
52
+ # * <tt>:limitnum</tt> - Optional limit at how many results (default 25)
53
+ # * <tt>:clientid</tt> - Optional search for a particular client's tickets
54
+ # * <tt>:deptid</tt> - Optional search in a particular department
55
+ # * <tt>:status</tt> - Optional search a particular status
56
+ # * <tt>:subject</tt> - Optional search for a word in the subject
57
+ #
58
+ # See:
59
+ #
60
+ # http://wiki.whmcs.com/API:Get_Tickets
61
+ def self.get_tickets(params = {})
62
+ params.merge!(:action => 'gettickets')
63
+ send_request(params)
64
+ end
65
+
66
+ # Get a ticket
67
+ #
68
+ # Parameters:
69
+ #
70
+ # * <tt>:ticketid</tt> - Ticket id to retrieve
71
+ #
72
+ # See:
73
+ #
74
+ # http://wiki.whmcs.com/API:Get_Ticket
75
+ def self.get_ticket(params = {})
76
+ params.merge!(:action => 'getticket')
77
+ send_request(params)
78
+ end
79
+
80
+ # Update an existing ticket
81
+ #
82
+ # Parameters:
83
+ #
84
+ # * <tt>:ticketid</tt> - Ticket ID to be updated
85
+ # * <tt>:subject</tt>
86
+ # * <tt>:priority</tt> - Low, Medium or High
87
+ # * <tt>:status</tt> - Open, Answered, Closed, etc...
88
+ #
89
+ # See:
90
+ #
91
+ # http://wiki.whmcs.com/API:Update_Ticket
92
+ def self.update_ticket(params = {})
93
+ params.merge!(:action => 'updateticket')
94
+ send_request(params)
95
+ end
96
+
97
+ # Add a note to an existing ticket
98
+ #
99
+ # Parameters:
100
+ #
101
+ # * <tt>:ticketid</tt> - Ticket ID the note is to be added
102
+ # * <tt>:message</tt> - The not to add
103
+ #
104
+ # See:
105
+ #
106
+ # http://wiki.whmcs.com/API:Add_Ticket_Note
107
+ def self.add_ticket_note(params = {})
108
+ params.merge!(:action => 'addticketnote')
109
+ send_request(params)
110
+ end
111
+
112
+ # Delete an existing ticket
113
+ #
114
+ # Parameters:
115
+ #
116
+ # * <tt>:ticketid</tt> - Ticket ID to be deleted
117
+ #
118
+ # See:
119
+ #
120
+ # http://wiki.whmcs.com/API:Delete_Ticket
121
+ def self.delete_ticket(params = {})
122
+ params.merge!(:action => 'deleteticket')
123
+ send_request(params)
124
+ end
125
+
126
+ # Get support departments
127
+ #
128
+ # See:
129
+ #
130
+ # http://wiki.whmcs.com/API:Get_Support_Departments
131
+ def self.get_support_departments
132
+ send_request(:action => 'getsupportdepartments')
133
+ end
134
+
135
+ # Get support statuses
136
+ #
137
+ # Parameters:
138
+ #
139
+ # * <tt>:deptid</tt> - Optional - Send a Department ID to limit results
140
+ #
141
+ # See:
142
+ #
143
+ # http://wiki.whmcs.com/API:Get_Support_Statuses
144
+ def self.get_support_statuses(params = {})
145
+ params.merge!(:action => 'getsupportstatuses')
146
+ send_request(params)
147
+ end
148
+
149
+ # Get ticket predefined categories
150
+ #
151
+ # See:
152
+ #
153
+ # http://wiki.whmcs.com/API:Get_Ticket_Predefined_Cats
154
+ def self.get_ticket_predefined_cats
155
+ send_request(:action => 'getticketpredefinedcats')
156
+ end
157
+
158
+ # Get ticket predefined replies
159
+ #
160
+ # Parameters:
161
+ #
162
+ # * <tt>:catid</tt> - Optional Select category to browse
163
+ #
164
+ # See:
165
+ #
166
+ # http://wiki.whmcs.com/API:Get_Ticket_Predefined_Replies
167
+ def self.get_ticket_predefined_repies(params = {})
168
+ params.merge!(:action => 'getsupportstatuses')
169
+ send_request(params)
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,3 @@
1
+ module WHMCS #:nodoc:
2
+ VERSION = Version = '0.0.1'
3
+ end
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ begin
6
+ require 'turn'
7
+ rescue LoadError
8
+ end
9
+
10
+ require 'whmcs'
11
+
12
+ WHMCS.configure do |config|
13
+ config.api_username = ENV['WHMCS_USER'] or raise "You must set the env variable WHMCS_USER"
14
+ config.api_password = ENV['WHMCS_PASS'] or raise "You must set the env variable WHMCS_PASS"
15
+ config.api_url = ENV['WHMCS_URL'] or raise "You must set the env variable WHMCS_URL"
16
+ end
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class WHMCSTest < Test::Unit::TestCase
4
+ context "WHMCS::Base.send_request" do
5
+
6
+ should "raise an error if params[:action] is not set" do
7
+ assert_raise RuntimeError do
8
+ WHMCS::Base.send_request
9
+ end
10
+ end
11
+
12
+ should "return a hash" do
13
+ res = WHMCS::Client.get_clients_details(:clientid => '1')
14
+ assert res.is_a?(Hash)
15
+ end
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whmcs-ruby
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Joshua Priddle
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-02 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: crack
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - "="
28
+ - !ruby/object:Gem::Version
29
+ hash: 11
30
+ segments:
31
+ - 0
32
+ - 1
33
+ - 8
34
+ version: 0.1.8
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: shoulda
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ description: " whmcs-ruby: Ruby bindings for the WHMCS API\n"
52
+ email: jpriddle@nevercraft.net
53
+ executables: []
54
+
55
+ extensions: []
56
+
57
+ extra_rdoc_files:
58
+ - README.markdown
59
+ files:
60
+ - Rakefile
61
+ - README.markdown
62
+ - lib/whmcs/base.rb
63
+ - lib/whmcs/client.rb
64
+ - lib/whmcs/config.rb
65
+ - lib/whmcs/invoice.rb
66
+ - lib/whmcs/misc.rb
67
+ - lib/whmcs/module.rb
68
+ - lib/whmcs/order.rb
69
+ - lib/whmcs/quote.rb
70
+ - lib/whmcs/ticket.rb
71
+ - lib/whmcs/version.rb
72
+ - lib/whmcs.rb
73
+ - test/test_helper.rb
74
+ - test/whmcs_test.rb
75
+ has_rdoc: true
76
+ homepage: https://github.com/dotblock/whmcs-ruby
77
+ licenses: []
78
+
79
+ post_install_message:
80
+ rdoc_options:
81
+ - --charset=UTF-8
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ requirements: []
103
+
104
+ rubyforge_project:
105
+ rubygems_version: 1.5.0
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: "whmcs-ruby: Ruby bindings for the WHMCS API"
109
+ test_files: []
110
+