Module: ScormEngine::Api::Endpoints::Destinations

Included in:
ScormEngine::Api::Endpoints
Defined in:
lib/scorm_engine/api/endpoints/destinations.rb

Instance Method Summary collapse

Instance Method Details

#delete_destination(options = {}) ⇒ ScormEngine::Response

Delete a destination.

Deleting a destination will also delete all dispatches for that destination.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :destination_id (String)

    The ID of the destination to delete.

Returns:

See Also:


143
144
145
146
147
148
149
# File 'lib/scorm_engine/api/endpoints/destinations.rb', line 143

def delete_destination(options = {})
  require_options(options, :destination_id)

  response = delete("destinations/#{options[:destination_id]}")

  Response.new(raw_response: response)
end

#get_destination(options = {}) ⇒ ScormEngine::Models::Destination

Get a destination.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :destination_id (String)

    The ID of the destination to get.

Returns:

See Also:


88
89
90
91
92
93
94
95
96
97
# File 'lib/scorm_engine/api/endpoints/destinations.rb', line 88

def get_destination(options = {})
  require_options(options, :destination_id)

  response = get("destinations/#{options[: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" => options[: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.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :destination_id (String)

    The ID of the destination to delete.

Returns:

  • (Integer)

See Also:


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(options = {})
  require_options(options, :destination_id)

  response = get("destinations/#{options[: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.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :course_id (String)

    Limit the results to destinations that have dispatches of the specified course.

  • :since (DateTime)

    Only destinations updated since the specified ISO 8601 TimeStamp (inclusive) are included. If a time zone is not specified, the server's time zone will be used.

Returns:

See Also:


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(options = {})
  options = options.dup

  response = get("destinations", options)

  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.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :destination_id (String)

    The destination ID.

  • :name (String) — default: :destination_id

    The destination's name.

Returns:

See Also:


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(options = {})
  require_options(options, :destination_id)

  options = options.dup
  options[:name] ||= options[:destination_id]

  body = {
    destinations: [
      id: options[:destination_id].to_s,
      data: {
        name: options[: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.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :destination_id (String)

    The ID of the destination

  • :enabled (Boolean)

    The enabledness of all related dispatches

Returns:

See Also:


166
167
168
169
170
171
172
173
174
# File 'lib/scorm_engine/api/endpoints/destinations.rb', line 166

def post_destination_dispatches_enabled(options = {})
  require_options(options, :destination_id, :enabled)

  body = options[:enabled].to_s

  response = post("destinations/#{options[:destination_id]}/dispatches/enabled", {}, body)

  Response.new(raw_response: response)
end

#post_destination_dispatches_registration_instancing(options = {}) ⇒ ScormEngine::Response

Enable or disable registration instancing.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :destination_id (String)

    The ID of the destination to delete.

  • :enabled (Boolean)

    The enabledness of the registration instancing

Returns:

See Also:


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(options = {})
  require_options(options, :destination_id, :enabled)

  body = options[:enabled].to_s

  response = post("destinations/#{options[:destination_id]}/dispatches/registrationInstancing", {}, body)

  Response.new(raw_response: response)
end

#put_destination(options = {}) ⇒ ScormEngine::Response

Update a destination.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :destination_id (String)

    The destination ID.

  • :name (String)

    The destination's new name.

Returns:

See Also:


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(options = {})
  require_options(options, :destination_id, :name)

  options = options.dup

  body = {
    name: options[:name],
  }

  response = put("destinations/#{options[:destination_id]}", {}, body)

  Response.new(raw_response: response)
end