{"action":"created","comment":{"url":"https://api.github.com/repos/bunq/sdk_java/pulls/comments/196308454","pull_request_review_id":129833538,"id":196308454,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NjMwODQ1NA==","diff_hunk":"@@ -15,57 +16,40 @@\n    * Error constants.\n    */\n   private static final String ERROR_UNEXPECTED_USER_INSTANCE = \"\\\"%s\\\" is unexpected user instance.\";\n-  private static final String ERROR_NO_ACTIVE_MONETARY_ACCOUNT_FOUND = \"No active monetary account found.\";\n-  private static final String ERROR_PRIMARY_MONETARY_ACCOUNT_IS_NOT_SET = \"Primary monetaryAccount is not set.\";\n-\n-  private static final String MONETARY_ACCOUNT_STATUS_ACTIVE = \"ACTIVE\";\n-  private static final int INDEX_FIRST = 0;\n+  private static final String ERROR_PRIMARY_MONETARY_ACCOUNT_IS_NOT_SET = \"Primary monetaryAccount is not set\";\n \n+  private final ApiContext apiContext;\n   private UserCompany userCompany;\n   private UserPerson userPerson;\n   private MonetaryAccountBank primaryMonetaryAccountBank;\n-  private Integer userId;\n-\n-  public UserContext(Integer userId) {\n-    this.setUser(this.getUserObject());\n-    this.userId = userId;\n-  }\n \n-  private BunqModel getUserObject() {\n-    return User.list().getValue().get(INDEX_FIRST).getReferencedObject();\n+  public UserContext(ApiContext apiContext) {\n+    this.apiContext = apiContext;\n+    refreshContext();\n   }\n \n-  private void setUser(BunqModel user) {\n-    if (user instanceof UserPerson) {\n-      this.userPerson = (UserPerson) user;\n-    } else if (user instanceof UserCompany) {\n-      this.userCompany = (UserCompany) user;\n+  private void initUser(User user) {\n+    if (user.getUserPerson() != null) {\n+      this.userPerson = user.getUserPerson();\n+    } else if (user.getUserCompany() != null) {\n+      this.userCompany = user.getUserCompany();\n     } else {\n       throw new BunqException(ERROR_UNEXPECTED_USER_INSTANCE);\n     }\n   }\n \n-  public void initMainMonetaryAccount() {\n-    List<MonetaryAccountBank> allMonetaryAccount =  MonetaryAccountBank.list().getValue();\n-\n-    for (MonetaryAccountBank monetaryAccountBank : allMonetaryAccount) {\n-      if (monetaryAccountBank.getStatus().equals(MONETARY_ACCOUNT_STATUS_ACTIVE)) {\n-        this.primaryMonetaryAccountBank = monetaryAccountBank;\n-\n-        return;\n-      }\n-    }\n-\n-    throw new BunqException(ERROR_NO_ACTIVE_MONETARY_ACCOUNT_FOUND);\n+  private void initMainMonetaryAccount(MonetaryAccountBank monetaryAccountBank) {","path":"src/main/java/com/bunq/sdk/context/UserContext.java","position":64,"original_position":64,"commit_id":"0bc198764cd527e97b1d42d7c23e53d32040fe17","original_commit_id":"cad108e1aa6b52480bd7943a7682ac60fad3b4a6","user":{"login":"OGKevin","id":17928966,"node_id":"MDQ6VXNlcjE3OTI4OTY2","avatar_url":"https://avatars3.githubusercontent.com/u/17928966?v=4","gravatar_id":"","url":"https://api.github.com/users/OGKevin","html_url":"https://github.com/OGKevin","followers_url":"https://api.github.com/users/OGKevin/followers","following_url":"https://api.github.com/users/OGKevin/following{/other_user}","gists_url":"https://api.github.com/users/OGKevin/gists{/gist_id}","starred_url":"https://api.github.com/users/OGKevin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OGKevin/subscriptions","organizations_url":"https://api.github.com/users/OGKevin/orgs","repos_url":"https://api.github.com/users/OGKevin/repos","events_url":"https://api.github.com/users/OGKevin/events{/privacy}","received_events_url":"https://api.github.com/users/OGKevin/received_events","type":"User","site_admin":false},"body":"This can be formatted to \r\n\r\n```\r\nprivate void initMainMonetaryAccount(\r\n   MonetaryAccountBank monetaryAccountBank\r\n) {\r\n```","created_at":"2018-06-19T06:38:12Z","updated_at":"2018-06-19T06:38:12Z","html_url":"https://github.com/bunq/sdk_java/pull/99#discussion_r196308454","pull_request_url":"https://api.github.com/repos/bunq/sdk_java/pulls/99","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/bunq/sdk_java/pulls/comments/196308454"},"html":{"href":"https://github.com/bunq/sdk_java/pull/99#discussion_r196308454"},"pull_request":{"href":"https://api.github.com/repos/bunq/sdk_java/pulls/99"}},"in_reply_to_id":196008277},"pull_request":{"url":"https://api.github.com/repos/bunq/sdk_java/pulls/99","id":195006805,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk1MDA2ODA1","html_url":"https://github.com/bunq/sdk_java/pull/99","diff_url":"https://github.com/bunq/sdk_java/pull/99.diff","patch_url":"https://github.com/bunq/sdk_java/pull/99.patch","issue_url":"https://api.github.com/repos/bunq/sdk_java/issues/99","number":99,"state":"open","locked":false,"title":"#93 UserContext building without static references, backwards compatible","user":{"login":"tubbynl","id":6532583,"node_id":"MDQ6VXNlcjY1MzI1ODM=","avatar_url":"https://avatars2.githubusercontent.com/u/6532583?v=4","gravatar_id":"","url":"https://api.github.com/users/tubbynl","html_url":"https://github.com/tubbynl","followers_url":"https://api.github.com/users/tubbynl/followers","following_url":"https://api.github.com/users/tubbynl/following{/other_user}","gists_url":"https://api.github.com/users/tubbynl/gists{/gist_id}","starred_url":"https://api.github.com/users/tubbynl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tubbynl/subscriptions","organizations_url":"https://api.github.com/users/tubbynl/orgs","repos_url":"https://api.github.com/users/tubbynl/repos","events_url":"https://api.github.com/users/tubbynl/events{/privacy}","received_events_url":"https://api.github.com/users/tubbynl/received_events","type":"User","site_admin":false},"body":"for prior art see #98\r\n\r\ni'm attempting some minor (non-breaking) changes to enable creation of the UserContext without referencing the static BunqContext ","created_at":"2018-06-14T20:20:44Z","updated_at":"2018-06-19T06:38:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e24571231ef50d419a7d82402ee8ac75d198d4bf","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/bunq/sdk_java/pulls/99/commits","review_comments_url":"https://api.github.com/repos/bunq/sdk_java/pulls/99/comments","review_comment_url":"https://api.github.com/repos/bunq/sdk_java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bunq/sdk_java/issues/99/comments","statuses_url":"https://api.github.com/repos/bunq/sdk_java/statuses/0bc198764cd527e97b1d42d7c23e53d32040fe17","head":{"label":"tubbynl:develop-non-breaking-refactor","ref":"develop-non-breaking-refactor","sha":"0bc198764cd527e97b1d42d7c23e53d32040fe17","user":{"login":"tubbynl","id":6532583,"node_id":"MDQ6VXNlcjY1MzI1ODM=","avatar_url":"https://avatars2.githubusercontent.com/u/6532583?v=4","gravatar_id":"","url":"https://api.github.com/users/tubbynl","html_url":"https://github.com/tubbynl","followers_url":"https://api.github.com/users/tubbynl/followers","following_url":"https://api.github.com/users/tubbynl/following{/other_user}","gists_url":"https://api.github.com/users/tubbynl/gists{/gist_id}","starred_url":"https://api.github.com/users/tubbynl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tubbynl/subscriptions","organizations_url":"https://api.github.com/users/tubbynl/orgs","repos_url":"https://api.github.com/users/tubbynl/repos","events_url":"https://api.github.com/users/tubbynl/events{/privacy}","received_events_url":"https://api.github.com/users/tubbynl/received_events","type":"User","site_admin":false},"repo":{"id":135687170,"node_id":"MDEwOlJlcG9zaXRvcnkxMzU2ODcxNzA=","name":"sdk_java","full_name":"tubbynl/sdk_java","owner":{"login":"tubbynl","id":6532583,"node_id":"MDQ6VXNlcjY1MzI1ODM=","avatar_url":"https://avatars2.githubusercontent.com/u/6532583?v=4","gravatar_id":"","url":"https://api.github.com/users/tubbynl","html_url":"https://github.com/tubbynl","followers_url":"https://api.github.com/users/tubbynl/followers","following_url":"https://api.github.com/users/tubbynl/following{/other_user}","gists_url":"https://api.github.com/users/tubbynl/gists{/gist_id}","starred_url":"https://api.github.com/users/tubbynl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tubbynl/subscriptions","organizations_url":"https://api.github.com/users/tubbynl/orgs","repos_url":"https://api.github.com/users/tubbynl/repos","events_url":"https://api.github.com/users/tubbynl/events{/privacy}","received_events_url":"https://api.github.com/users/tubbynl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tubbynl/sdk_java","description":"Java SDK for bunq API","fork":true,"url":"https://api.github.com/repos/tubbynl/sdk_java","forks_url":"https://api.github.com/repos/tubbynl/sdk_java/forks","keys_url":"https://api.github.com/repos/tubbynl/sdk_java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tubbynl/sdk_java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tubbynl/sdk_java/teams","hooks_url":"https://api.github.com/repos/tubbynl/sdk_java/hooks","issue_events_url":"https://api.github.com/repos/tubbynl/sdk_java/issues/events{/number}","events_url":"https://api.github.com/repos/tubbynl/sdk_java/events","assignees_url":"https://api.github.com/repos/tubbynl/sdk_java/assignees{/user}","branches_url":"https://api.github.com/repos/tubbynl/sdk_java/branches{/branch}","tags_url":"https://api.github.com/repos/tubbynl/sdk_java/tags","blobs_url":"https://api.github.com/repos/tubbynl/sdk_java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tubbynl/sdk_java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tubbynl/sdk_java/git/refs{/sha}","trees_url":"https://api.github.com/repos/tubbynl/sdk_java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tubbynl/sdk_java/statuses/{sha}","languages_url":"https://api.github.com/repos/tubbynl/sdk_java/languages","stargazers_url":"https://api.github.com/repos/tubbynl/sdk_java/stargazers","contributors_url":"https://api.github.com/repos/tubbynl/sdk_java/contributors","subscribers_url":"https://api.github.com/repos/tubbynl/sdk_java/subscribers","subscription_url":"https://api.github.com/repos/tubbynl/sdk_java/subscription","commits_url":"https://api.github.com/repos/tubbynl/sdk_java/commits{/sha}","git_commits_url":"https://api.github.com/repos/tubbynl/sdk_java/git/commits{/sha}","comments_url":"https://api.github.com/repos/tubbynl/sdk_java/comments{/number}","issue_comment_url":"https://api.github.com/repos/tubbynl/sdk_java/issues/comments{/number}","contents_url":"https://api.github.com/repos/tubbynl/sdk_java/contents/{+path}","compare_url":"https://api.github.com/repos/tubbynl/sdk_java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tubbynl/sdk_java/merges","archive_url":"https://api.github.com/repos/tubbynl/sdk_java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tubbynl/sdk_java/downloads","issues_url":"https://api.github.com/repos/tubbynl/sdk_java/issues{/number}","pulls_url":"https://api.github.com/repos/tubbynl/sdk_java/pulls{/number}","milestones_url":"https://api.github.com/repos/tubbynl/sdk_java/milestones{/number}","notifications_url":"https://api.github.com/repos/tubbynl/sdk_java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tubbynl/sdk_java/labels{/name}","releases_url":"https://api.github.com/repos/tubbynl/sdk_java/releases{/id}","deployments_url":"https://api.github.com/repos/tubbynl/sdk_java/deployments","created_at":"2018-06-01T08:02:04Z","updated_at":"2018-06-04T08:19:31Z","pushed_at":"2018-06-19T06:03:51Z","git_url":"git://github.com/tubbynl/sdk_java.git","ssh_url":"git@github.com:tubbynl/sdk_java.git","clone_url":"https://github.com/tubbynl/sdk_java.git","svn_url":"https://github.com/tubbynl/sdk_java","homepage":null,"size":1098,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"bunq:develop","ref":"develop","sha":"7ed15ad7762b88f58de44ca1c83a4b1cdea6ae08","user":{"login":"bunq","id":1984681,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5ODQ2ODE=","avatar_url":"https://avatars0.githubusercontent.com/u/1984681?v=4","gravatar_id":"","url":"https://api.github.com/users/bunq","html_url":"https://github.com/bunq","followers_url":"https://api.github.com/users/bunq/followers","following_url":"https://api.github.com/users/bunq/following{/other_user}","gists_url":"https://api.github.com/users/bunq/gists{/gist_id}","starred_url":"https://api.github.com/users/bunq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bunq/subscriptions","organizations_url":"https://api.github.com/users/bunq/orgs","repos_url":"https://api.github.com/users/bunq/repos","events_url":"https://api.github.com/users/bunq/events{/privacy}","received_events_url":"https://api.github.com/users/bunq/received_events","type":"Organization","site_admin":false},"repo":{"id":98569330,"node_id":"MDEwOlJlcG9zaXRvcnk5ODU2OTMzMA==","name":"sdk_java","full_name":"bunq/sdk_java","owner":{"login":"bunq","id":1984681,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5ODQ2ODE=","avatar_url":"https://avatars0.githubusercontent.com/u/1984681?v=4","gravatar_id":"","url":"https://api.github.com/users/bunq","html_url":"https://github.com/bunq","followers_url":"https://api.github.com/users/bunq/followers","following_url":"https://api.github.com/users/bunq/following{/other_user}","gists_url":"https://api.github.com/users/bunq/gists{/gist_id}","starred_url":"https://api.github.com/users/bunq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bunq/subscriptions","organizations_url":"https://api.github.com/users/bunq/orgs","repos_url":"https://api.github.com/users/bunq/repos","events_url":"https://api.github.com/users/bunq/events{/privacy}","received_events_url":"https://api.github.com/users/bunq/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bunq/sdk_java","description":"Java SDK for bunq API","fork":false,"url":"https://api.github.com/repos/bunq/sdk_java","forks_url":"https://api.github.com/repos/bunq/sdk_java/forks","keys_url":"https://api.github.com/repos/bunq/sdk_java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bunq/sdk_java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bunq/sdk_java/teams","hooks_url":"https://api.github.com/repos/bunq/sdk_java/hooks","issue_events_url":"https://api.github.com/repos/bunq/sdk_java/issues/events{/number}","events_url":"https://api.github.com/repos/bunq/sdk_java/events","assignees_url":"https://api.github.com/repos/bunq/sdk_java/assignees{/user}","branches_url":"https://api.github.com/repos/bunq/sdk_java/branches{/branch}","tags_url":"https://api.github.com/repos/bunq/sdk_java/tags","blobs_url":"https://api.github.com/repos/bunq/sdk_java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bunq/sdk_java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bunq/sdk_java/git/refs{/sha}","trees_url":"https://api.github.com/repos/bunq/sdk_java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bunq/sdk_java/statuses/{sha}","languages_url":"https://api.github.com/repos/bunq/sdk_java/languages","stargazers_url":"https://api.github.com/repos/bunq/sdk_java/stargazers","contributors_url":"https://api.github.com/repos/bunq/sdk_java/contributors","subscribers_url":"https://api.github.com/repos/bunq/sdk_java/subscribers","subscription_url":"https://api.github.com/repos/bunq/sdk_java/subscription","commits_url":"https://api.github.com/repos/bunq/sdk_java/commits{/sha}","git_commits_url":"https://api.github.com/repos/bunq/sdk_java/git/commits{/sha}","comments_url":"https://api.github.com/repos/bunq/sdk_java/comments{/number}","issue_comment_url":"https://api.github.com/repos/bunq/sdk_java/issues/comments{/number}","contents_url":"https://api.github.com/repos/bunq/sdk_java/contents/{+path}","compare_url":"https://api.github.com/repos/bunq/sdk_java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bunq/sdk_java/merges","archive_url":"https://api.github.com/repos/bunq/sdk_java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bunq/sdk_java/downloads","issues_url":"https://api.github.com/repos/bunq/sdk_java/issues{/number}","pulls_url":"https://api.github.com/repos/bunq/sdk_java/pulls{/number}","milestones_url":"https://api.github.com/repos/bunq/sdk_java/milestones{/number}","notifications_url":"https://api.github.com/repos/bunq/sdk_java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bunq/sdk_java/labels{/name}","releases_url":"https://api.github.com/repos/bunq/sdk_java/releases{/id}","deployments_url":"https://api.github.com/repos/bunq/sdk_java/deployments","created_at":"2017-07-27T18:39:50Z","updated_at":"2018-06-13T06:53:40Z","pushed_at":"2018-06-19T06:03:54Z","git_url":"git://github.com/bunq/sdk_java.git","ssh_url":"git@github.com:bunq/sdk_java.git","clone_url":"https://github.com/bunq/sdk_java.git","svn_url":"https://github.com/bunq/sdk_java","homepage":null,"size":1126,"stargazers_count":12,"watchers_count":12,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":10,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":4,"open_issues":10,"watchers":12,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/bunq/sdk_java/pulls/99"},"html":{"href":"https://github.com/bunq/sdk_java/pull/99"},"issue":{"href":"https://api.github.com/repos/bunq/sdk_java/issues/99"},"comments":{"href":"https://api.github.com/repos/bunq/sdk_java/issues/99/comments"},"review_comments":{"href":"https://api.github.com/repos/bunq/sdk_java/pulls/99/comments"},"review_comment":{"href":"https://api.github.com/repos/bunq/sdk_java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bunq/sdk_java/pulls/99/commits"},"statuses":{"href":"https://api.github.com/repos/bunq/sdk_java/statuses/0bc198764cd527e97b1d42d7c23e53d32040fe17"}},"author_association":"NONE"}}
{"actor":{"display_login":"OGKevin"}}