module Bearcat class Client < Footrest::Client module Users extend ClientModule prefix "/api/v1/accounts/:account/users/" do get :list_users post :add_user end prefix "/api/v1/users/" do prefix ":user/" do get :user_detail get :user_avatars, "avatars" get :user_profile, "profile" get :user_logins, "logins" get :communication_channels, "communication_channels" get :page_views, "page_views" put :user_merge, "merge_into/:merge_into_user" post :user_split, "split" get :user_assignments, "courses/:course/assignments" get :dashboard_positions, "dashboard_positions" put :update_dashboard_positions, "dashboard_positions" end prefix "self/" do get :course_nicknames, "course_nicknames" get :course_nickname, "course_nicknames/:course" put :set_course_nickname, "course_nicknames/:course" delete :delete_course_nickname, "course_nicknames/:course" delete :clear_course_nickname, "course_nicknames" end end # scope: food # params: {ns: 'com.account-domain.canvas-app'} # returns all custom user food scope data. If no scope returns all custom user data def load_custom_data(user, params, scope = '') get("/api/v1/users/#{user}/custom_data/#{scope}", params) end # scope: food # params: {ns: 'com.account-domain.canvas-app', # data: {'favorite' => 'steak', 'least favorite' => 'water mellon'}} # stores custom data in the food scope def store_custom_data(user, params, scope = '') put("/api/v1/users/#{user}/custom_data/#{scope}", params) end # scope: food # params: {ns: 'com.account-domain.canvas-app'} # deletes all custom user data for the food scope. If no scope deletes all custom user data def delete_custom_data(user, params, scope = '') delete("/api/v1/users/#{user}/custom_data/#{scope}", params) end def favorite_courses(user, params = {}) params.merge!({as_user_id: user}) get("/api/v1/users/self/favorites/courses", params) end def unfavorite_course(user, course, params = {}) params.merge!({as_user_id: user}) delete("/api/v1/users/self/favorites/courses/#{course}", params) end end end end