Class: Harvest::API::Projects
- Inherits:
-
Base
- Object
- Base
- Harvest::API::Projects
- Includes:
- Behavior::Crud
- Defined in:
- lib/harvest/api/projects.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary (collapse)
-
- (Harvest::Project) activate(project)
Activates the project.
-
- (Harvest::Project) create_task(project, task_name)
Creates and Assigns a task to the project.
-
- (Harvest::Project) deactivate(project)
Deactivates the project.
Methods included from Behavior::Crud
#all, #create, #delete, #find, #update
Methods inherited from Base
Constructor Details
This class inherits a constructor from Harvest::API::Base
Instance Method Details
- (Harvest::Project) activate(project)
Activates the project. Does nothing if the project is already activated
37 38 39 40 41 42 43 |
# File 'lib/harvest/api/projects.rb', line 37 def activate(project) if !project.active? request(:put, credentials, "#{api_model.api_path}/#{project.to_i}/toggle", :headers => {'Content-Length' => '0'}) project.active = true end project end |
- (Harvest::Project) create_task(project, task_name)
Creates and Assigns a task to the project
Examples
project = harvest.projects.find(401)
harvest.projects.create_task(project, 'Bottling Glue') # creates and assigns a task to the project
15 16 17 18 19 |
# File 'lib/harvest/api/projects.rb', line 15 def create_task(project, task_name) response = request(:post, credentials, "/projects/#{project.to_i}/task_assignments/add_with_create_new_task", :body => {"task" => {"name" => task_name}}.to_json) id = response.headers["location"].match(/\/.*\/(\d+)\/.*\/(\d+)/)[1] find(id) end |
- (Harvest::Project) deactivate(project)
Deactivates the project. Does nothing if the project is already deactivated
25 26 27 28 29 30 31 |
# File 'lib/harvest/api/projects.rb', line 25 def deactivate(project) if project.active? request(:put, credentials, "#{api_model.api_path}/#{project.to_i}/toggle", :headers => {'Content-Length' => '0'}) project.active = false end project end |