whmcs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
data/lib/whmcs.rb ADDED
@@ -0,0 +1,29 @@
1
+ module WHMCS
2
+ autoload :Config, "whmcs/config"
3
+ autoload :Base, "whmcs/base"
4
+ autoload :Client, "whmcs/client"
5
+ autoload :Invoice, "whmcs/invoice"
6
+ autoload :Misc, "whmcs/misc"
7
+ autoload :Module, "whmcs/module"
8
+ autoload :Order, "whmcs/order"
9
+ autoload :Quote, "whmcs/quote"
10
+ autoload :Ticket, "whmcs/ticket"
11
+
12
+ class << self
13
+ attr_accessor :config
14
+ end
15
+
16
+ self.config ||= Config.new
17
+
18
+ # Pass a block to configure the WHMCS API
19
+ #
20
+ # WHMCS.configure do |config|
21
+ # config.api_username = 'apiuser'
22
+ # config.api_password = 'c4ca4238a0b923820dcc509a6f75849b'
23
+ # config.api_url = 'http://example.com/includes/api.php
24
+ # end
25
+ def self.configure
26
+ yield config
27
+ config
28
+ end
29
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'simplecov'
2
+
3
+ module SimpleCov::Configuration
4
+ def clean_filters
5
+ @filters = []
6
+ end
7
+ end
8
+
9
+ SimpleCov.configure do
10
+ clean_filters
11
+ load_adapter 'test_frameworks'
12
+ end
13
+
14
+ ENV["COVERAGE"] && SimpleCov.start do
15
+ add_filter "/.rvm/"
16
+ end
17
+ require 'rubygems'
18
+ require 'bundler'
19
+ begin
20
+ Bundler.setup(:default, :development)
21
+ rescue Bundler::BundlerError => e
22
+ $stderr.puts e.message
23
+ $stderr.puts "Run `bundle install` to install missing gems"
24
+ exit e.status_code
25
+ end
26
+ require 'test/unit'
27
+ require 'shoulda'
28
+
29
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
30
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
31
+ require 'whmcs'
32
+
33
+ class Test::Unit::TestCase
34
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestWhmcs < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whmcs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matthew J.W. Basterfield
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: crack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.8
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.8
27
+ - !ruby/object:Gem::Dependency
28
+ name: shoulda
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: jeweler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.0.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.0.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: 'whmcs: A ruby wrapper for the WHMCS API - a port of the whmcs-ruby gem
98
+ (https://github.com/dotblock/whmcs-ruby)'
99
+ email: mjwb@flexbox.co.za
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files:
103
+ - LICENSE.txt
104
+ - README.rdoc
105
+ files:
106
+ - ".document"
107
+ - ".editorconfig"
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.rdoc
111
+ - Rakefile
112
+ - VERSION
113
+ - lib/whmcs.rb
114
+ - lib/whmcs/base.rb
115
+ - lib/whmcs/client.rb
116
+ - lib/whmcs/config.rb
117
+ - lib/whmcs/invoice.rb
118
+ - lib/whmcs/misc.rb
119
+ - lib/whmcs/module.rb
120
+ - lib/whmcs/order.rb
121
+ - lib/whmcs/quote.rb
122
+ - lib/whmcs/ticket.rb
123
+ - test/helper.rb
124
+ - test/test_whmcs.rb
125
+ homepage: http://github.com/mjwb/whmcs
126
+ licenses:
127
+ - MIT
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 2.4.5
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: 'whmcs: A Ruby wrapper for the WHMCS API.'
149
+ test_files: []