<%= autogenerated_model_warning %> class Role < ApplicationRecord include CanvasSync::ApiSyncable validates :canvas_id, uniqueness: true, presence: true has_many :admins, foreign_key: :canvas_role_id, primary_key: :canvas_id api_syncable({ canvas_id: :id, label: :label, base_role_type: :base_role_type, account: :account, canvas_account_id: ->(r) { r.dig('account', 'id') }, permissions: :permissions, workflow_state: :workflow_state, }, -> (api) { api.get("/api/v1/accounts/#{canvas_account_id}/roles/#{canvas_id}") }) def self.create_or_update(params); find_or_initialize_by(canvas_id: params['id']).update_from_api_params!(params); end end