Module: Bearcat::Client::OutcomeGroups

Extended by:
ClientModule
Defined in:
lib/bearcat/client/outcome_groups.rb

Constant Summary

Constants included from ClientModule

ClientModule::ARG_REGEX

Instance Attribute Summary

Attributes included from ClientModule

#_registered_endpoints

Instance Method Summary collapse

Methods included from ClientModule

context_types, endpoint, prefix

Instance Method Details

#create_outcome_in_group(outcome_group_id, params = {}) ⇒ Object



22
23
24
# File 'lib/bearcat/client/outcome_groups.rb', line 22

def create_outcome_in_group(outcome_group_id, params={})
  post("#{outcomes_context_slug(params)}#{outcome_group_id}/outcomes", params)
end

#create_subgroup(outcome_group_id, params = {}) ⇒ Object



38
39
40
# File 'lib/bearcat/client/outcome_groups.rb', line 38

def create_subgroup(outcome_group_id, params={})
  post("#{outcomes_context_slug(params)}#{outcome_group_id}/subgroups", params)
end

#delete_outcome_group(outcome_group_id, params = {}) ⇒ Object



14
15
16
# File 'lib/bearcat/client/outcome_groups.rb', line 14

def delete_outcome_group(outcome_group_id, params={})
  delete("#{outcomes_context_slug(params)}#{outcome_group_id}")
end

#import_outcome_group(outcome_group_id, params = {}) ⇒ Object



42
43
44
# File 'lib/bearcat/client/outcome_groups.rb', line 42

def import_outcome_group(outcome_group_id, params={})
  post("#{outcomes_context_slug(params)}#{outcome_group_id}/import", params)
end


26
27
28
# File 'lib/bearcat/client/outcome_groups.rb', line 26

def link_outcome(outcome_group_id, outcome_id, params={})
  put("#{outcomes_context_slug(params)}#{outcome_group_id}/outcomes/#{outcome_id}")
end

#list_linked_outcomes(outcome_group_id, params = {}) ⇒ Object



18
19
20
# File 'lib/bearcat/client/outcome_groups.rb', line 18

def list_linked_outcomes(outcome_group_id, params={})
  get("#{outcomes_context_slug(params)}#{outcome_group_id}/outcomes")
end

#list_subgroups(outcome_group_id, params = {}) ⇒ Object



34
35
36
# File 'lib/bearcat/client/outcome_groups.rb', line 34

def list_subgroups(outcome_group_id, params={})
  get("#{outcomes_context_slug(params)}#{outcome_group_id}/subgroups")
end

#outcomes_context_slug(params) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/bearcat/client/outcome_groups.rb', line 46

def outcomes_context_slug(params)
  context_hash = params.select { |k, _| k == "account" || k == "course" }

  if context_hash.keys.count > 1
    raise ArgumentError, "cannot have account and course in params"
  elsif context_hash.empty?
    return "#{global_slug}"
  else
    context_hash_key = context_hash.keys.first
    case context_hash_key
      when 'account'
        "#{account_slug(context_hash[context_hash_key])}"
      when 'course'
        "#{course_slug(context_hash[context_hash_key])}"
    end
  end
end

#show_outcome_group(outcome_group_id, params = {}) ⇒ Object



6
7
8
# File 'lib/bearcat/client/outcome_groups.rb', line 6

def show_outcome_group(outcome_group_id, params={})
  get("#{outcomes_context_slug(params)}#{outcome_group_id}")
end


30
31
32
# File 'lib/bearcat/client/outcome_groups.rb', line 30

def unlink_outcome(outcome_group_id, outcome_id, params={})
  delete("#{outcomes_context_slug(params)}#{outcome_group_id}/outcomes/#{outcome_id}")
end

#update_outcome_group(outcome_group_id, params = {}) ⇒ Object



10
11
12
# File 'lib/bearcat/client/outcome_groups.rb', line 10

def update_outcome_group(outcome_group_id, params={})
  put("#{outcomes_context_slug(params)}#{outcome_group_id}", params)
end