Module: ScormEngine::Api::Endpoints::Destinations
- Included in:
- ScormEngine::Api::Endpoints
- Defined in:
- lib/scorm_engine/api/endpoints/destinations.rb
Instance Method Summary collapse
-
#delete_destination(options = {}) ⇒ ScormEngine::Response
Delete a destination.
-
#get_destination(options = {}) ⇒ ScormEngine::Models::Destination
Get a destination.
-
#get_destination_dispatches_registration_count(options = {}) ⇒ Integer
Get an aggregate count of all related dispatch registrations.
-
#get_destinations(options = {}) ⇒ Enumerator<ScormEngine::Models::Destination>
Get a list of destinations.
-
#post_destination(options = {}) ⇒ ScormEngine::Response
Create a destination.
-
#post_destination_dispatches_enabled(options = {}) ⇒ ScormEngine::Response
Enable or disable all related dispatches.
-
#post_destination_dispatches_registration_instancing(options = {}) ⇒ ScormEngine::Response
Enable or disable registration instancing.
-
#put_destination(options = {}) ⇒ ScormEngine::Response
Update a destination.
Instance Method Details
#delete_destination(options = {}) ⇒ ScormEngine::Response
Delete a destination.
Deleting a destination will also delete all dispatches for that destination.
143 144 145 146 147 148 149 |
# File 'lib/scorm_engine/api/endpoints/destinations.rb', line 143 def delete_destination( = {}) (, :destination_id) response = delete("destinations/#{[:destination_id]}") Response.new(raw_response: response) end |
#get_destination(options = {}) ⇒ ScormEngine::Models::Destination
Get a destination.
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/scorm_engine/api/endpoints/destinations.rb', line 88 def get_destination( = {}) (, :destination_id) response = get("destinations/#{[:destination_id]}") # merge options to pick up destination_id which isn't passed back in the response result = response.success? ? ScormEngine::Models::Destination.new_from_api({ "id" => [:destination_id] }.merge(response.body)) : nil Response.new(raw_response: response, result: result) end |
#get_destination_dispatches_registration_count(options = {}) ⇒ Integer
Get an aggregate count of all related dispatch registrations.
213 214 215 216 217 218 219 220 221 |
# File 'lib/scorm_engine/api/endpoints/destinations.rb', line 213 def get_destination_dispatches_registration_count( = {}) (, :destination_id) response = get("destinations/#{[:destination_id]}/dispatches/registrationCount") result = response.success? ? response.body.to_i : nil Response.new(raw_response: response, result: result) end |
#get_destinations(options = {}) ⇒ Enumerator<ScormEngine::Models::Destination>
Get a list of destinations.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/scorm_engine/api/endpoints/destinations.rb', line 23 def get_destinations( = {}) = .dup response = get("destinations", ) result = Enumerator.new do |enum| loop do response.success? && response.body["destinations"].each do |destination| enum << ScormEngine::Models::Destination.new_from_api(destination) 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_destination(options = {}) ⇒ ScormEngine::Response
Create a destination.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/scorm_engine/api/endpoints/destinations.rb', line 56 def post_destination( = {}) (, :destination_id) = .dup [:name] ||= [:destination_id] body = { destinations: [ id: [:destination_id].to_s, data: { name: [:name].to_s, }, ] } response = post("destinations", {}, body) Response.new(raw_response: response) end |
#post_destination_dispatches_enabled(options = {}) ⇒ ScormEngine::Response
Enable or disable all related dispatches.
166 167 168 169 170 171 172 173 174 |
# File 'lib/scorm_engine/api/endpoints/destinations.rb', line 166 def post_destination_dispatches_enabled( = {}) (, :destination_id, :enabled) body = [:enabled].to_s response = post("destinations/#{[:destination_id]}/dispatches/enabled", {}, body) Response.new(raw_response: response) end |
#post_destination_dispatches_registration_instancing(options = {}) ⇒ ScormEngine::Response
Enable or disable registration instancing.
191 192 193 194 195 196 197 198 199 |
# File 'lib/scorm_engine/api/endpoints/destinations.rb', line 191 def post_destination_dispatches_registration_instancing( = {}) (, :destination_id, :enabled) body = [:enabled].to_s response = post("destinations/#{[:destination_id]}/dispatches/registrationInstancing", {}, body) Response.new(raw_response: response) end |
#put_destination(options = {}) ⇒ ScormEngine::Response
Update a destination.
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/scorm_engine/api/endpoints/destinations.rb', line 114 def put_destination( = {}) (, :destination_id, :name) = .dup body = { name: [:name], } response = put("destinations/#{[:destination_id]}", {}, body) Response.new(raw_response: response) end |