Module: ScormEngine::Api::Endpoints::Dispatches
- Included in:
- ScormEngine::Api::Endpoints
- Defined in:
- lib/scorm_engine/api/endpoints/dispatches.rb
Instance Method Summary collapse
-
#delete_dispatch(options = {}) ⇒ ScormEngine::Response
Delete a dispatch.
-
#delete_dispatch_registration_count(options = {}) ⇒ ScormEngine::Response
Reset the registration count and last reset time of a dispatch.
-
#get_dispatch(options = {}) ⇒ ScormEngine::Models::Dispatch
Get a dispatch.
-
#get_dispatch_enabled(options = {}) ⇒ ScormEngine::Response
Get the enabled status of a dispatch.
-
#get_dispatch_registration_count(options = {}) ⇒ ScormEngine::Models::DispatchRegistrationCount
Get the registration count and last reset time of a dispatch.
-
#get_dispatch_zip(options = {}) ⇒ ScormEngine::Models::DispatchZip
Get the ZIP dispatch package.
-
#get_dispatches(options = {}) ⇒ Enumerator<ScormEngine::Models::Dispatch>
Get a list of dispatches.
-
#post_dispatch(options = {}) ⇒ ScormEngine::Response
Create a dispatch.
-
#put_dispatch(options = {}) ⇒ ScormEngine::Response
Update a dispatch.
-
#put_dispatch_enabled(options = {}) ⇒ ScormEngine::Response
Enable or disable the dispatch.
Instance Method Details
#delete_dispatch(options = {}) ⇒ ScormEngine::Response
Delete a dispatch.
200 201 202 203 204 205 206 |
# File 'lib/scorm_engine/api/endpoints/dispatches.rb', line 200 def delete_dispatch( = {}) (, :dispatch_id) response = delete("dispatches/#{[:dispatch_id]}") Response.new(raw_response: response) end |
#delete_dispatch_registration_count(options = {}) ⇒ ScormEngine::Response
Reset the registration count and last reset time of a dispatch.
326 327 328 329 330 331 332 |
# File 'lib/scorm_engine/api/endpoints/dispatches.rb', line 326 def delete_dispatch_registration_count( = {}) (, :dispatch_id) response = delete("dispatches/#{[:dispatch_id]}/registrationCount") Response.new(raw_response: response) end |
#get_dispatch(options = {}) ⇒ ScormEngine::Models::Dispatch
Get a dispatch.
117 118 119 120 121 122 123 124 125 126 |
# File 'lib/scorm_engine/api/endpoints/dispatches.rb', line 117 def get_dispatch( = {}) (, :dispatch_id) response = get("dispatches/#{[:dispatch_id]}") # merge options to pick up dispatch_id which isn't passed back in the response result = response.success? ? ScormEngine::Models::Dispatch.new_from_api({ "id" => [:dispatch_id] }.merge(response.body)) : nil Response.new(raw_response: response, result: result) end |
#get_dispatch_enabled(options = {}) ⇒ ScormEngine::Response
Get the enabled status of a dispatch.
220 221 222 223 224 225 226 227 228 |
# File 'lib/scorm_engine/api/endpoints/dispatches.rb', line 220 def get_dispatch_enabled( = {}) (, :dispatch_id) response = get("dispatches/#{[:dispatch_id]}/enabled") result = response.success? ? response.body : nil Response.new(raw_response: response, result: result) end |
#get_dispatch_registration_count(options = {}) ⇒ ScormEngine::Models::DispatchRegistrationCount
Get the registration count and last reset time of a dispatch.
303 304 305 306 307 308 309 310 311 312 |
# File 'lib/scorm_engine/api/endpoints/dispatches.rb', line 303 def get_dispatch_registration_count( = {}) (, :dispatch_id) response = get("dispatches/#{[:dispatch_id]}/registrationCount") # merge options to pick up dispatch_id which isn't passed back in the response result = response.success? ? ScormEngine::Models::DispatchRegistrationCount.new_from_api({ "id" => [:dispatch_id] }.merge(response.body)) : nil Response.new(raw_response: response, result: result) end |
#get_dispatch_zip(options = {}) ⇒ ScormEngine::Models::DispatchZip
Get the ZIP dispatch package.
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/scorm_engine/api/endpoints/dispatches.rb', line 270 def get_dispatch_zip( = {}) (, :dispatch_id) = .dup dispatch_id = .delete(:dispatch_id) [:type] = [:type]&.upcase || "SCORM12" response = get("dispatches/#{dispatch_id}/zip", ) result = if response.success? ScormEngine::Models::DispatchZip.new( dispatch_id: dispatch_id, type: [:type], filename: response.headers["content-disposition"].match(/; filename="(.*?)"/)&.captures&.first, body: response.body, ) end Response.new(raw_response: response, result: result) end |
#get_dispatches(options = {}) ⇒ Enumerator<ScormEngine::Models::Dispatch>
Get a list of dispatches.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/scorm_engine/api/endpoints/dispatches.rb', line 23 def get_dispatches( = {}) = .dup response = get("dispatches", ) result = Enumerator.new do |enum| loop do response.success? && response.body["dispatches"].each do |course| enum << ScormEngine::Models::Dispatch.new_from_api(course) end break if !response.success? || response.body["more"].nil? response = get(response.body["more"]) end end Response.new(raw_response: response, result: result) end |
#post_dispatch(options = {}) ⇒ ScormEngine::Response
Create a dispatch.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/scorm_engine/api/endpoints/dispatches.rb', line 80 def post_dispatch( = {}) (, :dispatch_id, :destination_id, :course_id) = (.dup) body = { dispatches: [ id: [:dispatch_id], data: { destinationId: [:destination_id], courseId: [:course_id], allowNewRegistrations: [:allow_new_registrations], instanced: [:instanced], registrationCap: [:registration_cap], expirationDate: [:expiration_date], externalConfig: [:external_config], }, ] } response = post("dispatches", {}, body) Response.new(raw_response: response) end |
#put_dispatch(options = {}) ⇒ ScormEngine::Response
Update a dispatch.
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/scorm_engine/api/endpoints/dispatches.rb', line 167 def put_dispatch( = {}) (, :dispatch_id, :destination_id, :course_id, :allow_new_registrations, :instanced, :registration_cap, :expiration_date) = (.dup) body = { destinationId: [:destination_id], courseId: [:course_id], allowNewRegistrations: [:allow_new_registrations], instanced: [:instanced], registrationCap: [:registration_cap], expirationDate: [:expiration_date], externalConfig: [:external_config], } response = put("dispatches/#{[:dispatch_id]}", {}, body) Response.new(raw_response: response) end |
#put_dispatch_enabled(options = {}) ⇒ ScormEngine::Response
Enable or disable the dispatch.
245 246 247 248 249 250 251 252 253 |
# File 'lib/scorm_engine/api/endpoints/dispatches.rb', line 245 def put_dispatch_enabled( = {}) (, :dispatch_id, :enabled) body = [:enabled].to_s response = put("dispatches/#{[:dispatch_id]}/enabled", {}, body) Response.new(raw_response: response) end |