Class: SlsAdf::Mutation

Inherits:
Base
  • Object
show all
Defined in:
lib/sls_adf/mutation.rb

Overview

Make GraphQL mutation calls to SLS ADF through Ruby methods.

Sample Usage:

response = SlsAdf::Mutation.delete_assignment('Assignment-1234')

Class Method Summary collapse

Class Method Details

.create_assignment(assignment_input) ⇒ GraphQL::Client::Response

Makes a call to create assignment. assignment_input has the following shape:

{
  title: 'Test',
  start: '2017-11-30T10:15:30+01:00', #ISO8601 format
  end: '2017-12-30T12:15:30Z', #ISO8601 format
  createdBy: 'MOE-1234',
  type: 'QUIZ',
  subjectGroupUuid: 'subject-group-uuid',
  assignees: ['MOE-1235', 'MOE-1236', ...]
}

@param assignment_input

Returns:

  • (GraphQL::Client::Response)

    The response object



26
27
28
29
# File 'lib/sls_adf/mutation.rb', line 26

def create_assignment(assignment_input)
  execute_query(SlsAdf::Template::Mutation::Assignment::Create,
                assignment_input: assignment_input)
end

.create_notification(notification_input) ⇒ GraphQL::Client::Response

Makes a call to create a notification. notification_input has the following shape:

{
  message: 'Assignment 1 has started!',
  scope: 'SUBJECT_GROUP', #
  scopeId: '', #
  eventType: '', #
  eventTypeId: '' # UUID,
  receipient: ['', '', ...] # User ID.
}

@param notification_input

Returns:

  • (GraphQL::Client::Response)

    The response object



74
75
76
77
# File 'lib/sls_adf/mutation.rb', line 74

def create_notification(notification_input)
  execute_query(SlsAdf::Template::Mutation::Notification::Add,
                notification_input: notification_input)
end

.delete_assignment(uuid) ⇒ GraphQL::Client::Response

Makes a call to delete the assignment with the given UUID

@param uuid UUID of the subject_group to be modified

Returns:

  • (GraphQL::Client::Response)

    The response object



46
47
48
# File 'lib/sls_adf/mutation.rb', line 46

def delete_assignment(uuid)
  execute_query(SlsAdf::Template::Mutation::Assignment::Delete, uuid: uuid)
end

.update_assignment(uuid, assignment_input) ⇒ GraphQL::Client::Response

Makes a call to update assignment. See #create_assignment for assignment_input shape. If field is null, field will not be updated.

@param uuid UUID of the subject_group to be modified @param assignment_input

Returns:

  • (GraphQL::Client::Response)

    The response object



37
38
39
40
# File 'lib/sls_adf/mutation.rb', line 37

def update_assignment(uuid, assignment_input)
  execute_query(SlsAdf::Template::Mutation::Assignment::Update,
                uuid: uuid, assignment_input: assignment_input)
end

.update_task(uuid, status) ⇒ GraphQL::Client::Response

Makes a call to update the task. Task status is one of the following:

'NEW', 'IN_PROGRESS', 'COMPLETED'

@param uuid UUID of task to be updated @param status Status of the task to be updated

Returns:

  • (GraphQL::Client::Response)

    The response object



56
57
58
59
# File 'lib/sls_adf/mutation.rb', line 56

def update_task(uuid, status)
  execute_query(SlsAdf::Template::Mutation::Task::Update,
                uuid: uuid, task_status: status)
end