Sha256: a52a683cbbff6c0caf04b06c0a3afd6dd821d30ce47d93a012131309eab90d09
Contents?: true
Size: 1.95 KB
Versions: 2
Compression:
Stored size: 1.95 KB
Contents
module CanvasFactory # canvas user class class User attr_reader :learner_request, :user_response, :id, :admin_request, :email_id, :short_name, :password def initialize(opts = {}, merge = true) unique_email = "#{@email_prefix}#{SecureRandom.hex}@example.com" @learner_request = { user: { name: unique_email, short_name: 'auto user', terms_of_use: '1', send_confirmation: true }, pseudonym: { unique_id: unique_email, password: 'Testing01' }, force_validations: true } @learner_request = Mergie.deep_merge(@learner_request, opts, merge) create_learner_user end def delete_user user_end_point = "#{CANVAS_API_V1}/accounts/#{CANVAS_ACCOUNT_ID}/users/#{@id}" @user_response = CanvasFactory.perform_delete(user_end_point) end private def create_learner_user user_end_point = "#{CANVAS_API_V1}/accounts/#{CANVAS_ACCOUNT_ID}/users" @user_response = CanvasFactory.perform_post(user_end_point, @learner_request) @id = @user_response['id'] @email_id = @user_response['login_id'] @short_name = @user_response['short_name'] @password = @learner_request[:pseudonym][:password] @user_response end end # canvas admin user class class AdminUser < User def initialize(opts = {}, merge = true) super(opts, merge) make_admin_user end private def make_admin_user @admin_request = { user_id: @id, role_id: 'AccountAdmin', send_confirmation: true } admin_end_point = "#{CANVAS_API_V1}/accounts/#{CANVAS_ACCOUNT_ID}/admins" @admin_response = CanvasFactory.perform_post(admin_end_point, @admin_request) @id = @admin_response['user']['id'] @email_id = @admin_response['user']['login_id'] @short_name = @admin_response['user']['short_name'] @admin_response end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
japanda-0.1.6 | lib/japanda/canvas_factory/user.rb |
japanda-0.1.5 | lib/japanda/canvas_factory/user.rb |