lib/bearcat/client/external_tools.rb in bearcat-1.4.13 vs lib/bearcat/client/external_tools.rb in bearcat-1.5.0.beta1

- old
+ new

@@ -1,45 +1,18 @@ module Bearcat class Client < Footrest::Client module ExternalTools - def course_external_tools(course_id, params={}) - get("/api/v1/courses/#{course_id}/external_tools", params) - end + extend ClientModule - def account_external_tools(account_id, params={}) - get("/api/v1/accounts/#{account_id}/external_tools", params) - end + context_types %i[course account] do |ct| + prefix "/api/v1/#{ct}s/:#{ct}/external_tools/" do + get :"#{ct}_external_tools" + post :"create_#{ct}_external_tool" - def course_external_tool(course_id, tool_id, params={}) - get("/api/v1/courses/#{course_id}/external_tools/#{tool_id}", params) - end - - def account_external_tool(account_id, tool_id, params={}) - get("/api/v1/accounts/#{account_id}/external_tools/#{tool_id}", params) - end - - def create_course_external_tool(course_id, params={}) - post("/api/v1/courses/#{course_id}/external_tools", params) - end - - def create_account_external_tool(account_id, params={}) - post("/api/v1/accounts/#{account_id}/external_tools", params) - end - - def edit_course_external_tool(course_id, tool_id, params={}) - put("/api/v1/courses/#{course_id}/external_tools/#{tool_id}", params) - end - - def edit_account_external_tool(account_id, tool_id, params={}) - put("/api/v1/accounts/#{account_id}/external_tools/#{tool_id}", params) - end - - def delete_course_external_tool(course_id, tool_id, params={}) - delete("/api/v1/courses/#{course_id}/external_tools/#{tool_id}", params) - end - - def delete_account_external_tool(account_id, tool_id, params={}) - delete("/api/v1/accounts/#{account_id}/external_tools/#{tool_id}", params) + get :"#{ct}_external_tool", ":tool" + put :"edit_#{ct}_external_tool", ":tool" + delete :"delete_#{ct}_external_tool", ":tool" + end end end end end