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.19.0.beta10 spec/dummy/app/models/admin.rb
canvas_sync-0.19.0.beta9 spec/dummy/app/models/admin.rb
canvas_sync-0.19.0.beta8 spec/dummy/app/models/admin.rb
canvas_sync-0.19.0.beta7 spec/dummy/app/models/admin.rb
canvas_sync-0.19.0.beta6 spec/dummy/app/models/admin.rb
canvas_sync-0.19.0.beta5 spec/dummy/app/models/admin.rb
canvas_sync-0.19.0.beta4 spec/dummy/app/models/admin.rb
canvas_sync-0.19.0.beta3 spec/dummy/app/models/admin.rb
canvas_sync-0.19.0.beta2 spec/dummy/app/models/admin.rb
canvas_sync-0.19.0.beta1 spec/dummy/app/models/admin.rb
canvas_sync-0.18.12 spec/dummy/app/models/admin.rb
canvas_sync-0.18.10 spec/dummy/app/models/admin.rb
canvas_sync-0.18.9 spec/dummy/app/models/admin.rb
canvas_sync-0.18.8 spec/dummy/app/models/admin.rb
canvas_sync-0.18.7 spec/dummy/app/models/admin.rb
canvas_sync-0.18.6 spec/dummy/app/models/admin.rb
canvas_sync-0.18.5 spec/dummy/app/models/admin.rb
canvas_sync-0.18.3 spec/dummy/app/models/admin.rb
canvas_sync-0.18.2 spec/dummy/app/models/admin.rb
canvas_sync-0.18.1 spec/dummy/app/models/admin.rb