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

#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
# 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
    response = get("appManagement/configuration")

    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:



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

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