Sha256: 5456014aec36366093d38c99d960bb03f18b50e33dbfe5e33b666150c47df653

Contents?: true

Size: 1 KB

Versions: 82

Compression:

Stored size: 1 KB

Contents

# <%= autogenerated_model_warning %>

class Admin < ApplicationRecord
  include CanvasSync::Record
  include CanvasSync::Concerns::ApiSyncable

  validates :canvas_id, uniqueness: true, presence: true
  belongs_to :account, primary_key: :canvas_id, foreign_key: :canvas_account_id, optional: true
  belongs_to :user, primary_key: :canvas_id, foreign_key: :canvas_user_id, optional: true
  belongs_to :role, primary_key: :canvas_id, foreign_key: :canvas_role_id, optional: true

  api_syncable({
    canvas_id: :id,
    role_name: :role,
    canvas_role_id: :role_id,
    canvas_user_id: ->(r) { r['user']['id'] },
    # NOTICE: The :account_id field is added by CanvasSync - it is not included in the Canvas API response
    canvas_account_id: :account_id,
    workflow_state: :workflow_state,
  }, -> (api) {
    admins = api.account_admins(canvas_account_id).all_pages!
    admin_data = admins.find{|admin| admin['id'] == canvas_id }
    raise Footrest::HttpError::NotFound unless admin_data.present?
    admin_data
  })
end

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
canvas_sync-0.17.43 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.42 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.41 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.40 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.39 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.38 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.37 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.36 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.35 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.34 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.33 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.32 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.31 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.30 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.29 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.28 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.27 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.27.beta1 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.26.beta1 lib/canvas_sync/generators/templates/models/admin.rb
canvas_sync-0.17.24 lib/canvas_sync/generators/templates/models/admin.rb