Class: Asana::Resources::ProjectStatus

Inherits:
ProjectStatusesBase show all
Defined in:
lib/asana/resources/project_status.rb

Overview

A _project status_ is an update on the progress of a particular project, and is sent out to all project followers when created. These updates include both text describing the update and a color code intended to represent the overall state of the project: “green” for projects that are on track, “yellow” for projects at risk, and “red” for projects that are behind.

Project statuses can be created and deleted, but not modified.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ProjectStatusesBase

create_project_status_for_project, delete_project_status, get_project_status, get_project_statuses_for_project, inherited

Methods inherited from Resource

#initialize, #method_missing, #refresh, #respond_to_missing?, #to_h, #to_s

Methods included from ResponseHelper

#parse

Constructor Details

This class inherits a constructor from Asana::Resources::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Asana::Resources::Resource

Instance Attribute Details

#colorObject (readonly)


24
25
26
# File 'lib/asana/resources/project_status.rb', line 24

def color
  @color
end

#created_atObject (readonly)


28
29
30
# File 'lib/asana/resources/project_status.rb', line 28

def created_at
  @created_at
end

#created_byObject (readonly)


26
27
28
# File 'lib/asana/resources/project_status.rb', line 26

def created_by
  @created_by
end

#gidObject (readonly)


14
15
16
# File 'lib/asana/resources/project_status.rb', line 14

def gid
  @gid
end

#html_textObject (readonly)


22
23
24
# File 'lib/asana/resources/project_status.rb', line 22

def html_text
  @html_text
end

#resource_typeObject (readonly)


16
17
18
# File 'lib/asana/resources/project_status.rb', line 16

def resource_type
  @resource_type
end

#textObject (readonly)


20
21
22
# File 'lib/asana/resources/project_status.rb', line 20

def text
  @text
end

#titleObject (readonly)


18
19
20
# File 'lib/asana/resources/project_status.rb', line 18

def title
  @title
end

Class Method Details

.create_in_project(client, project: required("project"), text: required("text"), color: required("color"), options: {}, **data) ⇒ Object Also known as: create

Creates a new status update on the project.

Parameters:

  • Returns

    the full record of the newly created project status update.

  • project (Gid) (defaults to: required("project"))

    The project on which to create a status update.

  • text (String) (defaults to: required("text"))

    The text of the project status update.

  • color (String) (defaults to: required("color"))

    The color to associate with the status update. Must be one of `“red”`, `“yellow”`, or `“green”`.

  • options (Hash) (defaults to: {})

    the request I/O options.

  • data (Hash)

    the attributes to post.


47
48
49
50
# File 'lib/asana/resources/project_status.rb', line 47

def create_in_project(client, project: required("project"), text: required("text"), color: required("color"), options: {}, **data)
  with_params = data.merge(text: text, color: color).reject { |_,v| v.nil? || Array(v).empty? }
  Resource.new(parse(client.post("/projects/#{project}/project_statuses", body: with_params, options: options)).first, client: client)
end

.find_by_id(client, id, options: {}) ⇒ Object

Returns the complete record for a single status update.

Parameters:

  • id (Gid)

    The project status update to get.

  • options (Hash) (defaults to: {})

    the request I/O options.


67
68
69
70
# File 'lib/asana/resources/project_status.rb', line 67

def find_by_id(client, id, options: {})

  self.new(parse(client.get("/project_statuses/#{id}", options: options)).first, client: client)
end

.find_by_project(client, project: required("project"), per_page: 20, options: {}) ⇒ Object

Returns the compact project status update records for all updates on the project.

Parameters:

  • project (Gid) (defaults to: required("project"))

    The project to find status updates for.

  • per_page (Integer) (defaults to: 20)

    the number of records to fetch per page.

  • options (Hash) (defaults to: {})

    the request I/O options.


58
59
60
61
# File 'lib/asana/resources/project_status.rb', line 58

def find_by_project(client, project: required("project"), per_page: 20, options: {})
  params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.get("/projects/#{project}/project_statuses", params: params, options: options)), type: Resource, client: client)
end

.plural_nameObject

Returns the plural name of the resource.


32
33
34
# File 'lib/asana/resources/project_status.rb', line 32

def plural_name
  'project_statuses'
end

Instance Method Details

#deleteObject

Deletes a specific, existing project status update.

Returns:

  • an empty data record.


76
77
78
79
# File 'lib/asana/resources/project_status.rb', line 76

def delete()

  client.delete("/project_statuses/#{gid}") && true
end