{"action":"created","comment":{"url":"https://api.github.com/repos/openstax/exchange-ruby/pulls/comments/22798933","id":22798933,"diff_hunk":"@@ -0,0 +1,67 @@\n+module OpenStax\n+  module Exchange\n+    module Client\n+\n+      @use_real_client = true\n+\n+      def self.configure\n+        yield configuration\n+      end\n+\n+      def self.configuration\n+        @configuration ||= ClientConfiguration.new\n+      end\n+\n+      def self.reset!\n+        @client = nil\n+      end\n+\n+      def self.use_real_client\n+        @use_real_client = true\n+      end\n+\n+      def self.use_fake_client\n+        @use_real_client = false\n+      end\n+\n+      def self.use_real_client?\n+        !!@use_real_client\n+      end\n+\n+      def self.create_identifier\n+        begin\n+          client.create_identifier\n+        rescue StandardError => error\n+          raise ClientError.new(\"create_identifier failure\", error)\n+        end\n+      end\n+\n+      def self.create_multiple_choice(*args)\n+        begin\n+          client.create_multiple_choice(*args)\n+        rescue StandardError => error","path":"lib/openstax/exchange/client/client.rb","position":42,"original_position":42,"commit_id":"e587799afcaaf2c62e24f26ac267a7878b97516d","original_commit_id":"e587799afcaaf2c62e24f26ac267a7878b97516d","user":{"login":"jpslav","id":1001691,"avatar_url":"https://avatars.githubusercontent.com/u/1001691?v=3","gravatar_id":"","url":"https://api.github.com/users/jpslav","html_url":"https://github.com/jpslav","followers_url":"https://api.github.com/users/jpslav/followers","following_url":"https://api.github.com/users/jpslav/following{/other_user}","gists_url":"https://api.github.com/users/jpslav/gists{/gist_id}","starred_url":"https://api.github.com/users/jpslav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpslav/subscriptions","organizations_url":"https://api.github.com/users/jpslav/orgs","repos_url":"https://api.github.com/users/jpslav/repos","events_url":"https://api.github.com/users/jpslav/events{/privacy}","received_events_url":"https://api.github.com/users/jpslav/received_events","type":"User","site_admin":false},"body":"Since there are going to be like 30 of these calls can we do:\r\n\r\n```\r\ndef self.create_multiple_choice(arg1, arg2)\r\n  delegate_to_client(:create_multiple_choice, arg1, arg2)\r\nend\r\n\r\ndef delegate_to_client(method, *args)\r\n  begin\r\n    client.send(method, args)\r\n  rescue StandardError => error\r\n    raise ClientError.new(\"#{method.to_s} failure\", error)\r\n  end\r\nend\r\n```\r\n\r\neliminates copying the boilerplate begin rescue end all over the place.","created_at":"2015-01-12T15:58:11Z","updated_at":"2015-01-12T15:58:11Z","html_url":"https://github.com/openstax/exchange-ruby/pull/8#discussion_r22798933","pull_request_url":"https://api.github.com/repos/openstax/exchange-ruby/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/openstax/exchange-ruby/pulls/comments/22798933"},"html":{"href":"https://github.com/openstax/exchange-ruby/pull/8#discussion_r22798933"},"pull_request":{"href":"https://api.github.com/repos/openstax/exchange-ruby/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/openstax/exchange-ruby/pulls/8","id":27174403,"html_url":"https://github.com/openstax/exchange-ruby/pull/8","diff_url":"https://github.com/openstax/exchange-ruby/pull/8.diff","patch_url":"https://github.com/openstax/exchange-ruby/pull/8.patch","issue_url":"https://api.github.com/repos/openstax/exchange-ruby/issues/8","number":8,"state":"open","locked":false,"title":"exchange-ruby client: #create_identifier and #create_multiple_choice - WIP","user":{"login":"kevinburleigh75","id":1851667,"avatar_url":"https://avatars.githubusercontent.com/u/1851667?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinburleigh75","html_url":"https://github.com/kevinburleigh75","followers_url":"https://api.github.com/users/kevinburleigh75/followers","following_url":"https://api.github.com/users/kevinburleigh75/following{/other_user}","gists_url":"https://api.github.com/users/kevinburleigh75/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinburleigh75/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinburleigh75/subscriptions","organizations_url":"https://api.github.com/users/kevinburleigh75/orgs","repos_url":"https://api.github.com/users/kevinburleigh75/repos","events_url":"https://api.github.com/users/kevinburleigh75/events{/privacy}","received_events_url":"https://api.github.com/users/kevinburleigh75/received_events","type":"User","site_admin":false},"body":"This PR includes a client interface to Exchange which can be configured to use a real Exchange server (for integration tests) or to use a fake in-memory server (for unit tests). Support for the vcr gem is included, so there is no requirement to have an actual server running for the tests to pass.\r\n\r\nCurrently, the only supported client methods are `#create_identifier` and `#create_multiple_choice`. Others will need to be added as the APIs stabilize.\r\n\r\n@jpslav @Dantemss","created_at":"2015-01-12T04:10:42Z","updated_at":"2015-01-12T15:58:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cf89bbbdb4819bbd389f160512ee3fac4468f869","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openstax/exchange-ruby/pulls/8/commits","review_comments_url":"https://api.github.com/repos/openstax/exchange-ruby/pulls/8/comments","review_comment_url":"https://api.github.com/repos/openstax/exchange-ruby/pulls/comments/{number}","comments_url":"https://api.github.com/repos/openstax/exchange-ruby/issues/8/comments","statuses_url":"https://api.github.com/repos/openstax/exchange-ruby/statuses/e587799afcaaf2c62e24f26ac267a7878b97516d","head":{"label":"openstax:klb_sprint5","ref":"klb_sprint5","sha":"e587799afcaaf2c62e24f26ac267a7878b97516d","user":{"login":"openstax","id":3805549,"avatar_url":"https://avatars.githubusercontent.com/u/3805549?v=3","gravatar_id":"","url":"https://api.github.com/users/openstax","html_url":"https://github.com/openstax","followers_url":"https://api.github.com/users/openstax/followers","following_url":"https://api.github.com/users/openstax/following{/other_user}","gists_url":"https://api.github.com/users/openstax/gists{/gist_id}","starred_url":"https://api.github.com/users/openstax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstax/subscriptions","organizations_url":"https://api.github.com/users/openstax/orgs","repos_url":"https://api.github.com/users/openstax/repos","events_url":"https://api.github.com/users/openstax/events{/privacy}","received_events_url":"https://api.github.com/users/openstax/received_events","type":"Organization","site_admin":false},"repo":{"id":22080543,"name":"exchange-ruby","full_name":"openstax/exchange-ruby","owner":{"login":"openstax","id":3805549,"avatar_url":"https://avatars.githubusercontent.com/u/3805549?v=3","gravatar_id":"","url":"https://api.github.com/users/openstax","html_url":"https://github.com/openstax","followers_url":"https://api.github.com/users/openstax/followers","following_url":"https://api.github.com/users/openstax/following{/other_user}","gists_url":"https://api.github.com/users/openstax/gists{/gist_id}","starred_url":"https://api.github.com/users/openstax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstax/subscriptions","organizations_url":"https://api.github.com/users/openstax/orgs","repos_url":"https://api.github.com/users/openstax/repos","events_url":"https://api.github.com/users/openstax/events{/privacy}","received_events_url":"https://api.github.com/users/openstax/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openstax/exchange-ruby","description":"Ruby client for Exchange API","fork":false,"url":"https://api.github.com/repos/openstax/exchange-ruby","forks_url":"https://api.github.com/repos/openstax/exchange-ruby/forks","keys_url":"https://api.github.com/repos/openstax/exchange-ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openstax/exchange-ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openstax/exchange-ruby/teams","hooks_url":"https://api.github.com/repos/openstax/exchange-ruby/hooks","issue_events_url":"https://api.github.com/repos/openstax/exchange-ruby/issues/events{/number}","events_url":"https://api.github.com/repos/openstax/exchange-ruby/events","assignees_url":"https://api.github.com/repos/openstax/exchange-ruby/assignees{/user}","branches_url":"https://api.github.com/repos/openstax/exchange-ruby/branches{/branch}","tags_url":"https://api.github.com/repos/openstax/exchange-ruby/tags","blobs_url":"https://api.github.com/repos/openstax/exchange-ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openstax/exchange-ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openstax/exchange-ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/openstax/exchange-ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openstax/exchange-ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/openstax/exchange-ruby/languages","stargazers_url":"https://api.github.com/repos/openstax/exchange-ruby/stargazers","contributors_url":"https://api.github.com/repos/openstax/exchange-ruby/contributors","subscribers_url":"https://api.github.com/repos/openstax/exchange-ruby/subscribers","subscription_url":"https://api.github.com/repos/openstax/exchange-ruby/subscription","commits_url":"https://api.github.com/repos/openstax/exchange-ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/openstax/exchange-ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/openstax/exchange-ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/openstax/exchange-ruby/issues/comments/{number}","contents_url":"https://api.github.com/repos/openstax/exchange-ruby/contents/{+path}","compare_url":"https://api.github.com/repos/openstax/exchange-ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openstax/exchange-ruby/merges","archive_url":"https://api.github.com/repos/openstax/exchange-ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openstax/exchange-ruby/downloads","issues_url":"https://api.github.com/repos/openstax/exchange-ruby/issues{/number}","pulls_url":"https://api.github.com/repos/openstax/exchange-ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/openstax/exchange-ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/openstax/exchange-ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openstax/exchange-ruby/labels{/name}","releases_url":"https://api.github.com/repos/openstax/exchange-ruby/releases{/id}","created_at":"2014-07-21T21:16:34Z","updated_at":"2014-12-11T19:34:32Z","pushed_at":"2015-01-12T05:00:19Z","git_url":"git://github.com/openstax/exchange-ruby.git","ssh_url":"git@github.com:openstax/exchange-ruby.git","clone_url":"https://github.com/openstax/exchange-ruby.git","svn_url":"https://github.com/openstax/exchange-ruby","homepage":null,"size":204,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"openstax:master","ref":"master","sha":"bd4f80320e697e67a68901ba2e746ecce1caa3c1","user":{"login":"openstax","id":3805549,"avatar_url":"https://avatars.githubusercontent.com/u/3805549?v=3","gravatar_id":"","url":"https://api.github.com/users/openstax","html_url":"https://github.com/openstax","followers_url":"https://api.github.com/users/openstax/followers","following_url":"https://api.github.com/users/openstax/following{/other_user}","gists_url":"https://api.github.com/users/openstax/gists{/gist_id}","starred_url":"https://api.github.com/users/openstax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstax/subscriptions","organizations_url":"https://api.github.com/users/openstax/orgs","repos_url":"https://api.github.com/users/openstax/repos","events_url":"https://api.github.com/users/openstax/events{/privacy}","received_events_url":"https://api.github.com/users/openstax/received_events","type":"Organization","site_admin":false},"repo":{"id":22080543,"name":"exchange-ruby","full_name":"openstax/exchange-ruby","owner":{"login":"openstax","id":3805549,"avatar_url":"https://avatars.githubusercontent.com/u/3805549?v=3","gravatar_id":"","url":"https://api.github.com/users/openstax","html_url":"https://github.com/openstax","followers_url":"https://api.github.com/users/openstax/followers","following_url":"https://api.github.com/users/openstax/following{/other_user}","gists_url":"https://api.github.com/users/openstax/gists{/gist_id}","starred_url":"https://api.github.com/users/openstax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstax/subscriptions","organizations_url":"https://api.github.com/users/openstax/orgs","repos_url":"https://api.github.com/users/openstax/repos","events_url":"https://api.github.com/users/openstax/events{/privacy}","received_events_url":"https://api.github.com/users/openstax/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openstax/exchange-ruby","description":"Ruby client for Exchange API","fork":false,"url":"https://api.github.com/repos/openstax/exchange-ruby","forks_url":"https://api.github.com/repos/openstax/exchange-ruby/forks","keys_url":"https://api.github.com/repos/openstax/exchange-ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openstax/exchange-ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openstax/exchange-ruby/teams","hooks_url":"https://api.github.com/repos/openstax/exchange-ruby/hooks","issue_events_url":"https://api.github.com/repos/openstax/exchange-ruby/issues/events{/number}","events_url":"https://api.github.com/repos/openstax/exchange-ruby/events","assignees_url":"https://api.github.com/repos/openstax/exchange-ruby/assignees{/user}","branches_url":"https://api.github.com/repos/openstax/exchange-ruby/branches{/branch}","tags_url":"https://api.github.com/repos/openstax/exchange-ruby/tags","blobs_url":"https://api.github.com/repos/openstax/exchange-ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openstax/exchange-ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openstax/exchange-ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/openstax/exchange-ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openstax/exchange-ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/openstax/exchange-ruby/languages","stargazers_url":"https://api.github.com/repos/openstax/exchange-ruby/stargazers","contributors_url":"https://api.github.com/repos/openstax/exchange-ruby/contributors","subscribers_url":"https://api.github.com/repos/openstax/exchange-ruby/subscribers","subscription_url":"https://api.github.com/repos/openstax/exchange-ruby/subscription","commits_url":"https://api.github.com/repos/openstax/exchange-ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/openstax/exchange-ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/openstax/exchange-ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/openstax/exchange-ruby/issues/comments/{number}","contents_url":"https://api.github.com/repos/openstax/exchange-ruby/contents/{+path}","compare_url":"https://api.github.com/repos/openstax/exchange-ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openstax/exchange-ruby/merges","archive_url":"https://api.github.com/repos/openstax/exchange-ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openstax/exchange-ruby/downloads","issues_url":"https://api.github.com/repos/openstax/exchange-ruby/issues{/number}","pulls_url":"https://api.github.com/repos/openstax/exchange-ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/openstax/exchange-ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/openstax/exchange-ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openstax/exchange-ruby/labels{/name}","releases_url":"https://api.github.com/repos/openstax/exchange-ruby/releases{/id}","created_at":"2014-07-21T21:16:34Z","updated_at":"2014-12-11T19:34:32Z","pushed_at":"2015-01-12T05:00:19Z","git_url":"git://github.com/openstax/exchange-ruby.git","ssh_url":"git@github.com:openstax/exchange-ruby.git","clone_url":"https://github.com/openstax/exchange-ruby.git","svn_url":"https://github.com/openstax/exchange-ruby","homepage":null,"size":204,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openstax/exchange-ruby/pulls/8"},"html":{"href":"https://github.com/openstax/exchange-ruby/pull/8"},"issue":{"href":"https://api.github.com/repos/openstax/exchange-ruby/issues/8"},"comments":{"href":"https://api.github.com/repos/openstax/exchange-ruby/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/openstax/exchange-ruby/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/openstax/exchange-ruby/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/openstax/exchange-ruby/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/openstax/exchange-ruby/statuses/e587799afcaaf2c62e24f26ac267a7878b97516d"}}}}