Sha256: 363add2c5410baa11efa8acd2c5ef5008c2fb2dc1b004c527b11803630ee0fa9

Contents?: true

Size: 1.16 KB

Versions: 104

Compression:

Stored size: 1.16 KB

Contents

# #
# AUTO GENERATED MODEL
# This model was auto generated by the CanvasSync Gem.
# You can customize it as needed, but make sure you test
# any changes you make to the auto generated methods.
#


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

104 entries across 104 versions & 1 rubygems

Version Path
canvas_sync-0.17.26.beta1 spec/dummy/app/models/admin.rb
canvas_sync-0.17.24 spec/dummy/app/models/admin.rb
canvas_sync-0.17.23 spec/dummy/app/models/admin.rb
canvas_sync-0.17.23.beta8 spec/dummy/app/models/admin.rb
canvas_sync-0.17.23.beta7 spec/dummy/app/models/admin.rb
canvas_sync-0.17.23.beta6 spec/dummy/app/models/admin.rb
canvas_sync-0.17.23.beta5 spec/dummy/app/models/admin.rb
canvas_sync-0.17.23.beta4 spec/dummy/app/models/admin.rb
canvas_sync-0.17.23.beta2 spec/dummy/app/models/admin.rb
canvas_sync-0.17.23.beta1 spec/dummy/app/models/admin.rb
canvas_sync-0.17.20 spec/dummy/app/models/admin.rb
canvas_sync-0.17.19 spec/dummy/app/models/admin.rb
canvas_sync-0.17.18 spec/dummy/app/models/admin.rb
canvas_sync-0.17.17.beta1 spec/dummy/app/models/admin.rb
canvas_sync-0.17.16 spec/dummy/app/models/admin.rb
canvas_sync-0.17.15 spec/dummy/app/models/admin.rb
canvas_sync-0.17.14 spec/dummy/app/models/admin.rb
canvas_sync-0.17.13 spec/dummy/app/models/admin.rb
canvas_sync-0.17.12 spec/dummy/app/models/admin.rb
canvas_sync-0.17.10.beta2 spec/dummy/app/models/admin.rb