class CanvasAccount

Attributes

name[R]
parent_uid[R]
root_uid[R]
sis_id[R]
time_zone[R]
uid[R]
workflow[R]

Public Class Methods

gen_file(opts = {}) click to toggle source
# File lib/models/canvas_account.rb, line 39
def self.gen_file(opts = {})
  opts[:rows] ? rows = opts[:rows] : rows = 0
  opts[:parent] ? parent = opts[:parent] : parent = 1
  opts[:root] ? root = opts[:root] : root = 1
  accounts = []
  if(opts[:rows])
    rows.times do |x|
      accounts.push(CanvasAccount.random(parent, root))
    end
  end
  header = %w[account_id parent_account_id name status integration_id]
  CSV.open('./accounts.csv', 'wb', write_headers: true, headers: header) do |csv|
    accounts.each do |acc|
      csv << acc.to_csv
    end
  end
  return accounts
end
new(opts = {}) click to toggle source

future relase: Make fields reuired by canvas required here

# File lib/models/canvas_account.rb, line 14
def initialize(opts = {})
  @name = opts[:name] if opts[:name]
  @uid = opts[:uid] if opts[:uid]
  @parent_id = opts[:parent] if opts[:parent]
  @root_id = opts[:root] if opts[:root]
  @time_zone = opts[:time_zone] if opts[:time_zone]
  @sis_id = opts[:sis] if opts[:sis]
  @workflow = opts[:workflow] if opts[:workflow]
end
random(parent_id = 1 , root_id = 1) click to toggle source
# File lib/models/canvas_account.rb, line 24
def self.random (parent_id = 1 , root_id = 1)
  a = Forgery('name').company_name
  CanvasAccount.new(
    {
      name: a,
      uid: "#{a}-#{rand(10_000)}",
      parent: parent_id,
      root: root_id,
      time_zone: Forgery('time').zone,
      sis_id: (10_000+rand(10_000_000)),
      workflow: 'active'
      }
    )
end

Public Instance Methods

to_csv() click to toggle source
# File lib/models/canvas_account.rb, line 9
def to_csv
  row = [uid, parent_uid, name, 'active', nil]
end
to_s() click to toggle source
# File lib/models/canvas_account.rb, line 5
def to_s
  string = "#{name}, #{uid}, #{parent_uid}, #{root_uid}, #{time_zone}, #{sis_id}, #{workflow}"
end