class Harvest::API::UserAssignments

Public Instance Methods

all(project) click to toggle source
# File lib/forecast/api/user_assignments.rb, line 5
def all(project)
  response = request(:get, credentials, "/projects/#{project.to_i}/user_assignments")
  Harvest::UserAssignment.parse(response.parsed_response)
end
create(user_assignment) click to toggle source
# File lib/forecast/api/user_assignments.rb, line 15
def create(user_assignment)
  user_assignment = Harvest::UserAssignment.wrap(user_assignment)
  response = request(:post, credentials, "/projects/#{user_assignment.project_id}/user_assignments", :body => user_assignment.user_as_json.to_json)
  id = response.headers["location"].match(/\/.*\/(\d+)\/.*\/(\d+)/)[2]
  find(user_assignment.project_id, id)
end
delete(user_assignment) click to toggle source
# File lib/forecast/api/user_assignments.rb, line 28
def delete(user_assignment)
  request(:delete, credentials, "/projects/#{user_assignment.project_id}/user_assignments/#{user_assignment.to_i}")
  user_assignment.id
end
find(project, id) click to toggle source
# File lib/forecast/api/user_assignments.rb, line 10
def find(project, id)
  response = request(:get, credentials, "/projects/#{project.to_i}/user_assignments/#{id}")
  Harvest::UserAssignment.parse(response.parsed_response).first
end
update(user_assignment) click to toggle source
# File lib/forecast/api/user_assignments.rb, line 22
def update(user_assignment)
  user_assignment = Harvest::UserAssignment.wrap(user_assignment)
  request(:put, credentials, "/projects/#{user_assignment.project_id}/user_assignments/#{user_assignment.id}", :body => user_assignment.to_json)
  find(user_assignment.project_id, user_assignment.id)
end