Class: TrackerApi::Endpoints::Epic

Inherits:
Object
  • Object
show all
Defined in:
lib/tracker_api/endpoints/epic.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Epic

Returns a new instance of Epic.



6
7
8
# File 'lib/tracker_api/endpoints/epic.rb', line 6

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/tracker_api/endpoints/epic.rb', line 4

def client
  @client
end

Instance Method Details

#create(project_id, params = {}) ⇒ Object



22
23
24
25
26
# File 'lib/tracker_api/endpoints/epic.rb', line 22

def create(project_id, params={})
  data = client.post("/projects/#{project_id}/epics", params: params).body

  Resources::Epic.new({ client: client }.merge(data))
end

#get(project_id, id, params = {}) ⇒ Object



10
11
12
13
14
# File 'lib/tracker_api/endpoints/epic.rb', line 10

def get(project_id, id, params={})
  data = client.get("/projects/#{project_id}/epics/#{id}", params: params).body

  Resources::Epic.new({ client: client, project_id: project_id }.merge(data))
end

#get_epic(epic_id, params = {}) ⇒ Object



16
17
18
19
20
# File 'lib/tracker_api/endpoints/epic.rb', line 16

def get_epic(epic_id, params={})
  data = client.get("/epics/#{epic_id}", params: params).body

  Resources::Epic.new({ client: client }.merge(data))
end

#update(epic, params = {}) ⇒ Object

Raises:

  • (ArgumentError)


28
29
30
31
32
33
34
35
36
# File 'lib/tracker_api/endpoints/epic.rb', line 28

def update(epic, params={})
  raise ArgumentError, 'Valid epic required to update.' unless epic.instance_of?(Resources::Epic)

  data = client.put("/projects/#{epic.project_id}/epics/#{epic.id}", params: params).body

  epic.attributes = data
  epic.clean!
  epic
end