class MarkusRESTfulAPI::Users

A singleton that allows us to get and update user(s)

Public Class Methods

create(attributes) click to toggle source
# File lib/tools/api_wrapper/api_wrapper.rb, line 86
def self.create(attributes)
  url = 'users.json'
  response = self.post(url, attributes)

  self.get_by_user_name(attributes['user_name'])
end
get_all_admins() click to toggle source
# File lib/tools/api_wrapper/api_wrapper.rb, line 74
def self.get_all_admins()
  self.get('users.json?filter=type:admin')
end
get_all_by_first_name(first_name) click to toggle source
# File lib/tools/api_wrapper/api_wrapper.rb, line 70
def self.get_all_by_first_name(first_name)
  self.get("users.json?filter=first_name:#{first_name}")
end
get_all_students() click to toggle source
# File lib/tools/api_wrapper/api_wrapper.rb, line 82
def self.get_all_students()
  self.get('users.json?filter=type:student')
end
get_all_tas() click to toggle source
# File lib/tools/api_wrapper/api_wrapper.rb, line 78
def self.get_all_tas()
  self.get('users.json?filter=type:ta')
end
get_by_id(id) click to toggle source
# File lib/tools/api_wrapper/api_wrapper.rb, line 66
def self.get_by_id(id)
  self.get("users/#{id}.json")
end
get_by_user_name(user_name) click to toggle source
# File lib/tools/api_wrapper/api_wrapper.rb, line 62
def self.get_by_user_name(user_name)
  self.get("users.json?filter=user_name:#{user_name}")[0]
end
update(id, attributes) click to toggle source
# File lib/tools/api_wrapper/api_wrapper.rb, line 93
def self.update(id, attributes)
  attributes.delete('id')
  url = "users/#{id}.json"
  self.put(url, attributes)

  self.get_by_id(id)
end