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,127 @@
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
+ # * <tt>:subject</tt> - Subject of the quote
9
+ # * <tt>:stage</tt> - Draft,Delivered,On Hold,Accepted,Lost,Dead
10
+ # * <tt>:validuntil</tt> - In format set in Localisation
11
+ # * <tt>:lineitems</tt> - a base64 encoded serialized array containing:
12
+ # * <tt>:desc</tt> - The line description
13
+ # * <tt>:qty</tt> - The quantity being quoted
14
+ # * <tt>:up</tt> - unit price
15
+ # * <tt>:discount</tt> - discount amount in %
16
+ # * <tt>:taxable</tt> - true or false
17
+ #
18
+ # Optional attributes:
19
+ # * <tt>:datecreated</tt> - Optional - In format set in Localisation
20
+ # * <tt>:customernotes</tt> - notes that are viewable by the client
21
+ # * <tt>:adminnotes</tt> - notes that are admin only
22
+ # * <tt>:userid</tt> - the unique id number of the client in the tblclients table
23
+ # * <tt>:firstname</tt> - optional - only required if userid is not specified
24
+ # * <tt>:lastname</tt> - optional - only required if userid is not specified
25
+ # * <tt>:companyname</tt> - optional - only required if userid is not specified
26
+ # * <tt>:email</tt> - optional - only required if userid is not specified
27
+ # * <tt>:address1</tt> - optional - only required if userid is not specified
28
+ # * <tt>:address2</tt> - optional - only required if userid is not specified
29
+ # * <tt>:city</tt> - optional - only required if userid is not specified
30
+ # * <tt>:state</tt> - optional - only required if userid is not specified
31
+ # * <tt>:postcode</tt> - optional - only required if userid is not specified
32
+ # * <tt>:country</tt> - optional - only required if userid is not specified
33
+ # * <tt>:phonenumber</tt> - optional - only required if userid is not specified
34
+ # * <tt>:currency</tt> - optional - only required if userid is not specified
35
+ #
36
+ # See:
37
+ #
38
+ # http://docs.whmcs.com/API:Create_Quote
39
+ def self.create_quote(params = {})
40
+ params.merge!(:action => 'createquote')
41
+ send_request(params)
42
+ end
43
+
44
+ # Update an existing quote
45
+ #
46
+ # Parameters:
47
+ #
48
+ # * <tt>:quoteid</tt> - the id number of the quote in tblquotes
49
+ #
50
+ # * <tt>:userid</tt> - the unique id number of the client in the tblclients table
51
+ # * <tt>:firstname</tt> - optional - only required if userid is not specified
52
+ # * <tt>:lastname</tt> - optional - only required if userid is not specified
53
+ # * <tt>:companyname</tt> - optional - only required if userid is not specified
54
+ # * <tt>:email</tt> - optional - only required if userid is not specified
55
+ # * <tt>:address1</tt> - optional - only required if userid is not specified
56
+ # * <tt>:address2</tt> - optional - only required if userid is not specified
57
+ # * <tt>:city</tt> - optional - only required if userid is not specified
58
+ # * <tt>:state</tt> - optional - only required if userid is not specified
59
+ # * <tt>:postcode</tt> - optional - only required if userid is not specified
60
+ # * <tt>:country</tt> - optional - only required if userid is not specified
61
+ # * <tt>:phonenumber</tt> - optional - only required if userid is not specified
62
+ # * <tt>:currency</tt> - optional - only required if userid is not specified
63
+ # * <tt>:subject</tt> - Subject of the quote
64
+ # * <tt>:stage</tt> - Draft,Delivered,On Hold,Accepted,Lost,Dead
65
+ # * <tt>:validuntil</tt> - In format set in Localisation
66
+ # * <tt>:datecreated</tt> - Optional - In format set in Localisation
67
+ # * <tt>:customernotes</tt> - notes that are viewable by the client
68
+ # * <tt>:adminnotes</tt> - notes that are admin only
69
+ # * <tt>:lineitems</tt> - a base64 encoded serialized array containing:
70
+ # * <tt>:id</tt> - existing lineid only required to update existing lines
71
+ # * <tt>:desc</tt> - The line description
72
+ # * <tt>:qty</tt> - The quantity being quoted
73
+ # * <tt>:up</tt> - unit price
74
+ # * <tt>:discount</tt> - discount amount in %
75
+ # * <tt>:taxable</tt> - true or false
76
+ #
77
+ # See:
78
+ #
79
+ # http://docs.whmcs.com/API:Update_Quote
80
+ def self.update_quote(params = {})
81
+ params.merge!(:action => 'updatequote')
82
+ send_request(params)
83
+ end
84
+
85
+ # Delete a quote
86
+ #
87
+ # Parameters:
88
+ #
89
+ # * <tt>:quoteid</tt> - the id number of the quote in tblquotes
90
+ #
91
+ # See:
92
+ #
93
+ # http://docs.whmcs.com/API:Delete_Quote
94
+ def self.delete_quote(params = {})
95
+ params.merge!(:action => 'deletequote')
96
+ send_request(params)
97
+ end
98
+
99
+ # Send a quote to client
100
+ #
101
+ # Parameters:
102
+ #
103
+ # * <tt>:quoteid</tt> - the id number of the quote in tblquotes
104
+ #
105
+ # See:
106
+ #
107
+ # http://docs.whmcs.com/API:Send_Quote
108
+ def self.send_quote(params = {})
109
+ params.merge!(:action => 'sendquote')
110
+ send_request(params)
111
+ end
112
+
113
+ # Accept a quote
114
+ #
115
+ # Parameters:
116
+ #
117
+ # * <tt>:quoteid</tt> - the id number of the quote in tblquotes
118
+ #
119
+ # See:
120
+ #
121
+ # http://docs.whmcs.com/API:Accept_Quote
122
+ def self.accept_quote(params = {})
123
+ params.merge!(:action => 'acceptquote')
124
+ send_request(params)
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,227 @@
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>:deptid</tt> - the ID of the ticket department
11
+ # * <tt>:subject</tt>
12
+ # * <tt>:message</tt>
13
+ #
14
+ # Optional attributes:
15
+ # * <tt>:priority</tt> - can be "Low", "Medium" or "High" (Default = Low)
16
+ # * <tt>:contactid</tt> - the ID of the contact that you wish to associate the ticket with
17
+ # * <tt>:name</tt> - only required if not a registered client (clientid must be sent as 0)
18
+ # * <tt>:email</tt> - only required if not a registered client
19
+ # * <tt>:serviceid</tt> - the ID if the ticket relates to a specific product
20
+ # * <tt>:customfields</tt> - a base 64 serialized array of field IDs => values
21
+ # * <tt>:domainid</tt> - the ID if the ticket relates to a specific domain
22
+ # * <tt>:noemail</tt> - true/false - set to stop the Ticket Opened mail being sent to the user
23
+ #
24
+ # See:
25
+ #
26
+ # http://docs.whmcs.com/API:Open_Ticket
27
+ def self.open_ticket(params = {})
28
+ params.merge!(:action => 'openticket')
29
+ send_request(params)
30
+ end
31
+
32
+ # Reply to ticket
33
+ #
34
+ # Parameters:
35
+ #
36
+ # * <tt>:ticketid</tt> - the ID of the ticket to add the reply to
37
+ # * <tt>:message</tt>
38
+ #
39
+ # Optional attributes:
40
+ # * <tt>:clientid</tt> - if adding reply as a client
41
+ # * <tt>:contactid</tt> - to be used along with clientid. contactid should be a contact within the client
42
+ # * <tt>:name</tt> - only required if not a registered client (clientid must be sent as 0)
43
+ # * <tt>:email</tt> - only required if not a registered client
44
+ # * <tt>:adminusername</tt> - if adding reply as an admin, name to show
45
+ # * <tt>:status</tt> - specify if you want to set the status to On Hold or In Progress after reply
46
+ # * <tt>:customfields</tt> - base64_encoded serialized array of custom fields associated with the ticket.
47
+ #
48
+ # See:
49
+ #
50
+ # http://docs.whmcs.com/API:Reply_Ticket
51
+ def self.reply_ticket(params = {})
52
+ params.merge!(:action => 'addticketreply')
53
+ send_request(params)
54
+ end
55
+
56
+ # Get tickets
57
+ #
58
+ # Parameters:
59
+ #
60
+ # * <tt>:limitstart</tt> - Optional start at which result (default 0)
61
+ # * <tt>:limitnum</tt> - Optional limit at how many results (default 25)
62
+ # * <tt>:clientid</tt> - Optional search for a particular client's tickets
63
+ # * <tt>:email</tt> - filter for tickets only from a specific email address
64
+ # * <tt>:deptid</tt> - Optional search in a particular department
65
+ # * <tt>:status</tt> - filter for a particular status - in addition to any individual status options, this can also take the values "Awaiting Reply", "All
66
+ # Active Tickets" or "My Flagged Tickets" to return those preset status groups
67
+ # * <tt>:subject</tt> - Optional search for a word in the subject
68
+ # * <tt>:ignore_dept_assignments</tt> - Pass this to ignore the departments the admin user belongs to. Otherwise just the tickets for the departments the API
69
+ # user belongs to are returned
70
+ #
71
+ # See:
72
+ #
73
+ # http://docs.whmcs.com/API:Get_Tickets
74
+ def self.get_tickets(params = {})
75
+ params.merge!(:action => 'gettickets')
76
+ send_request(params)
77
+ end
78
+
79
+ # Get a ticket
80
+ #
81
+ # Parameters:
82
+ #
83
+ # * <tt>:ticketid</tt> - Ticket id to retrieve
84
+ # * <tt>:ticketnum</tt> - Ticket Num to retrieve (client ticket number)
85
+ #
86
+ # See:
87
+ #
88
+ # http://docs.whmcs.com/API:Get_Ticket
89
+ def self.get_ticket(params = {})
90
+ params.merge!(:action => 'getticket')
91
+ send_request(params)
92
+ end
93
+
94
+
95
+ # Get Ticket Notes
96
+ #
97
+ # Parameters:
98
+ # * <tt>:ticketid</tt> - Ticket ID to obtain the notes for
99
+ #
100
+ #
101
+ # See:
102
+ #
103
+ # http://docs.whmcs.com/API:Get_Ticket_Notes
104
+ def self.get_ticket_notes(params = {})
105
+ params.merge!(:action => 'getticketnotes')
106
+ send_request(params)
107
+ end
108
+
109
+ # Update an existing ticket
110
+ #
111
+ # Parameters:
112
+ #
113
+ # * <tt>:ticketid</tt> - Ticket ID to be updated
114
+ #
115
+ # Optional attributes:
116
+ # * <tt>:deptid</tt> - update the assigned department
117
+ # * <tt>:subject</tt>
118
+ # * <tt>:priority</tt> - Low, Medium or High
119
+ # * <tt>:status</tt> - Open, Answered, Closed, etc...
120
+ # * <tt>:userid</tt> - change the user that the ticket is assigned to
121
+ # * <tt>:email</tt> - change the email address that opened the ticket (only when userid is not used)
122
+ # * <tt>:cc</tt> - add CC emails to the ticket
123
+ # * <tt>:flag</tt> - flag to an adminid
124
+ #
125
+ # See:
126
+ #
127
+ # http://docs.whmcs.com/API:Update_Ticket
128
+ def self.update_ticket(params = {})
129
+ params.merge!(:action => 'updateticket')
130
+ send_request(params)
131
+ end
132
+
133
+ # Add a note to an existing ticket
134
+ #
135
+ # Parameters:
136
+ #
137
+ # * <tt>:ticketid</tt> - Ticket ID the note is to be added
138
+ # * <tt>:ticketnum</tt> - The Ticket number of the note. Please note that you can only use either ticketnum or ticketid and not both.
139
+ # * <tt>:message</tt> - The not to add
140
+ #
141
+ # See:
142
+ #
143
+ # http://docs.whmcs.com/API:Add_Ticket_Note
144
+ def self.add_ticket_note(params = {})
145
+ params.merge!(:action => 'addticketnote')
146
+ send_request(params)
147
+ end
148
+
149
+ # Delete an existing ticket
150
+ #
151
+ # Parameters:
152
+ #
153
+ # * <tt>:ticketid</tt> - Ticket ID to be deleted
154
+ #
155
+ # See:
156
+ #
157
+ # http://docs.whmcs.com/API:Delete_Ticket
158
+ def self.delete_ticket(params = {})
159
+ params.merge!(:action => 'deleteticket')
160
+ send_request(params)
161
+ end
162
+
163
+ # Delete Ticket Note
164
+ #
165
+ # Parameters:
166
+ # * <tt>:noteid</tt> - Note ID to be removed [See: Get Ticket Notes](http://docs.whmcs.com/API:Get_Ticket_Notes)
167
+ #
168
+ # See:
169
+ #
170
+ # http://docs.whmcs.com/API:Delete_Ticket_Note
171
+ def self.delete_ticket_note(params = {})
172
+ params.merge!(:action => 'deleteticketnote')
173
+ send_request(params)
174
+ end
175
+
176
+ # Get support departments
177
+ # This command is used to retrieve an XML list of Support Departments and counts of tickets Open and Awaiting reply.
178
+ #
179
+ # Optional attributes:
180
+ # * <tt>:ignore_dept_assignments</tt> - send as true to ignore the departments that the API user is assigned to
181
+ #
182
+ # See:
183
+ #
184
+ # http://docs.whmcs.com/API:Get_Support_Departments
185
+ def self.get_support_departments
186
+ send_request(:action => 'getsupportdepartments')
187
+ end
188
+
189
+ # Get support statuses
190
+ #
191
+ # Optional attributes:
192
+ #
193
+ # * <tt>:deptid</tt> - Optional - Send a Department ID to limit results
194
+ #
195
+ # See:
196
+ #
197
+ # http://docs.whmcs.com/API:Get_Support_Statuses
198
+ def self.get_support_statuses(params = {})
199
+ params.merge!(:action => 'getsupportstatuses')
200
+ send_request(params)
201
+ end
202
+
203
+ # Get ticket predefined categories
204
+ #
205
+ # See:
206
+ #
207
+ # http://docs.whmcs.com/API:Get_Ticket_Predefined_Cats
208
+ def self.get_ticket_predefined_cats
209
+ params.merge!(:action => 'getticketpredefinedcats')
210
+ send_request(params)
211
+ end
212
+
213
+ # Get ticket predefined replies
214
+ #
215
+ # Optional attributes:
216
+ #
217
+ # * <tt>:catid</tt> - Optional Select category to browse
218
+ #
219
+ # See:
220
+ #
221
+ # http://docs.whmcs.com/API:Get_Ticket_Predefined_Replies
222
+ def self.get_ticket_predefined_repies(params = {})
223
+ params.merge!(:action => 'getsupportstatuses')
224
+ send_request(params)
225
+ end
226
+ end
227
+ end
@@ -0,0 +1,3 @@
1
+ module WHMCS #:nodoc:
2
+ VERSION = Version = '0.0.2'
3
+ end
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ require 'simplecov'
5
+ require 'coveralls'
6
+
7
+
8
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
9
+ SimpleCov.start do
10
+ add_filter '/_test.rb/'
11
+ end
12
+
13
+ #Coveralls.wear!
14
+
15
+ begin
16
+ require 'turn'
17
+ rescue LoadError
18
+ end
19
+
20
+ require 'whmcs'
21
+
22
+ WHMCS.configure do |config|
23
+ config.api_username = ENV['WHMCS_USER'] or raise "You must set the env variable WHMCS_USER"
24
+ config.api_password = ENV['WHMCS_PASS'] or raise "You must set the env variable WHMCS_PASS"
25
+ config.api_url = ENV['WHMCS_URL'] or raise "You must set the env variable WHMCS_URL"
26
+ config.api_key = ENV['WHMCS_KEY'] or raise "There must be a present key for WHMCS_KEY"
27
+ end
@@ -0,0 +1,29 @@
1
+ require_relative 'test_helper'
2
+
3
+ class WHMCSAnnouncementTest < Test::Unit::TestCase
4
+ # dummy testing of announcement functionality
5
+ def test__basic_announcement_crud__passingValidData
6
+ passing_data = {
7
+ :date => '2014-04-01',
8
+ :title => 'Test Announcement1',
9
+ :announcement => 'Test Hello World announcement',
10
+ :published => 'off'
11
+ }
12
+
13
+ resulted_announce = WHMCS::Announcement.get_announcements()
14
+
15
+ resulted = WHMCS::Announcement.add_announcement( passing_data )
16
+
17
+ updated_announcement = WHMCS::Announcement.update_announcement(
18
+ :announcementid => resulted['announcementid'],
19
+ :title => 'Test Hello World announcement 2'
20
+ )
21
+
22
+ deleted_announcement = WHMCS::Announcement.delete_announcement(:announcementid => resulted['announcementid'])
23
+
24
+ assert_equal('success', updated_announcement['result'])
25
+ assert_equal(resulted['announcementid'], deleted_announcement['announcementid'])
26
+ assert_equal('success', deleted_announcement['result'])
27
+ assert_equal('success', resulted['result'])
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'test_helper'
2
+
3
+ class WHMCSTest < Test::Unit::TestCase
4
+ # in certain occasions encrypt call returns hash that includes '='
5
+ def test__parse_response__parsedCorrectlyHashesWithEqSign
6
+ expected = "result=succes;password=12lkjdfosifusdlfsdfmlasdof==;"
7
+ parsed = WHMCS::Base.parse_response(expected)
8
+ assert_equal('12lkjdfosifusdlfsdfmlasdof==', parsed['password'])
9
+ end
10
+
11
+ def test__send_request__returningHash
12
+ resulted = WHMCS::Base.send_request(:action => 'do_me_a_favor')
13
+ assert resulted.is_a?(Hash)
14
+ assert_equal('Command Not Found', resulted['message'])
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whmcs-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Andrey Vystavkin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-02 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
+ description: 'whmcs-api: Ruby bindings for the WHMCS API'
42
+ email: jujav4ik@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files:
46
+ - README.md
47
+ files:
48
+ - Rakefile
49
+ - README.md
50
+ - lib/whmcs/announcement.rb
51
+ - lib/whmcs/base.rb
52
+ - lib/whmcs/client.rb
53
+ - lib/whmcs/config.rb
54
+ - lib/whmcs/domain.rb
55
+ - lib/whmcs/invoice.rb
56
+ - lib/whmcs/misc.rb
57
+ - lib/whmcs/module.rb
58
+ - lib/whmcs/order.rb
59
+ - lib/whmcs/quote.rb
60
+ - lib/whmcs/ticket.rb
61
+ - lib/whmcs/version.rb
62
+ - lib/whmcs.rb
63
+ - test/test_helper.rb
64
+ - test/whmcs_announcement_test.rb
65
+ - test/whmcs_test.rb
66
+ homepage: https://github.com/jujav4ik/whmcs-api
67
+ licenses: []
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options:
71
+ - --charset=UTF-8
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.0.6
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: 'whmcs-api: Ruby bindings for the WHMCS API'
90
+ test_files: []