{"action":"created","comment":{"url":"https://api.github.com/repos/zendesk/radar_client/pulls/comments/38044807","id":38044807,"diff_hunk":"@@ -130,210 +132,181 @@ Client.prototype.stream = function(scope) {\n   return new Scope('stream', scope, this);\n };\n \n-// Access the \"control\" chainable operations\n Client.prototype.control = function(scope) {\n   return new Scope('control', scope, this);\n };\n \n+// Operations\n+\n Client.prototype.nameSync = function(scope, options, callback) {\n-  var message = { op: 'nameSync', to: scope };\n-  if (typeof options == 'function') {\n-    callback = options;\n-  } else {\n-    message.options = options;\n-  }\n-  return this._write(message, callback);\n+  var request = Request.buildNameSync(scope, options);\n+  return this._write(request, callback);\n };\n \n Client.prototype.push = function(scope, resource, action, value, callback) {\n-  return this._write({\n-    op: 'push',\n-    to: scope,\n-    resource: resource,\n-    action: action,\n-    value: value\n-  }, callback);\n+  var request = Request.buildPush(scope, resource, action, value);\n+  return this._write(request, callback);\n };\n \n Client.prototype.set = function(scope, value, clientData, callback) {\n-  var message = {\n-    op: 'set',\n-    to: scope,\n-    value: value,\n-    key: this._configuration.userId,\n-    type: this._configuration.userType\n-  };\n-\n+  var request = Request.buildSet(scope, value,\n+                  this._configuration.userId, this._configuration.userType);\n   if (typeof(clientData) === 'function') {\n     callback = clientData;\n-  } else {\n-    message.clientData = clientData;\n+  } else if (request) {\n+    request.setAttr('clientData', clientData);\n   }\n \n-  return this._write(message, callback);\n+  return this._write(request, callback);\n };\n \n Client.prototype.publish = function(scope, value, callback) {\n-  return this._write({\n-    op: 'publish',\n-    to: scope,\n-    value: value\n-  }, callback);\n+  var request = Request.buildPublish(scope, value);\n+  return this._write(request, callback);\n };\n \n Client.prototype.subscribe = function(scope, options, callback) {\n-  var message = { op: 'subscribe', to: scope };\n-  if (typeof options == 'function') {\n-    callback = options;\n-  } else {\n-    message.options = options;\n-  }\n-  return this._write(message, callback);\n+  var request = Request.buildSubscribe(scope);\n+  callback = _callbackOptionsSet(request, options, callback);","path":"lib/radar_client.js","position":107,"original_position":107,"commit_id":"5b7bd52399f740329278a6dc14a389a1b92a6204","original_commit_id":"5b7bd52399f740329278a6dc14a389a1b92a6204","user":{"login":"vanchi-zendesk","id":1341591,"avatar_url":"https://avatars.githubusercontent.com/u/1341591?v=3","gravatar_id":"","url":"https://api.github.com/users/vanchi-zendesk","html_url":"https://github.com/vanchi-zendesk","followers_url":"https://api.github.com/users/vanchi-zendesk/followers","following_url":"https://api.github.com/users/vanchi-zendesk/following{/other_user}","gists_url":"https://api.github.com/users/vanchi-zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/vanchi-zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanchi-zendesk/subscriptions","organizations_url":"https://api.github.com/users/vanchi-zendesk/orgs","repos_url":"https://api.github.com/users/vanchi-zendesk/repos","events_url":"https://api.github.com/users/vanchi-zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/vanchi-zendesk/received_events","type":"User","site_admin":false},"body":"The point here is, request.js and response.js become a common package. These options concerns should not be repeated in the api client.","created_at":"2015-08-26T22:48:44Z","updated_at":"2015-08-26T22:48:44Z","html_url":"https://github.com/zendesk/radar_client/pull/55#discussion_r38044807","pull_request_url":"https://api.github.com/repos/zendesk/radar_client/pulls/55","_links":{"self":{"href":"https://api.github.com/repos/zendesk/radar_client/pulls/comments/38044807"},"html":{"href":"https://github.com/zendesk/radar_client/pull/55#discussion_r38044807"},"pull_request":{"href":"https://api.github.com/repos/zendesk/radar_client/pulls/55"}}},"pull_request":{"url":"https://api.github.com/repos/zendesk/radar_client/pulls/55","id":41931951,"html_url":"https://github.com/zendesk/radar_client/pull/55","diff_url":"https://github.com/zendesk/radar_client/pull/55.diff","patch_url":"https://github.com/zendesk/radar_client/pull/55.patch","issue_url":"https://api.github.com/repos/zendesk/radar_client/issues/55","number":55,"state":"open","locked":false,"title":"Pobrien/feature message protocol v2 branch1","user":{"login":"bolddane","id":5687737,"avatar_url":"https://avatars.githubusercontent.com/u/5687737?v=3","gravatar_id":"","url":"https://api.github.com/users/bolddane","html_url":"https://github.com/bolddane","followers_url":"https://api.github.com/users/bolddane/followers","following_url":"https://api.github.com/users/bolddane/following{/other_user}","gists_url":"https://api.github.com/users/bolddane/gists{/gist_id}","starred_url":"https://api.github.com/users/bolddane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bolddane/subscriptions","organizations_url":"https://api.github.com/users/bolddane/orgs","repos_url":"https://api.github.com/users/bolddane/repos","events_url":"https://api.github.com/users/bolddane/events{/privacy}","received_events_url":"https://api.github.com/users/bolddane/received_events","type":"User","site_admin":false},"body":"Second version of the message library, used by radar_client. Refactor lib/radar_client.js to write separate, explicit get and sync functions. Identify request (aka client) and response (aka server) messages, and associated message lib API calls (now with some  server response messages.)\r\n\r\nThe PRs https://github.com/zendesk/radar_client/pull/51 and https://github.com/zendesk/radar_client/pull/52 are now closed. This implementation is the same as that in PR https://github.com/zendesk/radar_client/pull/52, with this *sole difference* - it is committed to a branch off the feature branch *pobrien/feature_message_protocol_v2*.  The feature branch will later be merged to master.\r\n\r\nThe majority of this code manipulates request/response objects, and not raw messages.  Raw messages still exist in the public APIs (cannot change these), callbacks, and messages handlers from radar server.  Tests have been modified to use request/response where needed.\r\n\r\nKnown limitations: zendesk_radar_client and its tests access some radar_client properties directly, and so some tests there are currently breaking.\r\n\r\n/cc @zendesk/zendesk-radar\r\n\r\n### Steps to merge\r\n - [ ] :+1: of the team\r\n\r\n### References\r\n - Jira link:  https://zendesk.atlassian.net/browse/RADAR-481\r\n\r\n### Risks\r\n - Medium to High: all existing client messages are now provided by the library, so a lot of logic has changed.","created_at":"2015-08-07T20:49:26Z","updated_at":"2015-08-26T22:48:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bc7ec31b99406339bba451fefaf4ea54d077551a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zendesk/radar_client/pulls/55/commits","review_comments_url":"https://api.github.com/repos/zendesk/radar_client/pulls/55/comments","review_comment_url":"https://api.github.com/repos/zendesk/radar_client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zendesk/radar_client/issues/55/comments","statuses_url":"https://api.github.com/repos/zendesk/radar_client/statuses/5b7bd52399f740329278a6dc14a389a1b92a6204","head":{"label":"zendesk:pobrien/feature_message_protocol_v2_branch1","ref":"pobrien/feature_message_protocol_v2_branch1","sha":"5b7bd52399f740329278a6dc14a389a1b92a6204","user":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":6050825,"name":"radar_client","full_name":"zendesk/radar_client","owner":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/radar_client","description":"High level API and backend for writing web apps that use push messaging ","fork":false,"url":"https://api.github.com/repos/zendesk/radar_client","forks_url":"https://api.github.com/repos/zendesk/radar_client/forks","keys_url":"https://api.github.com/repos/zendesk/radar_client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/radar_client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/radar_client/teams","hooks_url":"https://api.github.com/repos/zendesk/radar_client/hooks","issue_events_url":"https://api.github.com/repos/zendesk/radar_client/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/radar_client/events","assignees_url":"https://api.github.com/repos/zendesk/radar_client/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/radar_client/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/radar_client/tags","blobs_url":"https://api.github.com/repos/zendesk/radar_client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/radar_client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/radar_client/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/radar_client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/radar_client/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/radar_client/languages","stargazers_url":"https://api.github.com/repos/zendesk/radar_client/stargazers","contributors_url":"https://api.github.com/repos/zendesk/radar_client/contributors","subscribers_url":"https://api.github.com/repos/zendesk/radar_client/subscribers","subscription_url":"https://api.github.com/repos/zendesk/radar_client/subscription","commits_url":"https://api.github.com/repos/zendesk/radar_client/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/radar_client/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/radar_client/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/radar_client/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/radar_client/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/radar_client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/radar_client/merges","archive_url":"https://api.github.com/repos/zendesk/radar_client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/radar_client/downloads","issues_url":"https://api.github.com/repos/zendesk/radar_client/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/radar_client/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/radar_client/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/radar_client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/radar_client/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/radar_client/releases{/id}","created_at":"2012-10-02T20:16:42Z","updated_at":"2015-06-20T18:35:03Z","pushed_at":"2015-08-25T22:44:19Z","git_url":"git://github.com/zendesk/radar_client.git","ssh_url":"git@github.com:zendesk/radar_client.git","clone_url":"https://github.com/zendesk/radar_client.git","svn_url":"https://github.com/zendesk/radar_client","homepage":"http://radar.zendesk.com","size":1311,"stargazers_count":10,"watchers_count":10,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":3,"forks":8,"open_issues":3,"watchers":10,"default_branch":"master"}},"base":{"label":"zendesk:master","ref":"master","sha":"d729bc13f4d257dfbe0142efc13b3a13dc522a72","user":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":6050825,"name":"radar_client","full_name":"zendesk/radar_client","owner":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/radar_client","description":"High level API and backend for writing web apps that use push messaging ","fork":false,"url":"https://api.github.com/repos/zendesk/radar_client","forks_url":"https://api.github.com/repos/zendesk/radar_client/forks","keys_url":"https://api.github.com/repos/zendesk/radar_client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/radar_client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/radar_client/teams","hooks_url":"https://api.github.com/repos/zendesk/radar_client/hooks","issue_events_url":"https://api.github.com/repos/zendesk/radar_client/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/radar_client/events","assignees_url":"https://api.github.com/repos/zendesk/radar_client/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/radar_client/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/radar_client/tags","blobs_url":"https://api.github.com/repos/zendesk/radar_client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/radar_client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/radar_client/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/radar_client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/radar_client/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/radar_client/languages","stargazers_url":"https://api.github.com/repos/zendesk/radar_client/stargazers","contributors_url":"https://api.github.com/repos/zendesk/radar_client/contributors","subscribers_url":"https://api.github.com/repos/zendesk/radar_client/subscribers","subscription_url":"https://api.github.com/repos/zendesk/radar_client/subscription","commits_url":"https://api.github.com/repos/zendesk/radar_client/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/radar_client/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/radar_client/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/radar_client/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/radar_client/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/radar_client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/radar_client/merges","archive_url":"https://api.github.com/repos/zendesk/radar_client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/radar_client/downloads","issues_url":"https://api.github.com/repos/zendesk/radar_client/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/radar_client/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/radar_client/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/radar_client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/radar_client/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/radar_client/releases{/id}","created_at":"2012-10-02T20:16:42Z","updated_at":"2015-06-20T18:35:03Z","pushed_at":"2015-08-25T22:44:19Z","git_url":"git://github.com/zendesk/radar_client.git","ssh_url":"git@github.com:zendesk/radar_client.git","clone_url":"https://github.com/zendesk/radar_client.git","svn_url":"https://github.com/zendesk/radar_client","homepage":"http://radar.zendesk.com","size":1311,"stargazers_count":10,"watchers_count":10,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":3,"forks":8,"open_issues":3,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zendesk/radar_client/pulls/55"},"html":{"href":"https://github.com/zendesk/radar_client/pull/55"},"issue":{"href":"https://api.github.com/repos/zendesk/radar_client/issues/55"},"comments":{"href":"https://api.github.com/repos/zendesk/radar_client/issues/55/comments"},"review_comments":{"href":"https://api.github.com/repos/zendesk/radar_client/pulls/55/comments"},"review_comment":{"href":"https://api.github.com/repos/zendesk/radar_client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zendesk/radar_client/pulls/55/commits"},"statuses":{"href":"https://api.github.com/repos/zendesk/radar_client/statuses/5b7bd52399f740329278a6dc14a389a1b92a6204"}}}}