Module: ScormEngine::Api::Endpoints::Configuration

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

Instance Method Summary collapse

Instance Method Details

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

Deletes the current value for a setting, reverting it to its default value.

Parameters:

  • options (Hash) (defaults to: {})
  • [String] (Hash)

    a customizable set of options

Options Hash (options):

  • :for_tenant (Boolean)

    Indicates whether the configuration should be set for the current tenant. If false or not specified, will update configuration settings for the application in general.

Returns:

See Also:



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/scorm_engine/api/endpoints/configuration.rb', line 80

def delete_app_configuration(options = {})
  require_options(options, :setting_id)

  api_v2(without_tenant: !options.fetch(:for_tenant, false)) do
    setting_id = options.delete(:setting_id)

    response = delete("appManagement/configuration/#{setting_id}")

    Response.new(raw_response: response)
  end
end

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

Get the application settings currently configured in Engine.

Parameters:

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

Options Hash (options):

  • :for_tenant (Boolean)

    Indicates whether the configuration effective for the current tenant should be fetched. If false or not specified, will return configuration settings for the application in general.

Returns:

See Also:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/scorm_engine/api/endpoints/configuration.rb', line 18

def get_app_configuration(options = {})
  api_v2(without_tenant: !options.fetch(:for_tenant, false)) do
    options.delete(:for_tenant)

    response = get("appManagement/configuration", options)

    result = OpenStruct.new

    response.body["settingItems"].each do |setting|
      result[setting["id"]] = setting["effectiveValue"]
    end

    Response.new(raw_response: response, result: result)
  end
end

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

Set one or more application settings in Engine.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :for_tenant (Boolean)

    Indicates whether the configuration should be set for the current tenant. If false or not specified, will update configuration settings for the application in general.

Returns:

See Also:



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/scorm_engine/api/endpoints/configuration.rb', line 50

def post_app_configuration(options = {})
  require_options(options, :settings)

  api_v2(without_tenant: !options.fetch(:for_tenant, false)) do
    settings = options.delete(:settings)

    body = { settings: settings.map { |k, v| { "settingId" => k, "value" => v.to_s } } }

    response = post("appManagement/configuration", {}, body)

    Response.new(raw_response: response)
  end
end