Class: Bearcat::Client

Inherits:
Footrest::Client
  • Object
show all
Defined in:
lib/bearcat/client.rb,
lib/bearcat/client/tabs.rb,
lib/bearcat/client/files.rb,
lib/bearcat/client/pages.rb,
lib/bearcat/client/roles.rb,
lib/bearcat/client/users.rb,
lib/bearcat/client/groups.rb,
lib/bearcat/client/logins.rb,
lib/bearcat/client/rubric.rb,
lib/bearcat/client/search.rb,
lib/bearcat/client_module.rb,
lib/bearcat/client/courses.rb,
lib/bearcat/client/folders.rb,
lib/bearcat/client/modules.rb,
lib/bearcat/client/o_auth2.rb,
lib/bearcat/client/quizzes.rb,
lib/bearcat/client/reports.rb,
lib/bearcat/client/accounts.rb,
lib/bearcat/client/graph_ql.rb,
lib/bearcat/client/outcomes.rb,
lib/bearcat/client/sections.rb,
lib/bearcat/client/analytics.rb,
lib/bearcat/client/progresses.rb,
lib/bearcat/client/assignments.rb,
lib/bearcat/client/conferences.rb,
lib/bearcat/client/discussions.rb,
lib/bearcat/client/enrollments.rb,
lib/bearcat/client/file_helper.rb,
lib/bearcat/client/sis_imports.rb,
lib/bearcat/client/submissions.rb,
lib/bearcat/client/canvas_files.rb,
lib/bearcat/client/module_items.rb,
lib/bearcat/client/conversations.rb,
lib/bearcat/client/external_tools.rb,
lib/bearcat/client/outcome_groups.rb,
lib/bearcat/client/account_reports.rb,
lib/bearcat/client/calendar_events.rb,
lib/bearcat/client/content_exports.rb,
lib/bearcat/client/outcome_imports.rb,
lib/bearcat/client/group_categories.rb,
lib/bearcat/client/assignment_groups.rb,
lib/bearcat/client/blueprint_courses.rb,
lib/bearcat/client/group_memberships.rb,
lib/bearcat/client/learning_outcomes.rb,
lib/bearcat/client/rubric_assessment.rb,
lib/bearcat/client/content_migrations.rb,
lib/bearcat/client/rubric_association.rb,
lib/bearcat/client/account_notifications.rb,
lib/bearcat/client/custom_gradebook_columns.rb

Defined Under Namespace

Modules: AccountNotifications, AccountReports, Accounts, Analytics, AssignmentGroups, Assignments, BlueprintCourses, CalendarEvents, CanvasFiles, ClientModule, Conferences, ContentExports, ContentMigrations, Conversations, Courses, CustomGradebookColumns, Discussions, Enrollments, ExternalTools, FileHelper, Files, Folders, GraphQL, GroupCategories, GroupMemberships, Groups, LearningOutcomes, Logins, ModuleItems, Modules, OAuth2, OutcomeGroups, OutcomeImports, Outcomes, Pages, Progresses, Quizzes, Reports, Roles, Rubric, RubricAssessment, RubricAssociation, Search, Sections, SisImports, Submissions, Tabs, Users

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cache_on_self(key, &block) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/bearcat/client.rb', line 42

def self.cache_on_self(key, &block)
  @cache ||= {}
  if Rails.env.development? || Rails.env.test?
    block.call
  else
    @cache[key] ||= block.call
  end
end

.registered_endpointsObject



22
23
24
25
26
27
# File 'lib/bearcat/client.rb', line 22

def self.registered_endpoints
  @registered_endpoints ||= @added_modules.reduce({}) do |h, m|
    h.merge!(m._registered_endpoints) rescue h
  end
  @registered_endpoints
end

Instance Method Details

#cache_on_class(key, &block) ⇒ Object



51
52
53
# File 'lib/bearcat/client.rb', line 51

def cache_on_class(key, &block)
  self.class.cache_on_self(key, &block)
end

#request(method, &block) ⇒ Object



29
30
31
32
33
34
# File 'lib/bearcat/client.rb', line 29

def request(method, &block)
  response = rate_limited_request do
    connection.send(method, &block)
  end
  ApiArray.process_response(response, self)
end

#set_connection(config) ⇒ Object



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

def set_connection(config)
  super
  connection.builder.insert(Footrest::RaiseFootrestErrors, ExtendedRaiseFootrestErrors)
  connection.builder.delete(Footrest::RaiseFootrestErrors)
end