roconnector 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,20 @@
1
+ Copyright (c) 2011 Adam Focht and Brian Roberg
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,263 @@
1
+ require 'regonlineconnector/client'
2
+ require 'regonlineconnector/parser'
3
+ require 'regonlineconnector/error'
4
+
5
+ # = regonlineconnector.rb - Regonline API Interface Library
6
+ #
7
+ # Copyright (c) 2011 Adam Focht and Brian Roberg
8
+ #
9
+ # RegonlineConnector provides a ruby interface to the RegOnline Web
10
+ # API[http://forums.regonline.com/forums/thread/1383.aspx].
11
+ #
12
+ # This class provides ruby-friendly method names that return
13
+ # parsed RegOnline provided via hashes of hashes.
14
+ #
15
+ # == Example
16
+ #
17
+ # === Authentication
18
+ #
19
+ # require 'regonlineconnector'
20
+ #
21
+ # roc = RegonlineConnector.new(123456, 'joeuser', 'password')
22
+ #
23
+ # if !roc.authenticate
24
+ # puts "Invalid Credentials"
25
+ # end
26
+ #
27
+ # === Getting All Events
28
+ #
29
+ # require 'regonlineconnector'
30
+ # require 'pp'
31
+ #
32
+ # roc = RegonlineConnector.new(123456, 'joeuser', 'password')
33
+ #
34
+ # events = roc.events(654321)
35
+ # pp events
36
+ #
37
+ class RegonlineConnector
38
+ def initialize(account_id, username, password)
39
+ @client = RegonlineConnector::Client.new(account_id, username, password)
40
+ @parser = RegonlineConnector::Parser.new
41
+ end
42
+
43
+ # Returns boolean indicating whether valid login credentials have
44
+ # been supplied.
45
+ def authenticate
46
+ @authenticate = @client.authenticate
47
+ end
48
+
49
+ # Returns hashed data from RegOnline's getEvents.byAccountID method.
50
+ def events
51
+ events = @client.getEvents.ByAccountID
52
+ if events.include?("The credentials you supplied are not valid.")
53
+ raise RegonlineConnector::AuthenticationError
54
+ end
55
+ @parser.parse_events(events)
56
+ end
57
+
58
+ # Returns hashed data from RegOnline's getEvents.byAccountIDEventID method.
59
+ def event(event_id)
60
+ event = @client.getEvents.ByAccountIDEventID(event_id)
61
+ if event.include?('The credentials you supplied are not valid.')
62
+ raise RegonlineConnector::AuthenticationError
63
+ end
64
+ @parser.parse_events(event)
65
+ end
66
+
67
+ # Returns hashed data from RegOnline's getEvents.byAccountIDWithFilters
68
+ # method.
69
+ def filtered_events(filter_hash, filter_operator, filter_like_matching)
70
+ unless filter_like_matching == 'true' || filter_like_matching == 'false'
71
+ raise ArgumentError, "filter_like_matching argument must be either 'true' or 'false'"
72
+ end
73
+ unless filter_operator == 'and' || filter_operator == 'or'
74
+ raise ArgumentError, "filter_operator argument must be either 'and' or 'or'"
75
+ end
76
+ unless filter_hash.instance_of?(Hash)
77
+ raise ArgumentError, "filter hash must be hash"
78
+ end
79
+ if filter_hash.empty?
80
+ raise ArgumentError, "filter hash must not be empty"
81
+ end
82
+
83
+ filter_xml = "<filters>"
84
+ filter_hash.sort.each {|filter, value| filter_xml << "<#{filter}>#{value}</#{filter}>"}
85
+ filter_xml << "</filters>"
86
+
87
+ begin
88
+ events = @client.getEvents.ByAccountIDWithFilters(filter_xml, filter_operator, filter_like_matching)
89
+ rescue SOAP::FaultError
90
+ raise RegonlineConnector::RegonlineServerError
91
+ end
92
+
93
+ if events.include?('The credentials you supplied are not valid.')
94
+ raise RegonlineConnector::AuthenticationError
95
+ end
96
+ @parser.parse_events(events)
97
+ end
98
+
99
+ # Returns hashed data from RegOnline's geteventfields.RetrieveEventFields2
100
+ # method.
101
+ def event_fields(event_id, exclude_amounts="false")
102
+ begin
103
+ @parser.parse_event_fields(@client.getEventFields(event_id, exclude_amounts).RetrieveEventFields2)
104
+ rescue SOAP::FaultError => exception
105
+ if exception.to_s.include?("Authentication failure")
106
+ raise RegonlineConnector::AuthenticationError
107
+ else
108
+ raise RegonlineConnector::RegonlineServerError
109
+ end
110
+ end
111
+ end
112
+
113
+ # Returns hashed data from RegOnline's getEventRegistrations method.
114
+ def simple_event_registrations(event_id)
115
+ begin
116
+ @parser.parse_registrations(@client.getEventRegistrations(event_id).RetrieveRegistrationInfo)
117
+ rescue SOAP::FaultError => exception
118
+ if exception.to_s.include?("Authentication failure")
119
+ raise RegonlineConnector::AuthenticationError
120
+ else
121
+ raise RegonlineConnector::RegonlineServerError
122
+ end
123
+ end
124
+ end
125
+
126
+ # Returns hashed data from RegOnline's retrieveAllRegistrations method.
127
+ def event_registrations(event_id)
128
+ begin
129
+ @parser.parse_registrations(@client.retrieveAllRegistrations(event_id).RetrieveAllRegistrations)
130
+ rescue SOAP::FaultError => exception
131
+ if exception.to_s.include?("Authentication failure")
132
+ raise RegonlineConnector::AuthenticationError
133
+ else
134
+ raise RegonlineConnector::RegonlineServerError
135
+ end
136
+ end
137
+ end
138
+
139
+ # Returns hashed data from RegOnline's retrieveSingleRegistration
140
+ # method.
141
+ def registration(event_id, registration_id)
142
+ begin
143
+ @parser.parse_registrations(@client.retrieveSingleRegistration(event_id, registration_id).RetrieveSingleRegistration)
144
+ rescue SOAP::FaultError => exception
145
+ if exception.to_s.include?("Authentication failure")
146
+ raise RegonlineConnector::AuthenticationError
147
+ else
148
+ raise RegonlineConnector::RegonlineServerError
149
+ end
150
+ end
151
+ end
152
+
153
+ # Returns hashed data from RegOnline's RegOnline.getReport
154
+ # method.
155
+ def report(report_id, event_id, start_date, end_date, add_date)
156
+ unless add_date == 'true' || add_date == 'false'
157
+ raise ArgumentError, "add_date argument must be either 'true' or 'false'"
158
+ end
159
+ start_t = Date.parse(start_date)
160
+ end_t = Date.parse(end_date)
161
+ unless start_t < DateTime.now
162
+ raise ArgumentError, "start_time argument cannot be in future"
163
+ end
164
+ unless end_t < DateTime.now
165
+ raise ArgumentError, "end_time argument cannot be in future"
166
+ end
167
+ unless start_t < end_t
168
+ raise ArgumentError, "start time must be before end time cannot be in future"
169
+ end
170
+
171
+ registrations = @client.regOnline(report_id, event_id, start_date, end_date, add_date).getReport
172
+ if registrations.include?("Error 4458") && @client.authenticate == false
173
+ raise RegonlineConnector::AuthenticationError
174
+ end
175
+ @parser.parse_report(registrations)
176
+ end
177
+
178
+ # Updates regonline registrations from an XML file using the
179
+ # RegistrationUpdateService.UpdateRegistrations method.
180
+ def update_registrations(event_id, update_data_hash)
181
+ unless event_id.kind_of?(Integer)
182
+ raise ArgumentError, "event_id must be integer"
183
+ end
184
+ unless event_id > 0
185
+ raise ArgumentError, "event_id must be positive integer"
186
+ end
187
+ unless update_data_hash.instance_of?(Hash)
188
+ raise ArgumentError, "update data hash must be hash"
189
+ end
190
+ if update_data_hash.empty?
191
+ raise ArgumentError, "update data hash must not be empty"
192
+ end
193
+
194
+ registrations_to_be_updated = update_data_hash.keys.sort
195
+ registration_updater = @client.registrationUpdateService
196
+ request_xml = registration_updater.generate_request_xml(event_id, update_data_hash)
197
+
198
+ begin
199
+ response_xml = registration_updater.UpdateRegistrations(request_xml)
200
+ rescue SOAP::FaultError => exception
201
+ if exception.to_s.include?("Authentication failure")
202
+ raise RegonlineConnector::AuthenticationError
203
+ else
204
+ raise RegonlineConnector::RegonlineServerError
205
+ end
206
+ end
207
+
208
+ updated_registrations = @parser.parse_updated_registrations(response_xml)
209
+ updated_registrations.sort!
210
+
211
+ if registrations_to_be_updated != updated_registrations
212
+ raise RegonlineConnector::ResponseError
213
+ end
214
+
215
+ updated_registrations
216
+ end
217
+
218
+
219
+ #--
220
+ ############################################################################
221
+ # The following methods are not expected to be implemented at this time. #
222
+ # Feel free to implement them as desired and contribute them. :) #
223
+ ############################################################################
224
+ #++
225
+
226
+ # Uses the checkinreg.CheckIn method to check an attendee in.
227
+ # <b><em>Not implemented.</em></b>
228
+ def check_in(registration_id, event_id)
229
+ raise NotImplementedError
230
+ end
231
+
232
+ # Uses the customfieldresponse.modify method to assign a dna code to an
233
+ # attendee. <b><em>Not implemented.</em></b>
234
+ def assign_dna(registration_id, event_id, custom_field_id, dna_code)
235
+ raise NotImplementedError
236
+ end
237
+
238
+ # Uses the customfieldresponse.AssignSeat method to assign a seat for an
239
+ # attendee. <b><em>Not implemented.</em></b>
240
+ def assign_seat(registration_id, event_id, custom_field_id, level_id,
241
+ section_id, row_id, seat_id, block_code)
242
+ raise NotImplementedError
243
+ end
244
+
245
+ # Uses the registrationWS.Modify method to assign a resource group to an
246
+ # attendee. <b><em>Not implemented.</em></b>
247
+ def assign_resource_group(registration_id, resource_group_id)
248
+ raise NotImplementedError
249
+ end
250
+
251
+ # Uses the registrationWS.assignRoomSharerID method to assign a room sharer
252
+ # to an attendee. <b><em>Not implemented.</em></b>
253
+ def assign_room_sharer(registration_id, room_sharer_id)
254
+ raise NotImplementedError
255
+ end
256
+
257
+ # Uses the SetCustomFieldResponseStatus.setStatus method to set an attendee's
258
+ # custom field response status. <b><em>Not implemented.</em></b>
259
+ def set_custom_field_response_status(registration_id, custom_field_id,
260
+ status_id)
261
+ raise NotImplementedError
262
+ end
263
+ end
@@ -0,0 +1,122 @@
1
+ require 'regonlineconnector/client/geteventfields'
2
+ require 'regonlineconnector/client/geteventregistrations'
3
+ require 'regonlineconnector/client/getevents'
4
+ require 'regonlineconnector/client/registrationupdateservice'
5
+ require 'regonlineconnector/client/regonline'
6
+ require 'regonlineconnector/client/retrieveallregistrations'
7
+ require 'regonlineconnector/client/retrievesingleregistration'
8
+ require 'regonlineconnector/client/registrationupdateservice'
9
+ require 'base64'
10
+ require 'md5'
11
+ require 'rubygems'
12
+ require 'zip/zip'
13
+
14
+
15
+ class RegonlineConnector
16
+
17
+ # The client class handles the communication objects, containing
18
+ # the account_id, username, and password, once authenticated.
19
+ class Client
20
+ def initialize(account_id, username, password)
21
+ @account_id = account_id
22
+ @username = username
23
+ @password = password
24
+ end
25
+
26
+ # Provides interface to authentication method.
27
+ def authenticate
28
+ authenticate = RegonlineConnector::Client::GetEvents.new(@account_id,
29
+ @username,
30
+ @password)
31
+ authenticate.Authenticate
32
+ end
33
+
34
+ # Provides interface to GetEvents method, returning GetEvents object.
35
+ def getEvents
36
+ get_events = RegonlineConnector::Client::GetEvents.new(@account_id,
37
+ @username,
38
+ @password)
39
+ end
40
+
41
+ # Provides interface to GetEventFields method, returning
42
+ # GetEventFields object.
43
+ def getEventFields(event_id, exclude_amounts = "false")
44
+ get_event_fields =
45
+ RegonlineConnector::Client::GetEventFields.new(event_id,
46
+ @username,
47
+ @password,
48
+ exclude_amounts)
49
+ end
50
+
51
+ # Provides interface to GetEventRegistrations method, returning
52
+ # GetEventRegistrations object.
53
+ def getEventRegistrations(event_id)
54
+ get_event_registrations =
55
+ RegonlineConnector::Client::GetEventRegistrations.new(event_id,
56
+ @username,
57
+ @password)
58
+ end
59
+
60
+ # Provides interface to RetrieveAllRegistrations method, returning
61
+ # RetrieveAllRegistrations object.
62
+ def retrieveAllRegistrations(event_id)
63
+ retrieve_all_registrations =
64
+ RegonlineConnector::Client::RetrieveAllRegistrations.new(event_id,
65
+ @username,
66
+ @password)
67
+ end
68
+
69
+ # Provides interface to RetrieveSingleRegistration method, returning
70
+ # RetrieveSingleRegistration object.
71
+ def retrieveSingleRegistration(event_id, registration_id)
72
+ retrieve_single_registration =
73
+ RegonlineConnector::Client::RetrieveSingleRegistration.new(event_id,
74
+ registration_id,
75
+ @username,
76
+ @password)
77
+ end
78
+
79
+ # Provides interface to RegOnline method, returning RegOnline object.
80
+ def regOnline(report_id, event_id, start_date, end_date, add_date)
81
+ report_service =
82
+ RegonlineConnector::Client::RegOnline.new(@account_id, @username, @password,
83
+ report_id, event_id, start_date,
84
+ end_date, add_date)
85
+ end
86
+
87
+ # Provides interface to RegistrationUpdateService method, returning
88
+ # RegistrationUpdateService object.
89
+ def registrationUpdateService
90
+ registration_update_service =
91
+ RegonlineConnector::Client::RegistrationUpdateService.new(@username, @password)
92
+ end
93
+
94
+ private
95
+
96
+ # Takes base64 encoded string of zipped info and returns decoded
97
+ # and unzipped response.
98
+ def self.zip_to_xml(response)
99
+ response_decoded = Base64.decode64(response)
100
+
101
+ tmp_dir = Dir::tmpdir
102
+ zip_tmp = tmp_dir + '/' + MD5.md5(rand(1234567).to_s).to_s
103
+
104
+ File.open(zip_tmp, 'wb') do |f|
105
+ f.puts response_decoded
106
+ end
107
+
108
+ xml_response = '<?xml version="1.0" encoding="utf-8"?>'
109
+ xml_response << '<string xmlns="http://www.regonline.com/webservices/">'
110
+ Zip::ZipInputStream::open(zip_tmp) do |io|
111
+ io.get_next_entry
112
+ ic = Iconv.new("UTF-8", "UTF-16")
113
+ xml_response << ic.iconv(io.read)
114
+ end
115
+ xml_response << '</string>'
116
+
117
+ File.delete(zip_tmp)
118
+
119
+ xml_response
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,32 @@
1
+ require 'soap/wsdlDriver'
2
+
3
+ class RegonlineConnector
4
+
5
+ class Client
6
+
7
+ # This class provides RegOnline's
8
+ # getEventFields.asmx[http://www.regonline.com/webservices/geteventFields.asmx]
9
+ # service.
10
+ class GetEventFields
11
+
12
+ def initialize(event_id, username, password, exclude_amounts)
13
+ @event_id = event_id
14
+ @username = username
15
+ @password = password
16
+ @exclude_amounts = exclude_amounts
17
+ @wsdl = 'http://www.regonline.com/webservices/getEventFields.asmx?WSDL'
18
+ @field_getter = SOAP::WSDLDriverFactory.new(@wsdl).create_rpc_driver
19
+ end
20
+
21
+ # Provides access to the RetrieveEventFields2 SOAP operation.
22
+ def RetrieveEventFields2
23
+ response = @field_getter.RetrieveEventFields2(
24
+ {"login" => @username,
25
+ "password" => @password,
26
+ "eventID" => @event_id,
27
+ "excludeAmounts" => @exclude_amounts})
28
+ response.retrieveEventFields2Result
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,30 @@
1
+ require 'soap/wsdlDriver'
2
+
3
+ class RegonlineConnector
4
+
5
+ class Client
6
+
7
+ # This class provides RegOnline's
8
+ # getEventRegistrations.asmx[http://www.regonline.com/webservices/geteventregistrations.asmx]
9
+ # service.
10
+ class GetEventRegistrations
11
+
12
+ def initialize(event_id, username, password )
13
+ @event_id = event_id
14
+ @username = username
15
+ @password = password
16
+ @wsdl = 'http://www.regonline.com/webservices/getEventRegistrations.asmx?WSDL'
17
+ @registrant_getter = SOAP::WSDLDriverFactory.new(@wsdl).create_rpc_driver
18
+ end
19
+
20
+ # Provides access to the RetrieveRegistrationInfo SOAP operation.
21
+ def RetrieveRegistrationInfo
22
+ response = @registrant_getter.RetrieveRegistrationInfo(
23
+ {"login" => @username,
24
+ "password" => @password,
25
+ "eventID" => @event_id})
26
+ response.retrieveRegistrationInfoResult
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,62 @@
1
+ require 'soap/wsdlDriver'
2
+
3
+ class RegonlineConnector
4
+
5
+ # The Client class handles communication with RegOnline.
6
+ class Client
7
+
8
+ # This class provides RegOnline's
9
+ # getEvents.asmx[https://www.regonline.com/webservices/getEvents.asmx]
10
+ # service.
11
+ class GetEvents
12
+ def initialize( account_id, username, password )
13
+ @account_id = account_id
14
+ @username = username
15
+ @password = password
16
+ @wsdl = 'http://www.regonline.com/webservices/getEvents.asmx?WSDL'
17
+ @event_getter = SOAP::WSDLDriverFactory.new(@wsdl).create_rpc_driver
18
+ end
19
+
20
+ # Test whether valid authentication credentials have been provided (by
21
+ # attempting to get a list of events).
22
+ def Authenticate
23
+ response = @event_getter.ByAccountID({"AccountID" => @account_id,
24
+ "Username" => @username,
25
+ "Password" => @password})
26
+ if response.byAccountIDResult == 'The credentials you supplied are not valid.'
27
+ return false
28
+ else
29
+ return true
30
+ end
31
+ end
32
+
33
+ # Provides access to the ByAccountID SOAP operation.
34
+ def ByAccountID
35
+ response = @event_getter.ByAccountID({"AccountID" => @account_id,
36
+ "Username" => @username,
37
+ "Password" => @password})
38
+ response.byAccountIDResult
39
+ end
40
+
41
+ # Provides access to the ByAccountIDEventID SOAP operation.
42
+ def ByAccountIDEventID(event_id)
43
+ response = @event_getter.ByAccountIDEventID({"AccountID" => @account_id,
44
+ "Username" => @username,
45
+ "Password" => @password,
46
+ "EventId" => event_id})
47
+ response.byAccountIDEventIDResult
48
+ end
49
+
50
+ # Provides access to the ByAccountIDWithFilters SOAP operation.
51
+ def ByAccountIDWithFilters(filter_xml, filter_operator, filter_like_matching)
52
+ response = @event_getter.ByAccountIDWithFilters({"AccountID" => @account_id,
53
+ "Username" => @username,
54
+ "Password" => @password,
55
+ "xmlFilterData" => filter_xml,
56
+ "FilterOperator" => filter_operator,
57
+ "LikeMatching" => filter_like_matching})
58
+ response.byAccountIDWithFiltersResult
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,91 @@
1
+ require 'soap/wsdlDriver'
2
+
3
+ class RegonlineConnector
4
+
5
+ # The Client class handles communication with RegOnline.
6
+ class Client
7
+
8
+ # This class provides RegOnline's
9
+ # RegistrationUpdateService.asmx[https://www.regonline.com/webservices/RegistrationUpdateService.asmx]
10
+ # service.
11
+ class RegistrationUpdateService
12
+ def initialize( username, password )
13
+ @username = username
14
+ @password = password
15
+ end
16
+
17
+ # Provides access to the UpdateRegistrations SOAP operation.
18
+ def UpdateRegistrations(request_xml)
19
+ request = SOAP::StreamHandler::ConnectionData.new(request_xml)
20
+ stream = SOAP::HTTPStreamHandler.new(SOAP::Property.new)
21
+ resp_data = stream.send('http://www.regonline.com/webservices/RegistrationUpdateService.asmx',
22
+ request,
23
+ "http://www.regonline.com/webservices/2007/08/RegistrationUpdateService/UpdateRegistrations"
24
+ )
25
+ resp_data.receive_string
26
+ end
27
+
28
+ # Takes event id and hash of update data and returns regonline-friendly xml request xml.
29
+ #
30
+ # Example update_data_hash structure:
31
+ #
32
+ # update_data_hash = {registration_id => {
33
+ # "agenda_items" => {"Field Name" => "Field Value"}
34
+ # "custom_fields" => {"Field Name" => "Field Value"}
35
+ # "fees" => {"Field Name" => "Field Value"}
36
+ # }
37
+ # }
38
+ #
39
+ # where all three sub hashes are optional, as long as at least one exists.
40
+ def generate_request_xml(event_id, update_data_hash)
41
+ envelope = SOAP::SOAPEnvelope.new(update_registrations_request_header,
42
+ update_registrations_request(event_id, update_data_hash))
43
+ request_string = SOAP::Processor.marshal(envelope)
44
+ end
45
+
46
+ private
47
+
48
+ # Generates request header for updating registrations from stored username and password.
49
+ def update_registrations_request_header
50
+ header = SOAP::SOAPHeader.new
51
+ request_header = SOAP::SOAPElement.new('updateRegistrationsRequestHeader', '')
52
+ request_header.extraattr['xmlns'] = 'http://www.regonline.com/webservices/2007/08/RegistrationUpdateService'
53
+ request_header.add(SOAP::SOAPElement.new('login', @username))
54
+ request_header.add(SOAP::SOAPElement.new('password', @password))
55
+ header.add(nil, request_header)
56
+ header
57
+ end
58
+
59
+ # Generates request body from passed event id and update data hash.
60
+ def update_registrations_request(event_id, update_data_hash)
61
+ body_item = SOAP::SOAPElement.new('UpdateRegistrationsRequest', nil)
62
+ body_item.extraattr['xmlns'] = 'http://www.regonline.com/webservices/2007/08/RegistrationUpdateService'
63
+ event_id_xml = SOAP::SOAPElement.new('eventID', event_id.to_s)
64
+ event_id_xml.extraattr['xmlns'] = 'http://www.regonline.com/webservices/2007/08/RegistrationUpdateServiceTypes'
65
+ body_item.add(event_id_xml)
66
+ registrations = SOAP::SOAPElement.new('registrations', nil)
67
+ registrations.extraattr['xmlns'] = 'http://www.regonline.com/webservices/2007/08/RegistrationUpdateServiceTypes'
68
+
69
+ update_data_hash.each do |registration_id, registration_data|
70
+ registration = SOAP::SOAPElement.new('registration', nil)
71
+ registration.add(SOAP::SOAPElement.new('registrationId', registration_id.to_s))
72
+
73
+ custom_fields = SOAP::SOAPElement.new('customFields', nil)
74
+ registration_data['custom_fields'].each do |field_name, field_value|
75
+ custom_field = SOAP::SOAPElement.new('customField', nil)
76
+ custom_field.add(SOAP::SOAPElement.new('fieldName', field_name))
77
+ custom_field.add(SOAP::SOAPElement.new('value', field_value))
78
+ custom_field.add(SOAP::SOAPElement.new('quantity', '1'))
79
+ custom_fields.add(custom_field)
80
+ end
81
+ registration.add(custom_fields)
82
+ registrations.add(registration)
83
+ end
84
+
85
+ body_item.add(registrations)
86
+ body = SOAP::SOAPBody.new(body_item)
87
+ end
88
+ end
89
+ end
90
+ end
91
+
@@ -0,0 +1,46 @@
1
+ require 'soap/wsdlDriver'
2
+
3
+ class RegonlineConnector
4
+
5
+ class Client
6
+
7
+ # This class provides RegOnline's
8
+ # RegOnline.asmx[http://www.regonline.com/activereports/RegOnline.asmx]
9
+ # service.
10
+ class RegOnline
11
+
12
+ def initialize(account_id, username, password, report_id, event_id, start_date, end_date, add_date)
13
+ @account_id = account_id
14
+ @username = username
15
+ @password = password
16
+ @report_id = report_id
17
+ @event_id = event_id
18
+ @start_date = start_date
19
+ @end_date = end_date
20
+ @add_date = add_date
21
+ @wsdl = 'http://www.regonline.com/activereports/RegOnline.asmx?WSDL'
22
+ @report_getter = SOAP::WSDLDriverFactory.new(@wsdl).create_rpc_driver
23
+ end
24
+
25
+ # Provides access to the getReport SOAP operation.
26
+ def getReport
27
+ response = @report_getter.getReport({"login" => @username,
28
+ "pass" => @password,
29
+ "customerID" => @account_id,
30
+ "reportID" => @report_id,
31
+ "eventID" => @event_id,
32
+ "startDate" => @start_date,
33
+ "endDate" => @end_date,
34
+ "bAddDate" => @add_date})
35
+
36
+ if response.getReportResult == 'Error 4458: unable to process request.'
37
+ return response.getReportResult
38
+ else
39
+ return registrations = RegonlineConnector::Client::zip_to_xml(
40
+ response.getReportResult)
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,32 @@
1
+ require 'soap/wsdlDriver'
2
+
3
+ class RegonlineConnector
4
+
5
+ class Client
6
+
7
+ # This class provides RegOnline's
8
+ # RetrieveAllRegistrations.asmx[http://www.regonline.com/webservices/RetrieveAllRegistrations.asmx]
9
+ # service.
10
+ class RetrieveAllRegistrations
11
+
12
+ def initialize(event_id, username, password )
13
+ @event_id = event_id
14
+ @username = username
15
+ @password = password
16
+ @wsdl = 'http://www.regonline.com/webservices/RetrieveAllRegistrations.asmx?WSDL'
17
+ @registration_getter = SOAP::WSDLDriverFactory.new(@wsdl).create_rpc_driver
18
+ end
19
+
20
+ # Provides access to the RetrieveAllRegistrations SOAP operation.
21
+ def RetrieveAllRegistrations
22
+ response = @registration_getter.RetrieveAllRegistrations(
23
+ {"customerUserName" => @username,
24
+ "customerPassword" => @password,
25
+ "eventID" => @event_id})
26
+
27
+ registrations = RegonlineConnector::Client::zip_to_xml(
28
+ response.retrieveAllRegistrationsResult)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,34 @@
1
+ require 'soap/wsdlDriver'
2
+
3
+ class RegonlineConnector
4
+
5
+ class Client
6
+
7
+ # This class provides RegOnline's
8
+ # RetrieveSingleRegistration.asmx[http://www.regonline.com/webservices/RetrieveSingleRegistration.asmx]
9
+ # service.
10
+ class RetrieveSingleRegistration
11
+
12
+ def initialize(event_id, registration_id, username, password)
13
+ @event_id = event_id
14
+ @registration_id = registration_id
15
+ @username = username
16
+ @password = password
17
+ @wsdl = 'http://www.regonline.com/webservices/RetrieveSingleRegistration.asmx?WSDL'
18
+ @registration_getter = SOAP::WSDLDriverFactory.new(@wsdl).create_rpc_driver
19
+ end
20
+
21
+ # Provides access to the RetrieveSingleRegistration SOAP operation.
22
+ def RetrieveSingleRegistration
23
+ response = @registration_getter.RetrieveSingleRegistration(
24
+ {"customerUserName" => @username,
25
+ "customerPassword" => @password,
26
+ "eventID" => @event_id,
27
+ "registrationID" => @registration_id})
28
+
29
+ registration = RegonlineConnector::Client::zip_to_xml(
30
+ response.retrieveSingleRegistrationResult)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,14 @@
1
+ class RegonlineConnector
2
+
3
+ # Custom error class for rescuing from all RegonlineConnector errors
4
+ class Error < StandardError; end
5
+
6
+ # Raised when Regonline reports invalid credentials
7
+ class AuthenticationError < Error; end
8
+
9
+ # Raised when Regonline server raises other SOAP fault error
10
+ class RegonlineServerError < Error; end
11
+
12
+ # Raised when Regonline server does not respond as expected
13
+ class ResponseError < Error; end
14
+ end
@@ -0,0 +1,113 @@
1
+ require 'rexml/document'
2
+ include REXML
3
+
4
+ class RegonlineConnector
5
+
6
+ class Parser
7
+ def initialize
8
+
9
+ end
10
+
11
+ # Returns hash of event hashes from events xml.
12
+ def parse_events(response)
13
+ events = elements_to_hash(response, "//Table", "ID")
14
+ end
15
+
16
+ # Returns hash of event fields from event fields xml.
17
+ def parse_event_fields(response)
18
+ event_fields = attributes_to_hash(response, "//customField", "id", "//listItem", "name")
19
+ end
20
+
21
+ # Returns hash of registration hashes from registrations xml.
22
+ def parse_registrations(response)
23
+ registration = elements_to_hash(response, "//Registration", "registrationID")
24
+ end
25
+
26
+ # Returns hash of registration hashes from simple registrations xml.
27
+ def parse_simple_registrations(response)
28
+ registrations = attributes_to_hash(response, "//registration", "id")
29
+ end
30
+
31
+ # Returns hash of registration hashes from a report from report xml.
32
+ def parse_report(response)
33
+ response_no_escape = response.to_s.gsub!(/_x0020_/,'')
34
+ events = elements_to_hash(response, "//Table1", "ConfirmationNumber")
35
+ end
36
+
37
+ # Returns array of updated registration ids from response xml.
38
+ def parse_updated_registrations(response)
39
+ unless response
40
+ return nil
41
+ end
42
+ doc = REXML::Document.new response
43
+ updated_registrations = []
44
+ #if element = doc.elements.to_a("//updateRegistrationsResult")
45
+ # updated_registrations_string = element.text if element = doc.elements.to_a("//updateRegistrationsResult")
46
+ #end
47
+ updated_registrations_string = XPath.first( doc, "//updateRegistrationsResult").text
48
+ if updated_registrations_string
49
+ updated_registrations_string_array = updated_registrations_string.split(',')
50
+ updated_registrations_string_array.each {|registration_id| updated_registrations << registration_id.to_i}
51
+ end
52
+ updated_registrations
53
+ end
54
+
55
+ private
56
+
57
+ # Returns hash from xml elements
58
+ def elements_to_hash(xml_response, xpath, hash_id)
59
+ unless xml_response
60
+ return nil
61
+ end
62
+ doc = REXML::Document.new xml_response
63
+ entries = Hash.new
64
+ doc.elements.to_a(xpath).each do |xml_element|
65
+ entry = Hash.new
66
+ xml_element.elements.to_a.each do |el|
67
+ if el.text =~ %r{^[0-9]*$} then # Integer value
68
+ entry[el.name] = el.text.to_i
69
+ elsif el.text =~ %r{^[0-9]+\.[0-9]+$} then # Float value
70
+ entry[el.name] = el.text.to_f
71
+ else # String value
72
+ entry[el.name] = el.text
73
+ end
74
+ end
75
+ if entry[hash_id]
76
+ entries[entry[hash_id]] = entry
77
+ end
78
+ end
79
+ entries
80
+ end
81
+
82
+ # Returns hash from xml attributes
83
+ def attributes_to_hash(xml_response, xpath, hash_id, children_xpath = nil, child_attribute = nil)
84
+ unless xml_response
85
+ return nil
86
+ end
87
+ doc = REXML::Document.new xml_response
88
+ entries = Hash.new
89
+ doc.elements.to_a(xpath).each do |xml_element|
90
+ entry = Hash.new
91
+ xml_element.attributes.each do |name, value|
92
+ if value =~ %r{^[0-9]*$} then # Integer value
93
+ entry[name] = value.to_i
94
+ elsif value =~ %r{^[0-9]+\.[0-9]+$} then # Float value
95
+ entry[name] = value.to_f
96
+ else # String value
97
+ entry[name] = value
98
+ end
99
+ end
100
+ if entry[hash_id]
101
+ entries[entry[hash_id]] = entry
102
+ end
103
+ if children_xpath and xml_element.has_elements?
104
+ entry['list_items'] = []
105
+ xml_element.elements.to_a(children_xpath).each do |child_element|
106
+ entry['list_items'] << child_element.attribute(child_attribute).value if child_attribute
107
+ end
108
+ end
109
+ end
110
+ entries
111
+ end
112
+ end
113
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roconnector
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
+ - Adam Focht
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-10-16 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: A Ruby interface an online registration service's API version 1.
22
+ email: fochta@dm.org
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - lib/regonlineconnector/error.rb
31
+ - lib/regonlineconnector/client.rb
32
+ - lib/regonlineconnector/parser.rb
33
+ - lib/regonlineconnector/client/geteventfields.rb
34
+ - lib/regonlineconnector/client/retrieveallregistrations.rb
35
+ - lib/regonlineconnector/client/retrievesingleregistration.rb
36
+ - lib/regonlineconnector/client/regonline.rb
37
+ - lib/regonlineconnector/client/registrationupdateservice.rb
38
+ - lib/regonlineconnector/client/geteventregistrations.rb
39
+ - lib/regonlineconnector/client/getevents.rb
40
+ - lib/regonlineconnector.rb
41
+ - LICENSE.txt
42
+ homepage: https://github.com/disciplemakers/RO-Connector
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.8.15
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Interface to an online registration service's API version 1 (deprecated).
75
+ test_files: []
76
+