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, query = {}) ⇒ Object
5
6
7
8
|
# File 'lib/harvest/api/user_assignments.rb', line 5
def all(project, query = {})
response = request(:get, credentials, "/projects/#{project.to_i}/user_assignments", {query: query})
Harvest::UserAssignment.parse(response.parsed_response)
end
|
#create(user_assignment) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/harvest/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.["location"].match(/\/.*\/(\d+)\/.*\/(\d+)/)[2]
find(user_assignment.project_id, id)
end
|
#delete(user_assignment) ⇒ Object
28
29
30
31
|
# File 'lib/harvest/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) ⇒ 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.parsed_response).first
end
|
#update(user_assignment) ⇒ Object
22
23
24
25
26
|
# File 'lib/harvest/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
|