{"action":"created","comment":{"url":"https://api.github.com/repos/gabebw/fake_braintree/pulls/comments/29372402","id":29372402,"diff_hunk":"@@ -0,0 +1,98 @@\n+module FakeBraintree\n+  class MerchantAccount\n+    include Helpers\n+\n+    def initialize(merchant_account_hash_from_params, options)\n+      @merchant_account_hash = {\n+        'id' => options[:id]\n+      }\n+      @merchant_account_hash.merge!(merchant_account_hash_from_params)\n+      set_merchant_account_id\n+    end\n+\n+    def create\n+      if invalid?\n+        response_for_invalid_merchant_account\n+      else\n+        # credit_cards = customer_hash['credit_cards']\n+        create_merchant_account_with(merchant_account_hash)\n+        # credit_cards.each { |card| add_credit_card_to_registry(card) }\n+        # set_default_credit_card credit_cards.first\n+        response_for_created_merchant_account(merchant_account_hash)\n+      end\n+    end\n+\n+    def update\n+      if merchant_account_exists_in_registry?\n+        updates = merchant_account_hash\n+        updated_merchant_account = update_existing_merchant_account(updates)\n+        response_for_updated_merchant_account(updated_merchant_account)\n+      else\n+        response_for_merchant_account_not_found\n+      end\n+    end\n+\n+    def delete\n+      delete_merchant_account_with_id(merchant_account_id)\n+      deletion_response\n+    end\n+\n+    private\n+\n+    def invalid?\n+      false\n+    end\n+\n+    def create_merchant_account_with(hash)\n+      FakeBraintree.registry.merchant_accounts[hash['id'].to_s] = hash\n+    end\n+\n+    def update_existing_merchant_account(updates_hash)\n+      merchant_account_from_registry.merge!(updates_hash)\n+    end\n+\n+    def merchant_account_hash\n+      @merchant_account_hash\n+    end\n+\n+    def merchant_account_from_registry\n+      FakeBraintree.registry.merchant_accounts[merchant_account_id]\n+    end\n+\n+    def merchant_account_exists_in_registry?\n+      FakeBraintree.registry.merchant_accounts.key?(merchant_account_id)\n+    end\n+\n+    def delete_merchant_account_with_id(id)\n+      FakeBraintree.registry.merchant_accounts[id] = nil\n+    end\n+\n+    def deletion_response\n+      gzipped_response(200, '')\n+    end\n+\n+    def response_for_created_merchant_account(hash)\n+      gzipped_response(201, hash.to_xml(root: 'merchant_account'))\n+    end\n+\n+    def response_for_updated_merchant_account(hash)\n+      gzipped_response(200, hash.to_xml(root: 'merchant_account'))\n+    end\n+\n+    def response_for_merchant_account_not_found\n+      failure_response(404)\n+    end\n+\n+    def failure_response(code)\n+      gzipped_response(code, '')","path":"lib/fake_braintree/merchant_account.rb","position":87,"original_position":87,"commit_id":"3f0e15cf54d4df1ad9a81187c4f7d7c37697335c","original_commit_id":"3f0e15cf54d4df1ad9a81187c4f7d7c37697335c","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.","created_at":"2015-04-29T19:39:13Z","updated_at":"2015-04-29T19:39:13Z","html_url":"https://github.com/gabebw/fake_braintree/pull/92#discussion_r29372402","pull_request_url":"https://api.github.com/repos/gabebw/fake_braintree/pulls/92","_links":{"self":{"href":"https://api.github.com/repos/gabebw/fake_braintree/pulls/comments/29372402"},"html":{"href":"https://github.com/gabebw/fake_braintree/pull/92#discussion_r29372402"},"pull_request":{"href":"https://api.github.com/repos/gabebw/fake_braintree/pulls/92"}}},"pull_request":{"url":"https://api.github.com/repos/gabebw/fake_braintree/pulls/92","id":34398129,"html_url":"https://github.com/gabebw/fake_braintree/pull/92","diff_url":"https://github.com/gabebw/fake_braintree/pull/92.diff","patch_url":"https://github.com/gabebw/fake_braintree/pull/92.patch","issue_url":"https://api.github.com/repos/gabebw/fake_braintree/issues/92","number":92,"state":"open","locked":false,"title":"Merchant Account, ClientToken and JS card tokenization support","user":{"login":"twalpole","id":16556,"avatar_url":"https://avatars.githubusercontent.com/u/16556?v=3","gravatar_id":"","url":"https://api.github.com/users/twalpole","html_url":"https://github.com/twalpole","followers_url":"https://api.github.com/users/twalpole/followers","following_url":"https://api.github.com/users/twalpole/following{/other_user}","gists_url":"https://api.github.com/users/twalpole/gists{/gist_id}","starred_url":"https://api.github.com/users/twalpole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twalpole/subscriptions","organizations_url":"https://api.github.com/users/twalpole/orgs","repos_url":"https://api.github.com/users/twalpole/repos","events_url":"https://api.github.com/users/twalpole/events{/privacy}","received_events_url":"https://api.github.com/users/twalpole/received_events","type":"User","site_admin":false},"body":"This adds support for the MerchantAccounts API, ClientToken.generate, JS config, and JS card tokenization","created_at":"2015-04-29T19:39:05Z","updated_at":"2015-04-29T19:39:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"89759b615599890ac3542a563c1cdbf6942d8a1b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gabebw/fake_braintree/pulls/92/commits","review_comments_url":"https://api.github.com/repos/gabebw/fake_braintree/pulls/92/comments","review_comment_url":"https://api.github.com/repos/gabebw/fake_braintree/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gabebw/fake_braintree/issues/92/comments","statuses_url":"https://api.github.com/repos/gabebw/fake_braintree/statuses/3f0e15cf54d4df1ad9a81187c4f7d7c37697335c","head":{"label":"twalpole:new_api","ref":"new_api","sha":"3f0e15cf54d4df1ad9a81187c4f7d7c37697335c","user":{"login":"twalpole","id":16556,"avatar_url":"https://avatars.githubusercontent.com/u/16556?v=3","gravatar_id":"","url":"https://api.github.com/users/twalpole","html_url":"https://github.com/twalpole","followers_url":"https://api.github.com/users/twalpole/followers","following_url":"https://api.github.com/users/twalpole/following{/other_user}","gists_url":"https://api.github.com/users/twalpole/gists{/gist_id}","starred_url":"https://api.github.com/users/twalpole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twalpole/subscriptions","organizations_url":"https://api.github.com/users/twalpole/orgs","repos_url":"https://api.github.com/users/twalpole/repos","events_url":"https://api.github.com/users/twalpole/events{/privacy}","received_events_url":"https://api.github.com/users/twalpole/received_events","type":"User","site_admin":false},"repo":{"id":26512403,"name":"fake_braintree","full_name":"twalpole/fake_braintree","owner":{"login":"twalpole","id":16556,"avatar_url":"https://avatars.githubusercontent.com/u/16556?v=3","gravatar_id":"","url":"https://api.github.com/users/twalpole","html_url":"https://github.com/twalpole","followers_url":"https://api.github.com/users/twalpole/followers","following_url":"https://api.github.com/users/twalpole/following{/other_user}","gists_url":"https://api.github.com/users/twalpole/gists{/gist_id}","starred_url":"https://api.github.com/users/twalpole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twalpole/subscriptions","organizations_url":"https://api.github.com/users/twalpole/orgs","repos_url":"https://api.github.com/users/twalpole/repos","events_url":"https://api.github.com/users/twalpole/events{/privacy}","received_events_url":"https://api.github.com/users/twalpole/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/twalpole/fake_braintree","description":"A Braintree fake so that you can avoid hitting Braintree servers in tests.","fork":true,"url":"https://api.github.com/repos/twalpole/fake_braintree","forks_url":"https://api.github.com/repos/twalpole/fake_braintree/forks","keys_url":"https://api.github.com/repos/twalpole/fake_braintree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twalpole/fake_braintree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twalpole/fake_braintree/teams","hooks_url":"https://api.github.com/repos/twalpole/fake_braintree/hooks","issue_events_url":"https://api.github.com/repos/twalpole/fake_braintree/issues/events{/number}","events_url":"https://api.github.com/repos/twalpole/fake_braintree/events","assignees_url":"https://api.github.com/repos/twalpole/fake_braintree/assignees{/user}","branches_url":"https://api.github.com/repos/twalpole/fake_braintree/branches{/branch}","tags_url":"https://api.github.com/repos/twalpole/fake_braintree/tags","blobs_url":"https://api.github.com/repos/twalpole/fake_braintree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twalpole/fake_braintree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twalpole/fake_braintree/git/refs{/sha}","trees_url":"https://api.github.com/repos/twalpole/fake_braintree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twalpole/fake_braintree/statuses/{sha}","languages_url":"https://api.github.com/repos/twalpole/fake_braintree/languages","stargazers_url":"https://api.github.com/repos/twalpole/fake_braintree/stargazers","contributors_url":"https://api.github.com/repos/twalpole/fake_braintree/contributors","subscribers_url":"https://api.github.com/repos/twalpole/fake_braintree/subscribers","subscription_url":"https://api.github.com/repos/twalpole/fake_braintree/subscription","commits_url":"https://api.github.com/repos/twalpole/fake_braintree/commits{/sha}","git_commits_url":"https://api.github.com/repos/twalpole/fake_braintree/git/commits{/sha}","comments_url":"https://api.github.com/repos/twalpole/fake_braintree/comments{/number}","issue_comment_url":"https://api.github.com/repos/twalpole/fake_braintree/issues/comments{/number}","contents_url":"https://api.github.com/repos/twalpole/fake_braintree/contents/{+path}","compare_url":"https://api.github.com/repos/twalpole/fake_braintree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twalpole/fake_braintree/merges","archive_url":"https://api.github.com/repos/twalpole/fake_braintree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twalpole/fake_braintree/downloads","issues_url":"https://api.github.com/repos/twalpole/fake_braintree/issues{/number}","pulls_url":"https://api.github.com/repos/twalpole/fake_braintree/pulls{/number}","milestones_url":"https://api.github.com/repos/twalpole/fake_braintree/milestones{/number}","notifications_url":"https://api.github.com/repos/twalpole/fake_braintree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twalpole/fake_braintree/labels{/name}","releases_url":"https://api.github.com/repos/twalpole/fake_braintree/releases{/id}","created_at":"2014-11-12T00:51:52Z","updated_at":"2015-04-28T20:11:49Z","pushed_at":"2015-04-29T19:35:07Z","git_url":"git://github.com/twalpole/fake_braintree.git","ssh_url":"git@github.com:twalpole/fake_braintree.git","clone_url":"https://github.com/twalpole/fake_braintree.git","svn_url":"https://github.com/twalpole/fake_braintree","homepage":"","size":439,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gabebw:master","ref":"master","sha":"e1deca1e64b3b700e8befb8fbf695392697d9aeb","user":{"login":"gabebw","id":257678,"avatar_url":"https://avatars.githubusercontent.com/u/257678?v=3","gravatar_id":"","url":"https://api.github.com/users/gabebw","html_url":"https://github.com/gabebw","followers_url":"https://api.github.com/users/gabebw/followers","following_url":"https://api.github.com/users/gabebw/following{/other_user}","gists_url":"https://api.github.com/users/gabebw/gists{/gist_id}","starred_url":"https://api.github.com/users/gabebw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabebw/subscriptions","organizations_url":"https://api.github.com/users/gabebw/orgs","repos_url":"https://api.github.com/users/gabebw/repos","events_url":"https://api.github.com/users/gabebw/events{/privacy}","received_events_url":"https://api.github.com/users/gabebw/received_events","type":"User","site_admin":false},"repo":{"id":2236094,"name":"fake_braintree","full_name":"gabebw/fake_braintree","owner":{"login":"gabebw","id":257678,"avatar_url":"https://avatars.githubusercontent.com/u/257678?v=3","gravatar_id":"","url":"https://api.github.com/users/gabebw","html_url":"https://github.com/gabebw","followers_url":"https://api.github.com/users/gabebw/followers","following_url":"https://api.github.com/users/gabebw/following{/other_user}","gists_url":"https://api.github.com/users/gabebw/gists{/gist_id}","starred_url":"https://api.github.com/users/gabebw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabebw/subscriptions","organizations_url":"https://api.github.com/users/gabebw/orgs","repos_url":"https://api.github.com/users/gabebw/repos","events_url":"https://api.github.com/users/gabebw/events{/privacy}","received_events_url":"https://api.github.com/users/gabebw/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gabebw/fake_braintree","description":"A Braintree fake so that you can avoid hitting Braintree servers in tests.","fork":false,"url":"https://api.github.com/repos/gabebw/fake_braintree","forks_url":"https://api.github.com/repos/gabebw/fake_braintree/forks","keys_url":"https://api.github.com/repos/gabebw/fake_braintree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gabebw/fake_braintree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gabebw/fake_braintree/teams","hooks_url":"https://api.github.com/repos/gabebw/fake_braintree/hooks","issue_events_url":"https://api.github.com/repos/gabebw/fake_braintree/issues/events{/number}","events_url":"https://api.github.com/repos/gabebw/fake_braintree/events","assignees_url":"https://api.github.com/repos/gabebw/fake_braintree/assignees{/user}","branches_url":"https://api.github.com/repos/gabebw/fake_braintree/branches{/branch}","tags_url":"https://api.github.com/repos/gabebw/fake_braintree/tags","blobs_url":"https://api.github.com/repos/gabebw/fake_braintree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gabebw/fake_braintree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gabebw/fake_braintree/git/refs{/sha}","trees_url":"https://api.github.com/repos/gabebw/fake_braintree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gabebw/fake_braintree/statuses/{sha}","languages_url":"https://api.github.com/repos/gabebw/fake_braintree/languages","stargazers_url":"https://api.github.com/repos/gabebw/fake_braintree/stargazers","contributors_url":"https://api.github.com/repos/gabebw/fake_braintree/contributors","subscribers_url":"https://api.github.com/repos/gabebw/fake_braintree/subscribers","subscription_url":"https://api.github.com/repos/gabebw/fake_braintree/subscription","commits_url":"https://api.github.com/repos/gabebw/fake_braintree/commits{/sha}","git_commits_url":"https://api.github.com/repos/gabebw/fake_braintree/git/commits{/sha}","comments_url":"https://api.github.com/repos/gabebw/fake_braintree/comments{/number}","issue_comment_url":"https://api.github.com/repos/gabebw/fake_braintree/issues/comments{/number}","contents_url":"https://api.github.com/repos/gabebw/fake_braintree/contents/{+path}","compare_url":"https://api.github.com/repos/gabebw/fake_braintree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gabebw/fake_braintree/merges","archive_url":"https://api.github.com/repos/gabebw/fake_braintree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gabebw/fake_braintree/downloads","issues_url":"https://api.github.com/repos/gabebw/fake_braintree/issues{/number}","pulls_url":"https://api.github.com/repos/gabebw/fake_braintree/pulls{/number}","milestones_url":"https://api.github.com/repos/gabebw/fake_braintree/milestones{/number}","notifications_url":"https://api.github.com/repos/gabebw/fake_braintree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gabebw/fake_braintree/labels{/name}","releases_url":"https://api.github.com/repos/gabebw/fake_braintree/releases{/id}","created_at":"2011-08-19T20:12:32Z","updated_at":"2015-04-29T14:01:16Z","pushed_at":"2015-04-29T19:39:06Z","git_url":"git://github.com/gabebw/fake_braintree.git","ssh_url":"git@github.com:gabebw/fake_braintree.git","clone_url":"https://github.com/gabebw/fake_braintree.git","svn_url":"https://github.com/gabebw/fake_braintree","homepage":"","size":1622,"stargazers_count":137,"watchers_count":137,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":63,"mirror_url":null,"open_issues_count":5,"forks":63,"open_issues":5,"watchers":137,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gabebw/fake_braintree/pulls/92"},"html":{"href":"https://github.com/gabebw/fake_braintree/pull/92"},"issue":{"href":"https://api.github.com/repos/gabebw/fake_braintree/issues/92"},"comments":{"href":"https://api.github.com/repos/gabebw/fake_braintree/issues/92/comments"},"review_comments":{"href":"https://api.github.com/repos/gabebw/fake_braintree/pulls/92/comments"},"review_comment":{"href":"https://api.github.com/repos/gabebw/fake_braintree/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gabebw/fake_braintree/pulls/92/commits"},"statuses":{"href":"https://api.github.com/repos/gabebw/fake_braintree/statuses/3f0e15cf54d4df1ad9a81187c4f7d7c37697335c"}}}}