{"action":"created","comment":{"url":"https://api.github.com/repos/zendesk/radar_client/pulls/comments/36482194","id":36482194,"diff_hunk":"@@ -156,235 +393,200 @@ Client.prototype.currentClientId = function() {\n   return this._socket && this._socket.id;\n };\n \n+// Return the chainable scope object for a given message type\n+\n Client.prototype.message = function(scope) {\n-  return new Scope('message:/'+this._configuration.accountName+'/'+scope, this);\n+  return new Scope('message', scope, this);\n };\n \n-// Access the \"presence\" chainable operations\n Client.prototype.presence = function(scope) {\n-  return new Scope('presence:/'+this._configuration.accountName+'/'+scope, this);\n+  return new Scope('presence', scope, this);\n };\n \n-// Access the \"status\" chainable operations\n Client.prototype.status = function(scope) {\n-  return new Scope('status:/'+this._configuration.accountName+'/'+scope, this);\n+  return new Scope('status', scope, this);\n };\n \n Client.prototype.stream = function(scope) {\n-  return new Scope('stream:/'+this._configuration.accountName+'/'+scope, this);\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:/'+this._configuration.accountName+'/'+scope, this);\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-  if (typeof(clientData) === 'function') {\n-    callback = clientData;\n-  } else {\n-    message.clientData = clientData;\n-  }\n-\n-  return this._write(message, callback);\n+  callback = callbackSet(callback, clientData);\n+  var request = Request.buildSet(scope, value, clientData,\n+                  this._configuration.userId, this._configuration.userType);\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+  callback = callbackSet(callback, options);\n+  var request = Request.buildSubscribe(scope, options);\n+  return this._write(request, callback);\n };\n \n Client.prototype.unsubscribe = function(scope, callback) {\n-  return this._write({ op: 'unsubscribe', to: scope }, callback);\n+  var request = Request.buildUnsubscribe(scope);\n+  return this._write(request, callback);\n };\n \n-// Sync and get return the actual value of the operation\n-var init = function(propertyName) {\n-  Client.prototype[propertyName] = function(scope, options, callback) {\n-    var message = { op: propertyName, to: scope };\n-    // options is an optional argument\n-    if (typeof options == 'function') {\n-      callback = options;\n-    } else {\n-      message.options = options;\n-    }\n-    // Sync v1 for presence scopes acts inconsistently. The result should be a\n-    // \"get\" message, but it is actually a \"online\" message.\n-    // So force v2 and translate the result to v1 format.\n-    if (propertyName == 'sync' && !message.options && scope.match(/^presence.+/)) {\n-      message.options = { version: 2 };","path":"dist/radar_client.js","position":378,"original_position":378,"commit_id":"eb131cc96ec695b24843e3c9a934d57e90cd6b01","original_commit_id":"eb131cc96ec695b24843e3c9a934d57e90cd6b01","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 fact that we are getting tests to pass here is scary. Let's not merge until we have server tests passing. (Since integration tests are on radar repo)","created_at":"2015-08-07T00:38:34Z","updated_at":"2015-08-07T00:38:34Z","html_url":"https://github.com/zendesk/radar_client/pull/53#discussion_r36482194","pull_request_url":"https://api.github.com/repos/zendesk/radar_client/pulls/53","_links":{"self":{"href":"https://api.github.com/repos/zendesk/radar_client/pulls/comments/36482194"},"html":{"href":"https://github.com/zendesk/radar_client/pull/53#discussion_r36482194"},"pull_request":{"href":"https://api.github.com/repos/zendesk/radar_client/pulls/53"}}},"pull_request":{"url":"https://api.github.com/repos/zendesk/radar_client/pulls/53","id":41265998,"html_url":"https://github.com/zendesk/radar_client/pull/53","diff_url":"https://github.com/zendesk/radar_client/pull/53.diff","patch_url":"https://github.com/zendesk/radar_client/pull/53.patch","issue_url":"https://api.github.com/repos/zendesk/radar_client/issues/53","number":53,"state":"open","locked":false,"title":"Copy code changes from PR 52 to this branch off the feature branch","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-07-30T18:28:20Z","updated_at":"2015-08-07T00:38:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b051cc2d708ad13f35b9c243accc974c75ff52dd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zendesk/radar_client/pulls/53/commits","review_comments_url":"https://api.github.com/repos/zendesk/radar_client/pulls/53/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/53/comments","statuses_url":"https://api.github.com/repos/zendesk/radar_client/statuses/eb131cc96ec695b24843e3c9a934d57e90cd6b01","head":{"label":"zendesk:pobrien/feature_message_protocol_v2_branch1","ref":"pobrien/feature_message_protocol_v2_branch1","sha":"eb131cc96ec695b24843e3c9a934d57e90cd6b01","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-04T16:20:26Z","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":1269,"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":2,"forks":8,"open_issues":2,"watchers":10,"default_branch":"master"}},"base":{"label":"zendesk:pobrien/feature_message_protocol_v2","ref":"pobrien/feature_message_protocol_v2","sha":"f21477f94cf8256ef917cbebc23e292cf10245fb","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-04T16:20:26Z","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":1269,"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":2,"forks":8,"open_issues":2,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zendesk/radar_client/pulls/53"},"html":{"href":"https://github.com/zendesk/radar_client/pull/53"},"issue":{"href":"https://api.github.com/repos/zendesk/radar_client/issues/53"},"comments":{"href":"https://api.github.com/repos/zendesk/radar_client/issues/53/comments"},"review_comments":{"href":"https://api.github.com/repos/zendesk/radar_client/pulls/53/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/53/commits"},"statuses":{"href":"https://api.github.com/repos/zendesk/radar_client/statuses/eb131cc96ec695b24843e3c9a934d57e90cd6b01"}}}}