{"action":"created","comment":{"url":"https://api.github.com/repos/G5/g5-hub/pulls/comments/27163613","id":27163613,"diff_hunk":"@@ -0,0 +1,55 @@\n+class NotificationService\n+\n+  DEFAULT_SIZE = 25\n+  DEFAULT_PAGE = 0\n+\n+  def list(client, params = {page:0, size:25})\n+\n+    raise ArgumentError, 'client must be non-nil' unless client\n+\n+    size =    if params[:size] && params[:size].to_i > 0\n+                params[:size].to_i\n+              else\n+                DEFAULT_SIZE\n+              end\n+\n+    page =    if params[:page] && params[:page].to_i >= 0\n+                params[:page].to_i\n+              else\n+                DEFAULT_PAGE\n+              end\n+\n+    offset =  page * size\n+\n+    {\n+        # Call to_json to get rid of the wrapping hash in the response\n+        notifications: Notification\n+                           .where(client_id: client.id)\n+                           .order(created_at: :desc, id: :desc)\n+                           .offset(offset)\n+                           .limit(size),\n+\n+        total_rows: Notification.where(client_id: client.id).count\n+    }\n+  end\n+\n+  def create(client, hash={})\n+\n+    raise ArgumentError, 'client must be non-nil' unless client\n+\n+    notification = Notification.new(\n+        product: hash[:product],\n+        locations: hash[:locations],\n+        notif_type: hash[:notif_type],\n+        description: hash[:description],\n+        actions: hash[:actions],\n+        client: client\n+    )\n+\n+    if !notification.invalid?\n+      notification.save\n+    end\n+\n+    notification\n+  end\n+end","path":"lib/notifications_service.rb","position":55,"original_position":55,"commit_id":"54674a24230b1d290b4e3969514c1cc6d67bca14","original_commit_id":"54674a24230b1d290b4e3969514c1cc6d67bca14","user":{"login":"crojasaragonez","id":4663192,"avatar_url":"https://avatars.githubusercontent.com/u/4663192?v=3","gravatar_id":"","url":"https://api.github.com/users/crojasaragonez","html_url":"https://github.com/crojasaragonez","followers_url":"https://api.github.com/users/crojasaragonez/followers","following_url":"https://api.github.com/users/crojasaragonez/following{/other_user}","gists_url":"https://api.github.com/users/crojasaragonez/gists{/gist_id}","starred_url":"https://api.github.com/users/crojasaragonez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crojasaragonez/subscriptions","organizations_url":"https://api.github.com/users/crojasaragonez/orgs","repos_url":"https://api.github.com/users/crojasaragonez/repos","events_url":"https://api.github.com/users/crojasaragonez/events{/privacy}","received_events_url":"https://api.github.com/users/crojasaragonez/received_events","type":"User","site_admin":false},"body":"new line at the end","created_at":"2015-03-25T20:41:01Z","updated_at":"2015-03-25T20:41:01Z","html_url":"https://github.com/G5/g5-hub/pull/121#discussion_r27163613","pull_request_url":"https://api.github.com/repos/G5/g5-hub/pulls/121","_links":{"self":{"href":"https://api.github.com/repos/G5/g5-hub/pulls/comments/27163613"},"html":{"href":"https://github.com/G5/g5-hub/pull/121#discussion_r27163613"},"pull_request":{"href":"https://api.github.com/repos/G5/g5-hub/pulls/121"}}},"pull_request":{"url":"https://api.github.com/repos/G5/g5-hub/pulls/121","id":31566200,"html_url":"https://github.com/G5/g5-hub/pull/121","diff_url":"https://github.com/G5/g5-hub/pull/121.diff","patch_url":"https://github.com/G5/g5-hub/pull/121.patch","issue_url":"https://api.github.com/repos/G5/g5-hub/issues/121","number":121,"state":"open","locked":false,"title":"Notifications model, controller and specs to support https://www.pivotal...","user":{"login":"jonnysamps","id":149911,"avatar_url":"https://avatars.githubusercontent.com/u/149911?v=3","gravatar_id":"","url":"https://api.github.com/users/jonnysamps","html_url":"https://github.com/jonnysamps","followers_url":"https://api.github.com/users/jonnysamps/followers","following_url":"https://api.github.com/users/jonnysamps/following{/other_user}","gists_url":"https://api.github.com/users/jonnysamps/gists{/gist_id}","starred_url":"https://api.github.com/users/jonnysamps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonnysamps/subscriptions","organizations_url":"https://api.github.com/users/jonnysamps/orgs","repos_url":"https://api.github.com/users/jonnysamps/repos","events_url":"https://api.github.com/users/jonnysamps/events{/privacy}","received_events_url":"https://api.github.com/users/jonnysamps/received_events","type":"User","site_admin":false},"body":"...tracker.com/story/show/88759076","created_at":"2015-03-19T21:06:00Z","updated_at":"2015-03-25T20:41:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ca5ab79625276cfbdc034dbfaff758b0f2acd28","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/G5/g5-hub/pulls/121/commits","review_comments_url":"https://api.github.com/repos/G5/g5-hub/pulls/121/comments","review_comment_url":"https://api.github.com/repos/G5/g5-hub/pulls/comments{/number}","comments_url":"https://api.github.com/repos/G5/g5-hub/issues/121/comments","statuses_url":"https://api.github.com/repos/G5/g5-hub/statuses/54674a24230b1d290b4e3969514c1cc6d67bca14","head":{"label":"G5:jps/notifications","ref":"jps/notifications","sha":"54674a24230b1d290b4e3969514c1cc6d67bca14","user":{"login":"G5","id":2396851,"avatar_url":"https://avatars.githubusercontent.com/u/2396851?v=3","gravatar_id":"","url":"https://api.github.com/users/G5","html_url":"https://github.com/G5","followers_url":"https://api.github.com/users/G5/followers","following_url":"https://api.github.com/users/G5/following{/other_user}","gists_url":"https://api.github.com/users/G5/gists{/gist_id}","starred_url":"https://api.github.com/users/G5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/G5/subscriptions","organizations_url":"https://api.github.com/users/G5/orgs","repos_url":"https://api.github.com/users/G5/repos","events_url":"https://api.github.com/users/G5/events{/privacy}","received_events_url":"https://api.github.com/users/G5/received_events","type":"Organization","site_admin":false},"repo":{"id":6051824,"name":"g5-hub","full_name":"G5/g5-hub","owner":{"login":"G5","id":2396851,"avatar_url":"https://avatars.githubusercontent.com/u/2396851?v=3","gravatar_id":"","url":"https://api.github.com/users/G5","html_url":"https://github.com/G5","followers_url":"https://api.github.com/users/G5/followers","following_url":"https://api.github.com/users/G5/following{/other_user}","gists_url":"https://api.github.com/users/G5/gists{/gist_id}","starred_url":"https://api.github.com/users/G5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/G5/subscriptions","organizations_url":"https://api.github.com/users/G5/orgs","repos_url":"https://api.github.com/users/G5/repos","events_url":"https://api.github.com/users/G5/events{/privacy}","received_events_url":"https://api.github.com/users/G5/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/G5/g5-hub","description":"Rails app to create and publish a h-entry feed of clients","fork":false,"url":"https://api.github.com/repos/G5/g5-hub","forks_url":"https://api.github.com/repos/G5/g5-hub/forks","keys_url":"https://api.github.com/repos/G5/g5-hub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/G5/g5-hub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/G5/g5-hub/teams","hooks_url":"https://api.github.com/repos/G5/g5-hub/hooks","issue_events_url":"https://api.github.com/repos/G5/g5-hub/issues/events{/number}","events_url":"https://api.github.com/repos/G5/g5-hub/events","assignees_url":"https://api.github.com/repos/G5/g5-hub/assignees{/user}","branches_url":"https://api.github.com/repos/G5/g5-hub/branches{/branch}","tags_url":"https://api.github.com/repos/G5/g5-hub/tags","blobs_url":"https://api.github.com/repos/G5/g5-hub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/G5/g5-hub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/G5/g5-hub/git/refs{/sha}","trees_url":"https://api.github.com/repos/G5/g5-hub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/G5/g5-hub/statuses/{sha}","languages_url":"https://api.github.com/repos/G5/g5-hub/languages","stargazers_url":"https://api.github.com/repos/G5/g5-hub/stargazers","contributors_url":"https://api.github.com/repos/G5/g5-hub/contributors","subscribers_url":"https://api.github.com/repos/G5/g5-hub/subscribers","subscription_url":"https://api.github.com/repos/G5/g5-hub/subscription","commits_url":"https://api.github.com/repos/G5/g5-hub/commits{/sha}","git_commits_url":"https://api.github.com/repos/G5/g5-hub/git/commits{/sha}","comments_url":"https://api.github.com/repos/G5/g5-hub/comments{/number}","issue_comment_url":"https://api.github.com/repos/G5/g5-hub/issues/comments{/number}","contents_url":"https://api.github.com/repos/G5/g5-hub/contents/{+path}","compare_url":"https://api.github.com/repos/G5/g5-hub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/G5/g5-hub/merges","archive_url":"https://api.github.com/repos/G5/g5-hub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/G5/g5-hub/downloads","issues_url":"https://api.github.com/repos/G5/g5-hub/issues{/number}","pulls_url":"https://api.github.com/repos/G5/g5-hub/pulls{/number}","milestones_url":"https://api.github.com/repos/G5/g5-hub/milestones{/number}","notifications_url":"https://api.github.com/repos/G5/g5-hub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/G5/g5-hub/labels{/name}","releases_url":"https://api.github.com/repos/G5/g5-hub/releases{/id}","created_at":"2012-10-02T21:33:17Z","updated_at":"2015-03-24T23:41:15Z","pushed_at":"2015-03-24T23:41:17Z","git_url":"git://github.com/G5/g5-hub.git","ssh_url":"git@github.com:G5/g5-hub.git","clone_url":"https://github.com/G5/g5-hub.git","svn_url":"https://github.com/G5/g5-hub","homepage":"","size":2781,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":3,"forks":3,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"G5:master","ref":"master","sha":"2916d04fa52816262a0e80479d756d40556f89a6","user":{"login":"G5","id":2396851,"avatar_url":"https://avatars.githubusercontent.com/u/2396851?v=3","gravatar_id":"","url":"https://api.github.com/users/G5","html_url":"https://github.com/G5","followers_url":"https://api.github.com/users/G5/followers","following_url":"https://api.github.com/users/G5/following{/other_user}","gists_url":"https://api.github.com/users/G5/gists{/gist_id}","starred_url":"https://api.github.com/users/G5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/G5/subscriptions","organizations_url":"https://api.github.com/users/G5/orgs","repos_url":"https://api.github.com/users/G5/repos","events_url":"https://api.github.com/users/G5/events{/privacy}","received_events_url":"https://api.github.com/users/G5/received_events","type":"Organization","site_admin":false},"repo":{"id":6051824,"name":"g5-hub","full_name":"G5/g5-hub","owner":{"login":"G5","id":2396851,"avatar_url":"https://avatars.githubusercontent.com/u/2396851?v=3","gravatar_id":"","url":"https://api.github.com/users/G5","html_url":"https://github.com/G5","followers_url":"https://api.github.com/users/G5/followers","following_url":"https://api.github.com/users/G5/following{/other_user}","gists_url":"https://api.github.com/users/G5/gists{/gist_id}","starred_url":"https://api.github.com/users/G5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/G5/subscriptions","organizations_url":"https://api.github.com/users/G5/orgs","repos_url":"https://api.github.com/users/G5/repos","events_url":"https://api.github.com/users/G5/events{/privacy}","received_events_url":"https://api.github.com/users/G5/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/G5/g5-hub","description":"Rails app to create and publish a h-entry feed of clients","fork":false,"url":"https://api.github.com/repos/G5/g5-hub","forks_url":"https://api.github.com/repos/G5/g5-hub/forks","keys_url":"https://api.github.com/repos/G5/g5-hub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/G5/g5-hub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/G5/g5-hub/teams","hooks_url":"https://api.github.com/repos/G5/g5-hub/hooks","issue_events_url":"https://api.github.com/repos/G5/g5-hub/issues/events{/number}","events_url":"https://api.github.com/repos/G5/g5-hub/events","assignees_url":"https://api.github.com/repos/G5/g5-hub/assignees{/user}","branches_url":"https://api.github.com/repos/G5/g5-hub/branches{/branch}","tags_url":"https://api.github.com/repos/G5/g5-hub/tags","blobs_url":"https://api.github.com/repos/G5/g5-hub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/G5/g5-hub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/G5/g5-hub/git/refs{/sha}","trees_url":"https://api.github.com/repos/G5/g5-hub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/G5/g5-hub/statuses/{sha}","languages_url":"https://api.github.com/repos/G5/g5-hub/languages","stargazers_url":"https://api.github.com/repos/G5/g5-hub/stargazers","contributors_url":"https://api.github.com/repos/G5/g5-hub/contributors","subscribers_url":"https://api.github.com/repos/G5/g5-hub/subscribers","subscription_url":"https://api.github.com/repos/G5/g5-hub/subscription","commits_url":"https://api.github.com/repos/G5/g5-hub/commits{/sha}","git_commits_url":"https://api.github.com/repos/G5/g5-hub/git/commits{/sha}","comments_url":"https://api.github.com/repos/G5/g5-hub/comments{/number}","issue_comment_url":"https://api.github.com/repos/G5/g5-hub/issues/comments{/number}","contents_url":"https://api.github.com/repos/G5/g5-hub/contents/{+path}","compare_url":"https://api.github.com/repos/G5/g5-hub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/G5/g5-hub/merges","archive_url":"https://api.github.com/repos/G5/g5-hub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/G5/g5-hub/downloads","issues_url":"https://api.github.com/repos/G5/g5-hub/issues{/number}","pulls_url":"https://api.github.com/repos/G5/g5-hub/pulls{/number}","milestones_url":"https://api.github.com/repos/G5/g5-hub/milestones{/number}","notifications_url":"https://api.github.com/repos/G5/g5-hub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/G5/g5-hub/labels{/name}","releases_url":"https://api.github.com/repos/G5/g5-hub/releases{/id}","created_at":"2012-10-02T21:33:17Z","updated_at":"2015-03-24T23:41:15Z","pushed_at":"2015-03-24T23:41:17Z","git_url":"git://github.com/G5/g5-hub.git","ssh_url":"git@github.com:G5/g5-hub.git","clone_url":"https://github.com/G5/g5-hub.git","svn_url":"https://github.com/G5/g5-hub","homepage":"","size":2781,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":3,"forks":3,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/G5/g5-hub/pulls/121"},"html":{"href":"https://github.com/G5/g5-hub/pull/121"},"issue":{"href":"https://api.github.com/repos/G5/g5-hub/issues/121"},"comments":{"href":"https://api.github.com/repos/G5/g5-hub/issues/121/comments"},"review_comments":{"href":"https://api.github.com/repos/G5/g5-hub/pulls/121/comments"},"review_comment":{"href":"https://api.github.com/repos/G5/g5-hub/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/G5/g5-hub/pulls/121/commits"},"statuses":{"href":"https://api.github.com/repos/G5/g5-hub/statuses/54674a24230b1d290b4e3969514c1cc6d67bca14"}}}}