forked from zmoazeni/harvested
/
task_assignments.rb
27 lines (19 loc) · 1.02 KB
/
task_assignments.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require "harvested"
subdomain = 'yoursubdomain'
username = 'yourusername'
password = 'yourpassword'
harvest = Harvest.hardy_client(subdomain, username, password)
# Create a Client add a Project to that Client
client = Harvest::Client.new(:name => 'SuprCorp')
client = harvest.clients.create(client)
project = Harvest::Project.new(:name => 'SuprGlu', :client_id => client.id, :notes => 'Some notes about this project')
project = harvest.projects.create(project)
# You can create an assign a task in one call
harvest.projects.create_task(project, 'Bottling Glue')
puts "Assigned the task 'Bottling Glue' to the project 'SuprGlu'"
# You can explicitly create the task and then assign it
task = Harvest::Task.new(:name => 'Packaging Glue', :hourly_rate => 30, :billable => true)
task = harvest.tasks.create(task)
task_assignment = Harvest::TaskAssignment.new(:task_id => task.id, :project_id => project.id)
task_assignment = harvest.task_assignments.create(task_assignment)
puts "Assigned the task 'Packaging Glue' to the project 'SuprGlu'"