Sha256: fbcc41608367eab0c05161cf02424027dfd41839e5f914ac6793f6f23ebdaa1c

Contents?: true

Size: 853 Bytes

Versions: 23

Compression:

Stored size: 853 Bytes

Contents

# <%= autogenerated_event_warning %>

module LiveEvents
  class UserEvent < LiveEvents::BaseEvent
    # The following is provided in the live events call:
    # {
    #   user_id: user.global_id,
    #   uuid: user.uuid,
    #   name: user.name,
    #   short_name: user.short_name,
    #   workflow_state: user.workflow_state,
    #   created_at: user.created_at,
    #   updated_at: user.updated_at
    # }

    def perform(event_payload)
      super
      attrs = {
        canvas_user_id: local_canvas_id(payload[:user_id]),
        full_name: payload[:name],
        status: payload[:workflow_state],
      }
      create_or_update(attrs)
    end

    private

    def create_or_update(attrs)
      user = User.where(canvas_user_id: attrs[:canvas_user_id]).first_or_initialize
      user.assign_attributes(attrs)
      user.save!
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
canvas_sync-0.9.4 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.9.3 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.9.2 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.9.1 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.9.0 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.8.4 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.8.3 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.8.2 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.8.1 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.8.0 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.7.3 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.7.2 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.7.1 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.7.0 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.6.4 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.6.3 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.6.2 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.6.1 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.6.0 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb
canvas_sync-0.5.4 lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb