tracker_api 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +11 -2
- data/lib/tracker_api/client.rb +26 -1
- data/lib/tracker_api/endpoints/activity.rb +38 -0
- data/lib/tracker_api/endpoints/epic.rb +1 -1
- data/lib/tracker_api/endpoints/epics.rb +1 -1
- data/lib/tracker_api/endpoints/me.rb +1 -1
- data/lib/tracker_api/endpoints/memberships.rb +1 -1
- data/lib/tracker_api/endpoints/notifications.rb +20 -0
- data/lib/tracker_api/endpoints/story.rb +8 -0
- data/lib/tracker_api/endpoints/tasks.rb +1 -1
- data/lib/tracker_api/resources/activity.rb +24 -0
- data/lib/tracker_api/resources/base.rb +71 -0
- data/lib/tracker_api/resources/change.rb +15 -0
- data/lib/tracker_api/resources/epic.rb +0 -2
- data/lib/tracker_api/resources/iteration.rb +4 -0
- data/lib/tracker_api/resources/me.rb +0 -2
- data/lib/tracker_api/resources/membership_summary.rb +0 -2
- data/lib/tracker_api/resources/notification.rb +26 -0
- data/lib/tracker_api/resources/person.rb +0 -2
- data/lib/tracker_api/resources/primary_resource.rb +13 -0
- data/lib/tracker_api/resources/project.rb +26 -3
- data/lib/tracker_api/resources/project_membership.rb +0 -2
- data/lib/tracker_api/resources/story.rb +21 -2
- data/lib/tracker_api/resources/task.rb +0 -2
- data/lib/tracker_api/version.rb +1 -1
- data/lib/tracker_api.rb +7 -0
- data/test/client_test.rb +45 -1
- data/test/project_test.rb +50 -0
- data/test/story_test.rb +50 -1
- data/test/vcr/cassettes/client_done_iterations_with_pagination.json +1 -1
- data/test/vcr/cassettes/client_get_limited_stories_with_no_pagination.json +1 -0
- data/test/vcr/cassettes/create_story.json +1 -0
- data/test/vcr/cassettes/get_activity.json +148 -0
- data/test/vcr/cassettes/get_all_notifications.json +50 -0
- data/test/vcr/cassettes/get_done_iterations.json +1 -1
- data/test/vcr/cassettes/get_iteration_by_number.json +1 -0
- data/test/vcr/cassettes/get_my_activities.json +1 -0
- data/test/vcr/cassettes/get_project_activity.json +1 -0
- data/test/vcr/cassettes/get_story.json +1 -0
- data/test/vcr/cassettes/get_story_activity.json +1 -0
- data/test/vcr/cassettes/get_tasks_when_stories_filtered.json +1 -0
- data/test/vcr/cassettes/get_unscheduled_story.json +1 -0
- data/test/vcr/cassettes/save_story.json +1 -0
- data/test/vcr/cassettes/save_story_with_multiple_changes.json +1 -0
- data/test/vcr/cassettes/update_story_to_create_activity.json +1 -0
- data/tracker_api.gemspec +3 -2
- metadata +101 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a725b042575ce91d5fe34fae3754d7f14ebad3b
|
4
|
+
data.tar.gz: 3922fb5873893235e94de37dc705954965215604
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc75849fe80c0a8a4614149dc1ad7d77b7bf9d6b036d0d305120ad2f8a1201e4fac7815a71b1496ce3894c7e96796e9a87f25132278353635cb0fa4383f2fba4
|
7
|
+
data.tar.gz: e639910732c78410d570e198f965dfa0ae00ec39ce0e7171e2cc89e3d11976627acc46c4c0a16870c9476a7e87eea7eb8367a6b89584d634da5db01a66cebbe5
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -35,17 +35,26 @@ $ gem install tracker_api
|
|
35
35
|
```ruby
|
36
36
|
client = TrackerApi::Client.new(token: 'my-api-token') # Create API client
|
37
37
|
|
38
|
-
|
38
|
+
client.me.email # Get email for the authenticated person
|
39
|
+
client.activity # Get a list of all the activity performed the authenticated person
|
40
|
+
client.notifications # Get notifications for the authenticated person
|
39
41
|
|
40
42
|
projects = client.projects # Get all projects
|
41
43
|
project = client.project(123456) # Find project with given ID
|
44
|
+
project.activity # Get a list of all the activity performed on this project
|
42
45
|
|
43
46
|
project.stories # Get all stories for a project
|
44
47
|
project.stories(with_state: :unscheduled, limit: 10) # Get 10 unscheduled stories for a project
|
45
48
|
project.stories(filter: 'requester:OWK label:"jedi stuff"') # Get all stories that match the given filters
|
46
|
-
project.story(847762630) # Find a story with the given ID
|
47
49
|
project.create_story(name: 'Destroy death star') # Create a story with the name 'Destroy death star'
|
48
50
|
|
51
|
+
story = project.story(847762630) # Find a story with the given ID
|
52
|
+
story.activity # Get a list of all the activity performed on this story
|
53
|
+
|
54
|
+
story.name = 'Save the Ewoks' # Update a single story attribute
|
55
|
+
story.attributes = { name: 'Save the Ewoks', description: '...' } # Update multiple story attributes
|
56
|
+
story.save # Save changes made to a story
|
57
|
+
|
49
58
|
epics = project.epics # Get all epics for a project
|
50
59
|
epic = epics.first
|
51
60
|
label = epic.label # Get an epic's label
|
data/lib/tracker_api/client.rb
CHANGED
@@ -25,7 +25,7 @@ module TrackerApi
|
|
25
25
|
@url = Addressable::URI.parse(url).to_s
|
26
26
|
@api_version = options.fetch(:api_version, '/services/v5')
|
27
27
|
@logger = options.fetch(:logger, ::Logger.new(nil))
|
28
|
-
adapter = options.fetch(:adapter, :
|
28
|
+
adapter = options.fetch(:adapter, :excon)
|
29
29
|
connection_options = options.fetch(:connection_options, { ssl: { verify: true } })
|
30
30
|
@auto_paginate = options.fetch(:auto_paginate, true)
|
31
31
|
@token = options[:token]
|
@@ -63,6 +63,15 @@ module TrackerApi
|
|
63
63
|
request(:post, parse_query_and_convenience_headers(path, options))
|
64
64
|
end
|
65
65
|
|
66
|
+
# Make a HTTP PUT request
|
67
|
+
#
|
68
|
+
# @param path [String] The path, relative to api endpoint
|
69
|
+
# @param options [Hash] Query and header params for request
|
70
|
+
# @return [Faraday::Response]
|
71
|
+
def put(path, options = {})
|
72
|
+
request(:put, parse_query_and_convenience_headers(path, options))
|
73
|
+
end
|
74
|
+
|
66
75
|
# Make one or more HTTP GET requests, optionally fetching
|
67
76
|
# the next page of results from information passed back in headers
|
68
77
|
# based on value in {#auto_paginate}.
|
@@ -131,6 +140,22 @@ module TrackerApi
|
|
131
140
|
Endpoints::Story.new(self).get_story(story_id)
|
132
141
|
end
|
133
142
|
|
143
|
+
# Get notifications for the authenticated person
|
144
|
+
#
|
145
|
+
# @param [Hash] params
|
146
|
+
# @return [Array[TrackerApi::Resources::Notification]]
|
147
|
+
def notifications(params={})
|
148
|
+
Endpoints::Notifications.new(self).get(params)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Provides a list of all the activity performed the authenticated person.
|
152
|
+
#
|
153
|
+
# @param [Hash] params
|
154
|
+
# @return [Array[TrackerApi::Resources::Activity]]
|
155
|
+
def activity(params={})
|
156
|
+
Endpoints::Activity.new(self).get(params)
|
157
|
+
end
|
158
|
+
|
134
159
|
private
|
135
160
|
|
136
161
|
def parse_query_and_convenience_headers(path, options)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module TrackerApi
|
2
|
+
module Endpoints
|
3
|
+
class Activity
|
4
|
+
attr_accessor :client
|
5
|
+
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def get(params={})
|
11
|
+
data = client.paginate("/my/activity", params: params)
|
12
|
+
raise TrackerApi::Errors::UnexpectedData, 'Array of activities expected' unless data.is_a? Array
|
13
|
+
|
14
|
+
data.map do |activity|
|
15
|
+
Resources::Activity.new({ client: client }.merge(activity))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_project(project_id, params={})
|
20
|
+
data = client.paginate("/projects/#{project_id}/activity", params: params)
|
21
|
+
raise TrackerApi::Errors::UnexpectedData, 'Array of activities expected' unless data.is_a? Array
|
22
|
+
|
23
|
+
data.map do |activity|
|
24
|
+
Resources::Activity.new({ client: client }.merge(activity))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_story(project_id, story_id, params={})
|
29
|
+
data = client.paginate("/projects/#{project_id}/stories/#{story_id}/activity", params: params)
|
30
|
+
raise TrackerApi::Errors::UnexpectedData, 'Array of activities expected' unless data.is_a? Array
|
31
|
+
|
32
|
+
data.map do |activity|
|
33
|
+
Resources::Activity.new({ client: client }.merge(activity))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -10,7 +10,7 @@ module TrackerApi
|
|
10
10
|
def get(project_id, id)
|
11
11
|
data = client.get("/projects/#{project_id}/epics/#{id}").body
|
12
12
|
|
13
|
-
Resources::Epic.new({
|
13
|
+
Resources::Epic.new({ project_id: project_id }.merge(data))
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -12,7 +12,7 @@ module TrackerApi
|
|
12
12
|
raise TrackerApi::Errors::UnexpectedData, 'Array of epics expected' unless data.is_a? Array
|
13
13
|
|
14
14
|
data.map do |epic|
|
15
|
-
Resources::Epic.new({
|
15
|
+
Resources::Epic.new({ project_id: project_id }.merge(epic))
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -12,7 +12,7 @@ module TrackerApi
|
|
12
12
|
raise TrackerApi::Errors::UnexpectedData, 'Array of memberships expected' unless data.is_a? Array
|
13
13
|
|
14
14
|
data.map do |membership|
|
15
|
-
Resources::ProjectMembership.new({
|
15
|
+
Resources::ProjectMembership.new({ project_id: project_id }.merge(membership))
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module TrackerApi
|
2
|
+
module Endpoints
|
3
|
+
class Notifications
|
4
|
+
attr_accessor :client
|
5
|
+
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def get(params={})
|
11
|
+
data = client.paginate('/my/notifications', params: params)
|
12
|
+
raise TrackerApi::Errors::UnexpectedData, 'Array of notifications expected' unless data.is_a? Array
|
13
|
+
|
14
|
+
data.map do |notification|
|
15
|
+
Resources::Notification.new({ client: client }.merge(notification))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -24,6 +24,14 @@ module TrackerApi
|
|
24
24
|
|
25
25
|
Resources::Story.new({ client: client }.merge(data))
|
26
26
|
end
|
27
|
+
|
28
|
+
def update(story, params={})
|
29
|
+
raise ArgumentError, 'Valid story required to update.' unless story.instance_of?(Resources::Story)
|
30
|
+
|
31
|
+
data = client.put("/projects/#{story.project_id}/stories/#{story.id}", params: params).body
|
32
|
+
|
33
|
+
story.attributes = data
|
34
|
+
end
|
27
35
|
end
|
28
36
|
end
|
29
37
|
end
|
@@ -12,7 +12,7 @@ module TrackerApi
|
|
12
12
|
raise TrackerApi::Errors::UnexpectedData, 'Array of tasks expected' unless data.is_a? Array
|
13
13
|
|
14
14
|
data.map do |task|
|
15
|
-
Resources::Task.new({
|
15
|
+
Resources::Task.new({ story_id: story_id }.merge(task))
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module TrackerApi
|
2
|
+
module Resources
|
3
|
+
class Activity
|
4
|
+
include Virtus.model
|
5
|
+
|
6
|
+
attribute :client
|
7
|
+
|
8
|
+
attribute :kind, String
|
9
|
+
attribute :guid, String
|
10
|
+
attribute :project_version, Integer
|
11
|
+
attribute :message, String
|
12
|
+
attribute :highlight, String
|
13
|
+
attribute :changes, Array[TrackerApi::Resources::Change]
|
14
|
+
attribute :primary_resources, Array[TrackerApi::Resources::PrimaryResource]
|
15
|
+
attribute :project, TrackerApi::Resources::Project
|
16
|
+
attribute :performed_by, TrackerApi::Resources::Person
|
17
|
+
attribute :occurred_at, DateTime
|
18
|
+
|
19
|
+
def project=(data)
|
20
|
+
super.client = client
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'virtus'
|
2
|
+
require 'active_support/concern'
|
3
|
+
require 'active_model'
|
4
|
+
|
5
|
+
module TrackerApi
|
6
|
+
module Resources
|
7
|
+
module Base
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
include ActiveModel::Model
|
11
|
+
include ActiveModel::Dirty
|
12
|
+
|
13
|
+
included do
|
14
|
+
include Virtus.model
|
15
|
+
include OverrideAttributes
|
16
|
+
|
17
|
+
attribute :id, Integer
|
18
|
+
|
19
|
+
def initialize(attrs)
|
20
|
+
super
|
21
|
+
|
22
|
+
# always reset dirty tracking on initialize
|
23
|
+
reset_changes
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
# @return [Hash] key value pairs for just the changed attributes with their new values.
|
29
|
+
def just_changes
|
30
|
+
# @see changes in ActiveModel::Dirty in active_model/dirty.rb
|
31
|
+
# { attr => [original value, new value] }
|
32
|
+
changes.inject({}) do |h, (k, v)|
|
33
|
+
h[k] = v[1]; h;
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module OverrideAttributes
|
39
|
+
extend ActiveSupport::Concern
|
40
|
+
|
41
|
+
module ClassMethods
|
42
|
+
def attribute(name, type, options = {})
|
43
|
+
define_attribute_methods name
|
44
|
+
|
45
|
+
attribute = super
|
46
|
+
create_writer_with_dirty_tracking(name)
|
47
|
+
attribute
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def create_writer_with_dirty_tracking(name)
|
53
|
+
method_str = <<-RUBY
|
54
|
+
def #{name}=(value)
|
55
|
+
prev_value = #{name}
|
56
|
+
new_value = value
|
57
|
+
if prev_value != new_value
|
58
|
+
#{name}_will_change!
|
59
|
+
new_value = super(value)
|
60
|
+
end
|
61
|
+
new_value
|
62
|
+
end
|
63
|
+
RUBY
|
64
|
+
|
65
|
+
class_eval method_str, __FILE__, __LINE__ + 1
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module TrackerApi
|
2
|
+
module Resources
|
3
|
+
class Change
|
4
|
+
include Virtus.model
|
5
|
+
|
6
|
+
attribute :change_type, String
|
7
|
+
attribute :id, Integer
|
8
|
+
attribute :kind, String
|
9
|
+
attribute :name, String
|
10
|
+
attribute :new_values, Hash
|
11
|
+
attribute :original_values, Hash
|
12
|
+
attribute :story_type, String
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module TrackerApi
|
2
|
+
module Resources
|
3
|
+
class Notification
|
4
|
+
include Virtus.model
|
5
|
+
|
6
|
+
attribute :client
|
7
|
+
|
8
|
+
attribute :id, Integer
|
9
|
+
attribute :message, String
|
10
|
+
attribute :kind, String
|
11
|
+
attribute :project, TrackerApi::Resources::Project
|
12
|
+
attribute :story, TrackerApi::Resources::Story
|
13
|
+
attribute :performer, TrackerApi::Resources::Person
|
14
|
+
attribute :created_at, DateTime
|
15
|
+
attribute :updated_at, DateTime
|
16
|
+
|
17
|
+
def project=(data)
|
18
|
+
super.client = client
|
19
|
+
end
|
20
|
+
|
21
|
+
def story=(data)
|
22
|
+
super.client = client
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -45,6 +45,7 @@ module TrackerApi
|
|
45
45
|
@label_list ||= labels.collect(&:name).join(',')
|
46
46
|
end
|
47
47
|
|
48
|
+
# @param [Hash] params
|
48
49
|
# @return [Array[Epic]] epics associated with this project
|
49
50
|
def epics(params={})
|
50
51
|
raise ArgumentError, 'Expected @epics to be an Array' unless @epics.is_a? Array
|
@@ -57,11 +58,23 @@ module TrackerApi
|
|
57
58
|
# @option params [String] :scope Restricts the state of iterations to return.
|
58
59
|
# If not specified, it defaults to all iterations including done.
|
59
60
|
# Valid enumeration values: done, current, backlog, current_backlog.
|
61
|
+
# @option params [Integer] :number The iteration to retrieve, starting at 1
|
60
62
|
# @option params [Integer] :offset The offset of first iteration to return, relative to the
|
61
63
|
# set of iterations specified by 'scope', with zero being the first iteration in the scope.
|
62
64
|
# @option params [Integer] :limit The number of iterations to return relative to the offset.
|
63
65
|
# @return [Array[Iteration]] iterations associated with this project
|
64
66
|
def iterations(params = {})
|
67
|
+
if params.include?(:number)
|
68
|
+
number = params[:number].to_i
|
69
|
+
raise ArgumentError, ':number must be > 0' unless number > 0
|
70
|
+
|
71
|
+
params = params.merge(auto_paginate: false, limit: 1)
|
72
|
+
params.delete(:number)
|
73
|
+
|
74
|
+
offset = number - 1
|
75
|
+
params[:offset] = offset if offset > 0
|
76
|
+
end
|
77
|
+
|
65
78
|
Endpoints::Iterations.new(client).get(id, params)
|
66
79
|
end
|
67
80
|
|
@@ -81,18 +94,28 @@ module TrackerApi
|
|
81
94
|
Endpoints::Stories.new(client).get(id, params)
|
82
95
|
end
|
83
96
|
|
97
|
+
# @param [Hash] params
|
98
|
+
# @return [Array[ProjectMembership]] memberships of this project
|
84
99
|
def memberships(params = {})
|
85
100
|
Endpoints::Memberships.new(client).get(id, params)
|
86
101
|
end
|
87
102
|
|
103
|
+
# Provides a list of all the activity performed on a project.
|
104
|
+
#
|
105
|
+
# @param [Hash] params
|
106
|
+
# @return [Array[Activity]]
|
107
|
+
def activity(params = {})
|
108
|
+
Endpoints::Activity.new(client).get_project(id, params)
|
109
|
+
end
|
110
|
+
|
88
111
|
# @param [Fixnum] story_id id of story to get
|
89
|
-
# @return [Story]
|
112
|
+
# @return [Story] story with given id
|
90
113
|
def story(story_id)
|
91
114
|
Endpoints::Story.new(client).get(id, story_id)
|
92
115
|
end
|
93
116
|
|
94
|
-
# @param [Hash]
|
95
|
-
# @return [Story]
|
117
|
+
# @param [Hash] params attributes to create the story with
|
118
|
+
# @return [Story] newly created Story
|
96
119
|
def create_story(params)
|
97
120
|
Endpoints::Story.new(client).create(id, params)
|
98
121
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module TrackerApi
|
2
2
|
module Resources
|
3
3
|
class Story
|
4
|
-
include
|
4
|
+
include TrackerApi::Resources::Base
|
5
5
|
|
6
6
|
attribute :client
|
7
7
|
|
@@ -14,13 +14,13 @@ module TrackerApi
|
|
14
14
|
attribute :estimate, Float
|
15
15
|
attribute :external_id, String
|
16
16
|
attribute :follower_ids, Array[Integer]
|
17
|
-
attribute :id, Integer
|
18
17
|
attribute :integration_id, Integer
|
19
18
|
attribute :kind, String
|
20
19
|
attribute :label_ids, Array[Integer]
|
21
20
|
attribute :labels, Array[TrackerApi::Resources::Label]
|
22
21
|
attribute :name, String
|
23
22
|
attribute :owned_by_id, Integer # deprecated!
|
23
|
+
attribute :owner_ids, Array[Integer]
|
24
24
|
attribute :owners, Array[TrackerApi::Resources::Person]
|
25
25
|
attribute :planned_iteration_number, Integer
|
26
26
|
attribute :project_id, Integer
|
@@ -36,6 +36,16 @@ module TrackerApi
|
|
36
36
|
@label_list ||= labels.collect(&:name).join(',')
|
37
37
|
end
|
38
38
|
|
39
|
+
# Provides a list of all the activity performed on the story.
|
40
|
+
#
|
41
|
+
# @param [Hash] params
|
42
|
+
# @return [Array[Activity]]
|
43
|
+
def activity(params = {})
|
44
|
+
Endpoints::Activity.new(client).get_story(project_id, id, params)
|
45
|
+
end
|
46
|
+
|
47
|
+
# @param [Hash] params
|
48
|
+
# @return [Array[Task]]
|
39
49
|
def tasks(params = {})
|
40
50
|
if @tasks.any?
|
41
51
|
@tasks
|
@@ -43,6 +53,15 @@ module TrackerApi
|
|
43
53
|
@tasks = Endpoints::Tasks.new(client).get(project_id, id, params)
|
44
54
|
end
|
45
55
|
end
|
56
|
+
|
57
|
+
# Save changes to an existing Story.
|
58
|
+
def save
|
59
|
+
raise ArgumentError, 'Can not update a story with an unknown project_id.' if project_id.nil?
|
60
|
+
|
61
|
+
Endpoints::Story.new(client).update(self, just_changes)
|
62
|
+
|
63
|
+
changes_applied
|
64
|
+
end
|
46
65
|
end
|
47
66
|
end
|
48
67
|
end
|
data/lib/tracker_api/version.rb
CHANGED
data/lib/tracker_api.rb
CHANGED
@@ -20,11 +20,13 @@ module TrackerApi
|
|
20
20
|
end
|
21
21
|
|
22
22
|
module Endpoints
|
23
|
+
autoload :Activity, 'tracker_api/endpoints/activity'
|
23
24
|
autoload :Epic, 'tracker_api/endpoints/epic'
|
24
25
|
autoload :Epics, 'tracker_api/endpoints/epics'
|
25
26
|
autoload :Iterations, 'tracker_api/endpoints/iterations'
|
26
27
|
autoload :Me, 'tracker_api/endpoints/me'
|
27
28
|
autoload :Memberships, 'tracker_api/endpoints/memberships'
|
29
|
+
autoload :Notifications, 'tracker_api/endpoints/notifications'
|
28
30
|
autoload :Project, 'tracker_api/endpoints/project'
|
29
31
|
autoload :Projects, 'tracker_api/endpoints/projects'
|
30
32
|
autoload :Stories, 'tracker_api/endpoints/stories'
|
@@ -33,13 +35,18 @@ module TrackerApi
|
|
33
35
|
end
|
34
36
|
|
35
37
|
module Resources
|
38
|
+
autoload :Base, 'tracker_api/resources/base'
|
39
|
+
autoload :Activity, 'tracker_api/resources/activity'
|
36
40
|
autoload :Account, 'tracker_api/resources/account'
|
41
|
+
autoload :Change, 'tracker_api/resources/change'
|
37
42
|
autoload :Epic, 'tracker_api/resources/epic'
|
38
43
|
autoload :Iteration, 'tracker_api/resources/iteration'
|
39
44
|
autoload :Me, 'tracker_api/resources/me'
|
40
45
|
autoload :MembershipSummary, 'tracker_api/resources/membership_summary'
|
46
|
+
autoload :Notification, 'tracker_api/resources/notification'
|
41
47
|
autoload :Label, 'tracker_api/resources/label'
|
42
48
|
autoload :Person, 'tracker_api/resources/person'
|
49
|
+
autoload :PrimaryResource, 'tracker_api/resources/primary_resource'
|
43
50
|
autoload :Project, 'tracker_api/resources/project'
|
44
51
|
autoload :ProjectMembership, 'tracker_api/resources/project_membership'
|
45
52
|
autoload :Story, 'tracker_api/resources/story'
|
data/test/client_test.rb
CHANGED
@@ -86,7 +86,7 @@ describe TrackerApi::Client do
|
|
86
86
|
|
87
87
|
it 'auto paginates when needed' do
|
88
88
|
VCR.use_cassette('client: get all stories with pagination', record: :new_episodes) do
|
89
|
-
project
|
89
|
+
project = client.project(project_id)
|
90
90
|
|
91
91
|
# skip pagination with a hugh limit
|
92
92
|
unpaged_stories = project.stories(limit: 300)
|
@@ -136,4 +136,48 @@ describe TrackerApi::Client do
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
139
|
+
|
140
|
+
describe '.notifictions' do
|
141
|
+
let(:pt_user) { PT_USER_1 }
|
142
|
+
let(:client) { TrackerApi::Client.new token: pt_user[:token] }
|
143
|
+
|
144
|
+
it 'gets authenticated persons notifications' do
|
145
|
+
VCR.use_cassette('get all notifications', record: :new_episodes) do
|
146
|
+
notifications = client.notifications
|
147
|
+
|
148
|
+
notifications.wont_be_empty
|
149
|
+
notification = notifications.first
|
150
|
+
notification.must_be_instance_of TrackerApi::Resources::Notification
|
151
|
+
|
152
|
+
notification.project.id.must_equal pt_user[:project_id]
|
153
|
+
notification.story.must_be_instance_of TrackerApi::Resources::Story
|
154
|
+
notification.performer.must_be_instance_of TrackerApi::Resources::Person
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe '.activity' do
|
160
|
+
let(:pt_user) { PT_USER_1 }
|
161
|
+
let(:client) { TrackerApi::Client.new token: pt_user[:token] }
|
162
|
+
|
163
|
+
it 'gets all my activities' do
|
164
|
+
VCR.use_cassette('get my activities', record: :new_episodes) do
|
165
|
+
activities = client.activity(fields: ':default')
|
166
|
+
|
167
|
+
activities.wont_be_empty
|
168
|
+
activity = activities.first
|
169
|
+
activity.must_be_instance_of TrackerApi::Resources::Activity
|
170
|
+
|
171
|
+
activity.changes.wont_be_empty
|
172
|
+
activity.changes.first.must_be_instance_of TrackerApi::Resources::Change
|
173
|
+
|
174
|
+
activity.primary_resources.wont_be_empty
|
175
|
+
activity.primary_resources.first.must_be_instance_of TrackerApi::Resources::PrimaryResource
|
176
|
+
|
177
|
+
activity.project.must_be_instance_of TrackerApi::Resources::Project
|
178
|
+
|
179
|
+
activity.performed_by.must_be_instance_of TrackerApi::Resources::Person
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
139
183
|
end
|