D2lvalenceElixir.Utils.Service (D2lvalenceElixir v0.1.0) View Source

Provides a suite of convenience functions for making D2L Valence calls.

Link to this section Summary

Functions

Check if the Version of products requested are supported by the D2L instance

Creates the user with the information provided.

Deletes the user with the user_id.

Get all the grade objects for the organization unit id.

Gets the versions of all components.

Get the classlist of an org unit id

Get the information of an user.

Get the users information.

Gets the version of a product component especified in product component.

Calls the Whoami service of Brightspace.

Creates the user with the information provided.

Link to this section Functions

Link to this function

check_versions(user_context, supported_version_request_list, options \\ [])

View Source

Specs

check_versions(
  %D2lvalenceElixir.Auth.D2LUserContext{
    anonymous: term(),
    app_id: term(),
    app_key: term(),
    encrypt_requests: term(),
    host: term(),
    scheme: term(),
    server_skew: term(),
    user_id: term(),
    user_key: term()
  },
  [
    %D2lvalenceElixir.Data.SupportedVersionRequest{
      product_code: term(),
      version: term()
    }
  ],
  %{serializers: map() | %{}, body: map() | []}
) :: {:error, String.t()} | {:ok, [map()]} | {:ok, binary()}

Check if the Version of products requested are supported by the D2L instance

Returns

{:error, cause} when an error is caused.

{:ok, list(map())} If application/json serializer available returns a list of maps with the check of every product.

Parameters

supported_version_request_list must be a list of %D2lvalenceElixir.Data.SupportedVersionRequest{}

Options

serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request.

Link to this function

create_user(user_context, create_user_data, options \\ [])

View Source

Specs

create_user(
  %D2lvalenceElixir.Auth.D2LUserContext{
    anonymous: term(),
    app_id: term(),
    app_key: term(),
    encrypt_requests: term(),
    host: term(),
    scheme: term(),
    server_skew: term(),
    user_id: term(),
    user_key: term()
  },
  %D2lvalenceElixir.Data.CreateUserData{
    external_email: term(),
    first_name: term(),
    is_active: term(),
    last_name: term(),
    middle_name: term(),
    org_defined_id: term(),
    role_id: term(),
    send_creation_email: term(),
    user_name: term()
  },
  serializers: map(),
  ver: String.t(),
  body: list()
) ::
  {:error, String.t()}
  | {:ok,
     %D2lvalenceElixir.Data.UserData{
       activation: term(),
       external_email: term(),
       first_name: term(),
       is_active: term(),
       last_name: term(),
       middle_name: term(),
       org_defined_id: term(),
       org_id: term(),
       unique_identifier: term(),
       user_id: term(),
       user_name: term()
     }}

Creates the user with the information provided.

Returns

{:error, cause} when an error is caused.

{:ok, %D2lvalenceElixir.Data.UserData{}} the result contains the information created.

Options

version: version of the component to verify. If not specified, will get the version of the component. serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request.

Link to this function

delete_user(user_context, user_id, options \\ [])

View Source

Specs

delete_user(
  %D2lvalenceElixir.Auth.D2LUserContext{
    anonymous: term(),
    app_id: term(),
    app_key: term(),
    encrypt_requests: term(),
    host: term(),
    scheme: term(),
    server_skew: term(),
    user_id: term(),
    user_key: term()
  },
  String.t(),
  %{serializers: map() | %{}, body: map() | %{}, ver: String.t()}
) :: {:error, String.t()} | {:ok, any()}

Deletes the user with the user_id.

Returns

{:error, cause} when an error is caused.

{:ok, body_parsed} the body_parsed depends on the available serializers.

Parameters

supported_version_request_list must be a list of %D2lvalenceElixir.Data.SupportedVersionRequest{}

Options

serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request.

Link to this function

get_all_dropbox_folders_for_orgunit(user_context, org_unit_id, options \\ [])

View Source

Specs

get_all_dropbox_folders_for_orgunit(
  %D2lvalenceElixir.Auth.D2LUserContext{
    anonymous: term(),
    app_id: term(),
    app_key: term(),
    encrypt_requests: term(),
    host: term(),
    scheme: term(),
    server_skew: term(),
    user_id: term(),
    user_key: term()
  },
  integer(),
  serializers: map(),
  ver: String.t(),
  body: list()
) :: {:error, String.t()} | {:ok, any()}

Gets all the folders of the orgunit.

Returns

{:error, cause} when an error is caused.

{:ok, list(%D2lvalenceElixir.Data.DropboxFolder{})} The result contains a list with all the folders for the orgunit.

Options

version: version of the component to verify. If not specified, will get the version of the component. serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request.

Link to this function

get_all_grade_objects_for_org(user_context, org_unit_id, options \\ [])

View Source

Specs

get_all_grade_objects_for_org(
  %D2lvalenceElixir.Auth.D2LUserContext{
    anonymous: term(),
    app_id: term(),
    app_key: term(),
    encrypt_requests: term(),
    host: term(),
    scheme: term(),
    server_skew: term(),
    user_id: term(),
    user_key: term()
  },
  integer(),
  serializers: map(),
  ver: String.t(),
  body: list()
) ::
  {:error, String.t()}
  | {:ok,
     [
       %D2lvalenceElixir.Data.GradeObjectNumeric{
         can_exceed_max_points: term(),
         category: term(),
         description: term(),
         exclude_from_final_grade_calculation: term(),
         grade_scheme_id: term(),
         grade_type: term(),
         id: term(),
         is_bonus: term(),
         max_points: term(),
         name: term(),
         short_name: term()
       }
       | %D2lvalenceElixir.Data.GradeObjectPassFail{
           category: term(),
           description: term(),
           exclude_from_final_grade_calculation: term(),
           grade_scheme_id: term(),
           grade_type: term(),
           id: term(),
           is_bonus: term(),
           max_points: term(),
           name: term(),
           short_name: term()
         }
       | %D2lvalenceElixir.Data.GradeObjectText{
           category: term(),
           description: term(),
           grade_type: term(),
           id: term(),
           name: term(),
           short_name: term()
         }
       | %D2lvalenceElixir.Data.GradeObject{
           category: term(),
           description: term(),
           grade_type: term(),
           id: term(),
           name: term(),
           short_name: term()
         }
     ]}

Get all the grade objects for the organization unit id.

Returns

{:error, cause} when an error is caused.

{:ok, list(%D2lvalenceElixir.Data.GradeObjectNumeric{} | %D2lvalenceElixir.Data.GradeObjectPassFail{} | %D2lvalenceElixir.Data.GradeObjectText{} | %D2lvalenceElixir.Data.GradeObject{})} The result contains the information of the grade objects.

Options

version: version of the component to verify. If not specified, will get the version of the component. serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request.

Link to this function

get_all_grade_values_for_user_in_org(user_context, org_unit_id, user_id, options \\ [])

View Source

Specs

get_all_grade_values_for_user_in_org(
  %D2lvalenceElixir.Auth.D2LUserContext{
    anonymous: term(),
    app_id: term(),
    app_key: term(),
    encrypt_requests: term(),
    host: term(),
    scheme: term(),
    server_skew: term(),
    user_id: term(),
    user_key: term()
  },
  integer(),
  integer(),
  serializers: map(),
  ver: String.t(),
  body: list()
) ::
  {:error, String.t()}
  | {:ok,
     [
       %D2lvalenceElixir.Data.GradeValueComputable{
         displayed_grade: term(),
         grade_object_identifier: term(),
         grade_object_name: term(),
         grade_object_type: term(),
         grade_object_type_name: term(),
         points_denominator: term(),
         points_numerator: term(),
         weighted_denominator: term(),
         weighted_numerator: term()
       }
       | %D2lvalenceElixir.Data.GradeValue{
           displayed_grade: term(),
           grade_object_identifier: term(),
           grade_object_name: term(),
           grade_object_type: term(),
           grade_object_type_name: term()
         }
     ]}

Get all the grades from the user.

Returns

{:error, cause} when an error is caused.

{:ok, list(%D2lvalenceElixir.Data.GradeValueComputable{}| %D2lvalenceElixir.Data.GradeValue{})} The result contains the information of the grade objects.

Options

version: version of the component to verify. If not specified, will get the version of the component. serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request.

Link to this function

get_all_versions(user_context, options \\ [])

View Source

Specs

get_all_versions(
  %D2lvalenceElixir.Auth.D2LUserContext{
    anonymous: term(),
    app_id: term(),
    app_key: term(),
    encrypt_requests: term(),
    host: term(),
    scheme: term(),
    server_skew: term(),
    user_id: term(),
    user_key: term()
  },
  %{serializers: map() | %{}, body: map() | []}
) :: {:error, String.t()} | {:ok, [map()]} | {:ok, binary()}

Gets the versions of all components.

Returns

{:error, cause} when an error is caused.

{:ok, list(map())} If application/json serializer available returns a list of maps with the products available and its versions:

[%{"LatestVersion" => "1.1", "ProductCode" => "bas", "SupportedVersions" => ["1.0", "1.1"]}]

Options

serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request.

Link to this function

get_classlist(user_context, org_unit_id, options \\ [])

View Source

Specs

get_classlist(
  %D2lvalenceElixir.Auth.D2LUserContext{
    anonymous: term(),
    app_id: term(),
    app_key: term(),
    encrypt_requests: term(),
    host: term(),
    scheme: term(),
    server_skew: term(),
    user_id: term(),
    user_key: term()
  },
  integer(),
  serializers: map(),
  ver: String.t(),
  body: list()
) ::
  {:error, String.t()}
  | {:ok,
     [
       %D2lvalenceElixir.Data.ClasslistUser{
         display_name: term(),
         email: term(),
         identifier: term(),
         org_defined_id: term(),
         profile_identifier: term(),
         user_name: term()
       }
     ]}

Get the classlist of an org unit id

Returns

{:error, cause} when an error is caused.

{:ok, list(%D2lvalenceElixir.Data.ClasslistUser{})} The result contains the information of the classlist.

Options

version: version of the component to verify. If not specified, will get the version of the component. serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request.

Link to this function

get_files_from_submission(user_context, org_unit_id, folder_id, submission, options \\ [])

View Source

Specs

get_files_from_submission(
  %D2lvalenceElixir.Auth.D2LUserContext{
    anonymous: term(),
    app_id: term(),
    app_key: term(),
    encrypt_requests: term(),
    host: term(),
    scheme: term(),
    server_skew: term(),
    user_id: term(),
    user_key: term()
  },
  integer(),
  integer(),
  %D2lvalenceElixir.Data.SingleSubmissionForDropbox{
    comment: term(),
    files: term(),
    id: term(),
    submission_date: term(),
    submitted_by: term()
  },
  serializers: map() | %{},
  ver: String.t(),
  body: list() | []
) ::
  {:ok, [%D2lvalenceElixir.Data.FileResponse{filename: term(), path: term()}]}
  | {:error, String.t()}

Gets all the files from an specific submission.

Returns

{:error, cause} when an error is caused.

{:ok, list(%D2lvalenceElixir.Data.FileResponse{})} The result contains a list with all the files. The files are stored on a temporary path.

Options

version: version of the component to verify. If not specified, will get the version of the component. serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request.

Link to this function

get_submissions_for_dropbox_folder(user_context, org_unit_id, folder_id, options \\ [])

View Source

Specs

get_submissions_for_dropbox_folder(
  %D2lvalenceElixir.Auth.D2LUserContext{
    anonymous: term(),
    app_id: term(),
    app_key: term(),
    encrypt_requests: term(),
    host: term(),
    scheme: term(),
    server_skew: term(),
    user_id: term(),
    user_key: term()
  },
  integer(),
  integer(),
  serializers: map(),
  ver: String.t(),
  body: list()
) :: {:error, String.t()} | {:ok, any()}

Get all the submissions from the dropbox folder

Returns

{:error, cause} when an error is caused.

{:ok, list(%{})} The result contains a list with all the submissions of the dropbox folder.

Options

version: version of the component to verify. If not specified, will get the version of the component. serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request.

Link to this function

get_user(user_context, user_id, options \\ [])

View Source

Specs

get_user(
  %D2lvalenceElixir.Auth.D2LUserContext{
    anonymous: term(),
    app_id: term(),
    app_key: term(),
    encrypt_requests: term(),
    host: term(),
    scheme: term(),
    server_skew: term(),
    user_id: term(),
    user_key: term()
  },
  String.t(),
  keyword()
) ::
  {:error, String.t()}
  | {:ok,
     %D2lvalenceElixir.Data.UserData{
       activation: term(),
       external_email: term(),
       first_name: term(),
       is_active: term(),
       last_name: term(),
       middle_name: term(),
       org_defined_id: term(),
       org_id: term(),
       unique_identifier: term(),
       user_id: term(),
       user_name: term()
     }}

Get the information of an user.

Returns

{:error, cause} when an error is caused.

{:ok, %D2lvalenceElixir.Data.UserData{}} with the information requested

Options

serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request.

Link to this function

get_users(user_context, options \\ [])

View Source

Specs

get_users(
  %D2lvalenceElixir.Auth.D2LUserContext{
    anonymous: term(),
    app_id: term(),
    app_key: term(),
    encrypt_requests: term(),
    host: term(),
    scheme: term(),
    server_skew: term(),
    user_id: term(),
    user_key: term()
  },
  serializers: map() | %{},
  body: list() | [],
  ver: String.t(),
  org_defined_id: String.t(),
  user_name: String.t(),
  bookmark: String.t()
) ::
  {:error, String.t()}
  | {:ok,
     %D2lvalenceElixir.Data.UserData{
       activation: term(),
       external_email: term(),
       first_name: term(),
       is_active: term(),
       last_name: term(),
       middle_name: term(),
       org_defined_id: term(),
       org_id: term(),
       unique_identifier: term(),
       user_id: term(),
       user_name: term()
     }}
  | {:ok,
     [
       %D2lvalenceElixir.Data.UserData{
         activation: term(),
         external_email: term(),
         first_name: term(),
         is_active: term(),
         last_name: term(),
         middle_name: term(),
         org_defined_id: term(),
         org_id: term(),
         unique_identifier: term(),
         user_id: term(),
         user_name: term()
       }
     ]}
  | {:ok,
     %D2lvalenceElixir.Data.PagedResultSet{
       bookmark: term(),
       has_more_items: term(),
       items: term(),
       paging_info: term()
     }}

Get the users information.

Returns

{:error, cause} when an error is caused.

{:ok, list(%D2lvalenceElixir.Data.UserData{})} when the org_defined_id is defined.

{:ok, %D2lvalenceElixir.Data.UserData{}} when the user_name is defined and the org_defined_id is not defined.

{:ok, %D2lvalenceElixir.Data.PagedResultSer{}} when only the bookmark is defined.

Options

serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request. org_defined_id: Id of the organization. user_name: User name to obtain the information bookmark: Bookmark for the request

Link to this function

get_versions_for_product_component(user_context, product_component, options \\ [])

View Source

Specs

get_versions_for_product_component(
  %D2lvalenceElixir.Auth.D2LAppContext{app_id: term(), app_key: term()},
  String.t(),
  %{version: String.t() | nil, serializers: map() | %{}, body: map() | %{}}
) :: {:error, String.t()} | {:ok, list()} | {:ok, binary()}

Gets the version of a product component especified in product component.

Returns

{:error, cause} when an error is caused.

{:ok, list} If application/json serializer available returns a list with the product versions available

Options

version: version of the component to verify. If not specified, will get the version of the component. serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request.

Link to this function

get_whoami(user_context, options \\ [])

View Source

Specs

get_whoami(
  %D2lvalenceElixir.Auth.D2LUserContext{
    anonymous: term(),
    app_id: term(),
    app_key: term(),
    encrypt_requests: term(),
    host: term(),
    scheme: term(),
    server_skew: term(),
    user_id: term(),
    user_key: term()
  },
  %{serializers: %{}, ver: String.t()}
) ::
  {:error, String.t()}
  | {:ok,
     %D2lvalenceElixir.Data.WhoAmIUser{
       first_name: term(),
       identifier: term(),
       last_name: term(),
       profile_identifier: term(),
       unique_name: term()
     }}

Calls the Whoami service of Brightspace.

Returns

{:error, cause} when an error is caused.

{:ok, %D2lvalenceElixir.Data.WhoAmIUser{}} the result contains the information of the logged user.

Options

version: version of the component to verify. If not specified, will get the version of the component. serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request.

Link to this function

update_user(user_context, user_id, update_user_data, options \\ [])

View Source

Specs

update_user(
  %D2lvalenceElixir.Auth.D2LUserContext{
    anonymous: term(),
    app_id: term(),
    app_key: term(),
    encrypt_requests: term(),
    host: term(),
    scheme: term(),
    server_skew: term(),
    user_id: term(),
    user_key: term()
  },
  String.t(),
  %D2lvalenceElixir.Data.UpdateUserData{
    activation: term(),
    external_email: term(),
    first_name: term(),
    last_name: term(),
    middle_name: term(),
    org_defined_id: term(),
    user_name: term()
  },
  serializers: map(),
  ver: String.t(),
  body: list()
) :: {:error, String.t()} | {:ok, any()}

Creates the user with the information provided.

Returns

{:error, cause} when an error is caused.

{:ok, %D2lvalenceElixir.Data.UserData{}} the result contains the information created.

Options

version: version of the component to verify. If not specified, will get the version of the component. serializers: Map of availaber serializers. application/json recommended. body: Options to pass to the body of the request.