Sha256: 6ad3261192a43ea2984aab09e25dc5e73dbe915d4ac71a4eb08c484548ed26f9

Contents?: true

Size: 744 Bytes

Versions: 2

Compression:

Stored size: 744 Bytes

Contents

require "bundler/setup"
require "velocity"

contributors_list = CSV.parse(File.read("./examples/contributors-list.csv"), headers: true)

contributors_list.map do |contributor|
  velocity_contributor = Velocity::Contributor.find_by(name: contributor["name"])

  if velocity_contributor
    puts "Contributor #{velocity_contributor.id} found.\n#{velocity_contributor.inspect}"
  else
    role = Velocity::Role.find_by(name: contributor["role_name"])

    raise "Role not found" if role.nil?

    invite = Velocity::Invite.create(
      name: contributor["name"],
      email: contributor["email"],
      job_function: contributor["job_function"],
      role_ids: [role.id]
    )

    puts "Invite #{invite.id} sent.\n#{invite.inspect}"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
velocity_client_ruby-0.3.0 examples/send_bulk_invites.rb
velocity_client_ruby-0.2.1 examples/send_bulk_invites.rb