diff --git a/lib/tracker_api.rb b/lib/tracker_api.rb index 8e91e3d..f7cd743 100644 --- a/lib/tracker_api.rb +++ b/lib/tracker_api.rb @@ -25,6 +25,7 @@ module Endpoints autoload :Iterations, 'tracker_api/endpoints/iterations' autoload :Me, 'tracker_api/endpoints/me' autoload :Memberships, 'tracker_api/endpoints/memberships' + autoload :Notifications, 'tracker_api/endpoints/notifications' autoload :Project, 'tracker_api/endpoints/project' autoload :Projects, 'tracker_api/endpoints/projects' autoload :Stories, 'tracker_api/endpoints/stories' @@ -38,6 +39,7 @@ module Resources autoload :Iteration, 'tracker_api/resources/iteration' autoload :Me, 'tracker_api/resources/me' autoload :MembershipSummary, 'tracker_api/resources/membership_summary' + autoload :Notification, 'tracker_api/resources/notification' autoload :Label, 'tracker_api/resources/label' autoload :Person, 'tracker_api/resources/person' autoload :Project, 'tracker_api/resources/project' diff --git a/lib/tracker_api/client.rb b/lib/tracker_api/client.rb index 7f24f4b..c6d6e5f 100644 --- a/lib/tracker_api/client.rb +++ b/lib/tracker_api/client.rb @@ -131,6 +131,10 @@ def story(story_id) Endpoints::Story.new(self).get_story(story_id) end + def notifications + Endpoints::Notifications.new(self).get + end + private def parse_query_and_convenience_headers(path, options) diff --git a/lib/tracker_api/endpoints/notifications.rb b/lib/tracker_api/endpoints/notifications.rb new file mode 100644 index 0000000..6d7b395 --- /dev/null +++ b/lib/tracker_api/endpoints/notifications.rb @@ -0,0 +1,18 @@ +module TrackerApi + module Endpoints + class Notifications + attr_accessor :client + + def initialize(client) + @client = client + end + + def get(params={}) + data = client.paginate("/my/notifications") + data.map do |notification| + Resources::Notification.new({ client: client }.merge(notification)) + end + end + end + end +end diff --git a/lib/tracker_api/resources/notification.rb b/lib/tracker_api/resources/notification.rb new file mode 100644 index 0000000..3d10715 --- /dev/null +++ b/lib/tracker_api/resources/notification.rb @@ -0,0 +1,16 @@ +module TrackerApi + module Resources + class Notification + include Virtus.model + + attribute :id, Integer + attribute :message, String + attribute :kind, String + attribute :project, TrackerApi::Resources::Project + attribute :story, TrackerApi::Resources::Story + attribute :performer, TrackerApi::Resources::Person + attribute :created_at, DateTime + attribute :updated_at, DateTime + end + end +end