Class: Harvest::API::UserAssignments
- Inherits:
-
Base
- Object
- Base
- Harvest::API::UserAssignments
show all
- Defined in:
- lib/harvest/api/user_assignments.rb
Instance Attribute Summary
Attributes inherited from Base
#credentials
Instance Method Summary
collapse
Methods inherited from Base
api_model, #initialize
Instance Method Details
#all(project) ⇒ Object
5
6
7
8
|
# File 'lib/harvest/api/user_assignments.rb', line 5
def all(project)
response = request(:get, credentials, "/projects/#{project.to_i}/user_assignments")
Harvest::UserAssignment.parse(response.body)
end
|
#create(user_assignment) ⇒ Object
15
16
17
18
19
|
# File 'lib/harvest/api/user_assignments.rb', line 15
def create(user_assignment)
response = request(:post, credentials, "/projects/#{user_assignment.project_id}/user_assignments", :body => user_assignment.user_xml)
id = response.["location"].first.match(/\/.*\/(\d+)\/.*\/(\d+)/)[2]
find(user_assignment.project_id, id)
end
|
#delete(user_assignment) ⇒ Object
26
27
28
29
|
# File 'lib/harvest/api/user_assignments.rb', line 26
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) ⇒ Object
10
11
12
13
|
# File 'lib/harvest/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.body, :single => true)
end
|
#update(user_assignment) ⇒ Object
21
22
23
24
|
# File 'lib/harvest/api/user_assignments.rb', line 21
def update(user_assignment)
request(:put, credentials, "/projects/#{user_assignment.project_id}/user_assignments/#{user_assignment.id}", :body => user_assignment.to_xml)
find(user_assignment.project_id, user_assignment.id)
end
|