Class: TrackerApi::Endpoints::Activity

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Activity

Returns a new instance of Activity.



6
7
8
# File 'lib/tracker_api/endpoints/activity.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/activity.rb', line 4

def client
  @client
end

Instance Method Details

#get(params = {}) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/tracker_api/endpoints/activity.rb', line 10

def get(params={})
  data = client.paginate("/my/activity", params: params)
  raise Errors::UnexpectedData, 'Array of activities expected' unless data.is_a? Array

  data.map do |activity|
    Resources::Activity.new({ client: client }.merge(activity))
  end
end

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



19
20
21
22
23
24
25
26
# File 'lib/tracker_api/endpoints/activity.rb', line 19

def get_project(project_id, params={})
  data = client.paginate("/projects/#{project_id}/activity", params: params)
  raise Errors::UnexpectedData, 'Array of activities expected' unless data.is_a? Array

  data.map do |activity|
    Resources::Activity.new({ client: client }.merge(activity))
  end
end

#get_story(project_id, story_id, params = {}) ⇒ Object



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

def get_story(project_id, story_id, params={})
  data = client.paginate("/projects/#{project_id}/stories/#{story_id}/activity", params: params)
  raise Errors::UnexpectedData, 'Array of activities expected' unless data.is_a? Array

  data.map do |activity|
    Resources::Activity.new({ client: client }.merge(activity))
  end
end