{"action":"created","comment":{"url":"https://api.github.com/repos/e2y/adyen-mirakl/pulls/comments/175753323","pull_request_review_id":105327304,"id":175753323,"diff_hunk":"@@ -103,8 +111,58 @@\n         return builder.build();\n     }\n \n-    public List<ShareholderContact> extractUbos(final MiraklShop shop, Integer maxUbos) {\n-        return extractUbos(shop, null, maxUbos);\n+    public Map<MiraklShopDocument, DocumentDetail.DocumentTypeEnum> extractUboDocuments(List<MiraklShopDocument> miraklUbos) {\n+        final ImmutableMap.Builder<MiraklShopDocument, DocumentDetail.DocumentTypeEnum> builder = ImmutableMap.builder();\n+\n+        Map<String, DocumentDetail.DocumentTypeEnum> internalMemoryForDocs = new HashMap<>();\n+        miraklUbos.forEach(miraklShopDocument -> {\n+            for (int uboNumber = 1; uboNumber <= maxUbos; uboNumber++) {\n+                addToBuilder(builder, internalMemoryForDocs, miraklShopDocument, uboNumber);\n+            }\n+        });\n+\n+        return builder.build();\n+    }\n+\n+    private void addToBuilder(ImmutableMap.Builder<MiraklShopDocument, DocumentDetail.DocumentTypeEnum> builder, Map<String, DocumentDetail.DocumentTypeEnum> internalMemoryForDocs, MiraklShopDocument miraklShopDocument, int uboNumber) {\n+        String photoIdFront = ADYEN_UBO + uboNumber + \"-photoid\";\n+        String photoIdRear = ADYEN_UBO + uboNumber + \"-photoid-rear\";\n+        if (miraklShopDocument.getTypeCode().equalsIgnoreCase(photoIdFront) || miraklShopDocument.getTypeCode().equalsIgnoreCase(photoIdRear)) {\n+            DocumentDetail.DocumentTypeEnum documentTypeEnum = retrieveUboPhotoIdType(uboNumber, miraklShopDocument.getShopId(), internalMemoryForDocs);\n+            if(documentTypeEnum!=null){\n+                builder.put(miraklShopDocument, documentTypeEnum);\n+            }\n+        }\n+    }\n+\n+    private DocumentDetail.DocumentTypeEnum retrieveUboPhotoIdType(final Integer uboNumber, final String shopId, Map<String, DocumentDetail.DocumentTypeEnum> internalMemory) {\n+        DocumentDetail.DocumentTypeEnum documentTypeEnum = internalMemory.getOrDefault(shopId + \"_\" + uboNumber, null);\n+        if (documentTypeEnum == null) {\n+            DocumentDetail.DocumentTypeEnum docTypeFromMirakl = getDocTypeFromMirakl(uboNumber, shopId);\n+            if(docTypeFromMirakl!=null){\n+                internalMemory.put(shopId + \"_\" + uboNumber, docTypeFromMirakl);\n+                return docTypeFromMirakl;\n+            }\n+        }\n+        return documentTypeEnum;\n+    }\n+\n+    private DocumentDetail.DocumentTypeEnum getDocTypeFromMirakl(Integer uboNumber, String shopId) {\n+        MiraklGetShopsRequest request = new MiraklGetShopsRequest();\n+        request.setShopIds(ImmutableList.of(shopId));\n+        MiraklShops shops = miraklMarketplacePlatformOperatorApiClient.getShops(request);\n+        MiraklShop shop = shops.getShops().iterator().next();\n+        String code = ADYEN_UBO + uboNumber + \"-photoidtype\";\n+        Optional<MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue> photoIdType = shop.getAdditionalFieldValues().stream()\n+            .filter(MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue.class::isInstance)\n+            .map(MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue.class::cast)\n+            .filter(x -> code.equalsIgnoreCase(x.getCode())).findAny();\n+        return photoIdType.filter(x -> StringUtils.isNotEmpty(x.getValue())).map(x -> DocumentDetail.DocumentTypeEnum.valueOf(x.getValue()))","path":"src/main/java/com/adyen/mirakl/service/UboService.java","position":102,"original_position":102,"commit_id":"cdb8772d43031cec260c1271faa79431d08907f4","original_commit_id":"cdb8772d43031cec260c1271faa79431d08907f4","user":{"login":"rmcotton","id":10423174,"avatar_url":"https://avatars0.githubusercontent.com/u/10423174?v=4","gravatar_id":"","url":"https://api.github.com/users/rmcotton","html_url":"https://github.com/rmcotton","followers_url":"https://api.github.com/users/rmcotton/followers","following_url":"https://api.github.com/users/rmcotton/following{/other_user}","gists_url":"https://api.github.com/users/rmcotton/gists{/gist_id}","starred_url":"https://api.github.com/users/rmcotton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmcotton/subscriptions","organizations_url":"https://api.github.com/users/rmcotton/orgs","repos_url":"https://api.github.com/users/rmcotton/repos","events_url":"https://api.github.com/users/rmcotton/events{/privacy}","received_events_url":"https://api.github.com/users/rmcotton/received_events","type":"User","site_admin":false},"body":"I think this needs to be more clever for FRONT/BACK.\r\n\r\nwe only ask the seller to tell us whether they are uploading a DRIVING_LICENSE.. its up to us if we are provided a rear document to amend it to rear.\r\n","created_at":"2018-03-20T12:53:58Z","updated_at":"2018-03-20T12:55:31Z","html_url":"https://github.com/e2y/adyen-mirakl/pull/97#discussion_r175753323","pull_request_url":"https://api.github.com/repos/e2y/adyen-mirakl/pulls/97","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/e2y/adyen-mirakl/pulls/comments/175753323"},"html":{"href":"https://github.com/e2y/adyen-mirakl/pull/97#discussion_r175753323"},"pull_request":{"href":"https://api.github.com/repos/e2y/adyen-mirakl/pulls/97"}}},"pull_request":{"url":"https://api.github.com/repos/e2y/adyen-mirakl/pulls/97","id":176050768,"html_url":"https://github.com/e2y/adyen-mirakl/pull/97","diff_url":"https://github.com/e2y/adyen-mirakl/pull/97.diff","patch_url":"https://github.com/e2y/adyen-mirakl/pull/97.patch","issue_url":"https://api.github.com/repos/e2y/adyen-mirakl/issues/97","number":97,"state":"open","locked":false,"title":"[DG] ADY-99 As a Business Seller I would like to upload new or update…","user":{"login":"pandemicGander","id":1323016,"avatar_url":"https://avatars0.githubusercontent.com/u/1323016?v=4","gravatar_id":"","url":"https://api.github.com/users/pandemicGander","html_url":"https://github.com/pandemicGander","followers_url":"https://api.github.com/users/pandemicGander/followers","following_url":"https://api.github.com/users/pandemicGander/following{/other_user}","gists_url":"https://api.github.com/users/pandemicGander/gists{/gist_id}","starred_url":"https://api.github.com/users/pandemicGander/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pandemicGander/subscriptions","organizations_url":"https://api.github.com/users/pandemicGander/orgs","repos_url":"https://api.github.com/users/pandemicGander/repos","events_url":"https://api.github.com/users/pandemicGander/events{/privacy}","received_events_url":"https://api.github.com/users/pandemicGander/received_events","type":"User","site_admin":false},"body":"…d photo id for shareholders so that I can complete identity checks","created_at":"2018-03-19T23:16:45Z","updated_at":"2018-03-20T12:55:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9e918af0d5422fdec95575ac1da32bb0e000b20e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/e2y/adyen-mirakl/pulls/97/commits","review_comments_url":"https://api.github.com/repos/e2y/adyen-mirakl/pulls/97/comments","review_comment_url":"https://api.github.com/repos/e2y/adyen-mirakl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/e2y/adyen-mirakl/issues/97/comments","statuses_url":"https://api.github.com/repos/e2y/adyen-mirakl/statuses/cdb8772d43031cec260c1271faa79431d08907f4","head":{"label":"e2y:feature/ADY-99","ref":"feature/ADY-99","sha":"cdb8772d43031cec260c1271faa79431d08907f4","user":{"login":"e2y","id":17727193,"avatar_url":"https://avatars2.githubusercontent.com/u/17727193?v=4","gravatar_id":"","url":"https://api.github.com/users/e2y","html_url":"https://github.com/e2y","followers_url":"https://api.github.com/users/e2y/followers","following_url":"https://api.github.com/users/e2y/following{/other_user}","gists_url":"https://api.github.com/users/e2y/gists{/gist_id}","starred_url":"https://api.github.com/users/e2y/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/e2y/subscriptions","organizations_url":"https://api.github.com/users/e2y/orgs","repos_url":"https://api.github.com/users/e2y/repos","events_url":"https://api.github.com/users/e2y/events{/privacy}","received_events_url":"https://api.github.com/users/e2y/received_events","type":"Organization","site_admin":false},"repo":{"id":120294302,"name":"adyen-mirakl","full_name":"e2y/adyen-mirakl","owner":{"login":"e2y","id":17727193,"avatar_url":"https://avatars2.githubusercontent.com/u/17727193?v=4","gravatar_id":"","url":"https://api.github.com/users/e2y","html_url":"https://github.com/e2y","followers_url":"https://api.github.com/users/e2y/followers","following_url":"https://api.github.com/users/e2y/following{/other_user}","gists_url":"https://api.github.com/users/e2y/gists{/gist_id}","starred_url":"https://api.github.com/users/e2y/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/e2y/subscriptions","organizations_url":"https://api.github.com/users/e2y/orgs","repos_url":"https://api.github.com/users/e2y/repos","events_url":"https://api.github.com/users/e2y/events{/privacy}","received_events_url":"https://api.github.com/users/e2y/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/e2y/adyen-mirakl","description":"Adyen Mirakl Connector","fork":false,"url":"https://api.github.com/repos/e2y/adyen-mirakl","forks_url":"https://api.github.com/repos/e2y/adyen-mirakl/forks","keys_url":"https://api.github.com/repos/e2y/adyen-mirakl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/e2y/adyen-mirakl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/e2y/adyen-mirakl/teams","hooks_url":"https://api.github.com/repos/e2y/adyen-mirakl/hooks","issue_events_url":"https://api.github.com/repos/e2y/adyen-mirakl/issues/events{/number}","events_url":"https://api.github.com/repos/e2y/adyen-mirakl/events","assignees_url":"https://api.github.com/repos/e2y/adyen-mirakl/assignees{/user}","branches_url":"https://api.github.com/repos/e2y/adyen-mirakl/branches{/branch}","tags_url":"https://api.github.com/repos/e2y/adyen-mirakl/tags","blobs_url":"https://api.github.com/repos/e2y/adyen-mirakl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/e2y/adyen-mirakl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/e2y/adyen-mirakl/git/refs{/sha}","trees_url":"https://api.github.com/repos/e2y/adyen-mirakl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/e2y/adyen-mirakl/statuses/{sha}","languages_url":"https://api.github.com/repos/e2y/adyen-mirakl/languages","stargazers_url":"https://api.github.com/repos/e2y/adyen-mirakl/stargazers","contributors_url":"https://api.github.com/repos/e2y/adyen-mirakl/contributors","subscribers_url":"https://api.github.com/repos/e2y/adyen-mirakl/subscribers","subscription_url":"https://api.github.com/repos/e2y/adyen-mirakl/subscription","commits_url":"https://api.github.com/repos/e2y/adyen-mirakl/commits{/sha}","git_commits_url":"https://api.github.com/repos/e2y/adyen-mirakl/git/commits{/sha}","comments_url":"https://api.github.com/repos/e2y/adyen-mirakl/comments{/number}","issue_comment_url":"https://api.github.com/repos/e2y/adyen-mirakl/issues/comments{/number}","contents_url":"https://api.github.com/repos/e2y/adyen-mirakl/contents/{+path}","compare_url":"https://api.github.com/repos/e2y/adyen-mirakl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/e2y/adyen-mirakl/merges","archive_url":"https://api.github.com/repos/e2y/adyen-mirakl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/e2y/adyen-mirakl/downloads","issues_url":"https://api.github.com/repos/e2y/adyen-mirakl/issues{/number}","pulls_url":"https://api.github.com/repos/e2y/adyen-mirakl/pulls{/number}","milestones_url":"https://api.github.com/repos/e2y/adyen-mirakl/milestones{/number}","notifications_url":"https://api.github.com/repos/e2y/adyen-mirakl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/e2y/adyen-mirakl/labels{/name}","releases_url":"https://api.github.com/repos/e2y/adyen-mirakl/releases{/id}","deployments_url":"https://api.github.com/repos/e2y/adyen-mirakl/deployments","created_at":"2018-02-05T11:12:50Z","updated_at":"2018-03-20T11:01:35Z","pushed_at":"2018-03-20T12:10:45Z","git_url":"git://github.com/e2y/adyen-mirakl.git","ssh_url":"git@github.com:e2y/adyen-mirakl.git","clone_url":"https://github.com/e2y/adyen-mirakl.git","svn_url":"https://github.com/e2y/adyen-mirakl","homepage":null,"size":824,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"base":{"label":"e2y:develop","ref":"develop","sha":"b518c99ddda88d35a681b858df7ab43407d82636","user":{"login":"e2y","id":17727193,"avatar_url":"https://avatars2.githubusercontent.com/u/17727193?v=4","gravatar_id":"","url":"https://api.github.com/users/e2y","html_url":"https://github.com/e2y","followers_url":"https://api.github.com/users/e2y/followers","following_url":"https://api.github.com/users/e2y/following{/other_user}","gists_url":"https://api.github.com/users/e2y/gists{/gist_id}","starred_url":"https://api.github.com/users/e2y/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/e2y/subscriptions","organizations_url":"https://api.github.com/users/e2y/orgs","repos_url":"https://api.github.com/users/e2y/repos","events_url":"https://api.github.com/users/e2y/events{/privacy}","received_events_url":"https://api.github.com/users/e2y/received_events","type":"Organization","site_admin":false},"repo":{"id":120294302,"name":"adyen-mirakl","full_name":"e2y/adyen-mirakl","owner":{"login":"e2y","id":17727193,"avatar_url":"https://avatars2.githubusercontent.com/u/17727193?v=4","gravatar_id":"","url":"https://api.github.com/users/e2y","html_url":"https://github.com/e2y","followers_url":"https://api.github.com/users/e2y/followers","following_url":"https://api.github.com/users/e2y/following{/other_user}","gists_url":"https://api.github.com/users/e2y/gists{/gist_id}","starred_url":"https://api.github.com/users/e2y/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/e2y/subscriptions","organizations_url":"https://api.github.com/users/e2y/orgs","repos_url":"https://api.github.com/users/e2y/repos","events_url":"https://api.github.com/users/e2y/events{/privacy}","received_events_url":"https://api.github.com/users/e2y/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/e2y/adyen-mirakl","description":"Adyen Mirakl Connector","fork":false,"url":"https://api.github.com/repos/e2y/adyen-mirakl","forks_url":"https://api.github.com/repos/e2y/adyen-mirakl/forks","keys_url":"https://api.github.com/repos/e2y/adyen-mirakl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/e2y/adyen-mirakl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/e2y/adyen-mirakl/teams","hooks_url":"https://api.github.com/repos/e2y/adyen-mirakl/hooks","issue_events_url":"https://api.github.com/repos/e2y/adyen-mirakl/issues/events{/number}","events_url":"https://api.github.com/repos/e2y/adyen-mirakl/events","assignees_url":"https://api.github.com/repos/e2y/adyen-mirakl/assignees{/user}","branches_url":"https://api.github.com/repos/e2y/adyen-mirakl/branches{/branch}","tags_url":"https://api.github.com/repos/e2y/adyen-mirakl/tags","blobs_url":"https://api.github.com/repos/e2y/adyen-mirakl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/e2y/adyen-mirakl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/e2y/adyen-mirakl/git/refs{/sha}","trees_url":"https://api.github.com/repos/e2y/adyen-mirakl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/e2y/adyen-mirakl/statuses/{sha}","languages_url":"https://api.github.com/repos/e2y/adyen-mirakl/languages","stargazers_url":"https://api.github.com/repos/e2y/adyen-mirakl/stargazers","contributors_url":"https://api.github.com/repos/e2y/adyen-mirakl/contributors","subscribers_url":"https://api.github.com/repos/e2y/adyen-mirakl/subscribers","subscription_url":"https://api.github.com/repos/e2y/adyen-mirakl/subscription","commits_url":"https://api.github.com/repos/e2y/adyen-mirakl/commits{/sha}","git_commits_url":"https://api.github.com/repos/e2y/adyen-mirakl/git/commits{/sha}","comments_url":"https://api.github.com/repos/e2y/adyen-mirakl/comments{/number}","issue_comment_url":"https://api.github.com/repos/e2y/adyen-mirakl/issues/comments{/number}","contents_url":"https://api.github.com/repos/e2y/adyen-mirakl/contents/{+path}","compare_url":"https://api.github.com/repos/e2y/adyen-mirakl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/e2y/adyen-mirakl/merges","archive_url":"https://api.github.com/repos/e2y/adyen-mirakl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/e2y/adyen-mirakl/downloads","issues_url":"https://api.github.com/repos/e2y/adyen-mirakl/issues{/number}","pulls_url":"https://api.github.com/repos/e2y/adyen-mirakl/pulls{/number}","milestones_url":"https://api.github.com/repos/e2y/adyen-mirakl/milestones{/number}","notifications_url":"https://api.github.com/repos/e2y/adyen-mirakl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/e2y/adyen-mirakl/labels{/name}","releases_url":"https://api.github.com/repos/e2y/adyen-mirakl/releases{/id}","deployments_url":"https://api.github.com/repos/e2y/adyen-mirakl/deployments","created_at":"2018-02-05T11:12:50Z","updated_at":"2018-03-20T11:01:35Z","pushed_at":"2018-03-20T12:10:45Z","git_url":"git://github.com/e2y/adyen-mirakl.git","ssh_url":"git@github.com:e2y/adyen-mirakl.git","clone_url":"https://github.com/e2y/adyen-mirakl.git","svn_url":"https://github.com/e2y/adyen-mirakl","homepage":null,"size":824,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/e2y/adyen-mirakl/pulls/97"},"html":{"href":"https://github.com/e2y/adyen-mirakl/pull/97"},"issue":{"href":"https://api.github.com/repos/e2y/adyen-mirakl/issues/97"},"comments":{"href":"https://api.github.com/repos/e2y/adyen-mirakl/issues/97/comments"},"review_comments":{"href":"https://api.github.com/repos/e2y/adyen-mirakl/pulls/97/comments"},"review_comment":{"href":"https://api.github.com/repos/e2y/adyen-mirakl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/e2y/adyen-mirakl/pulls/97/commits"},"statuses":{"href":"https://api.github.com/repos/e2y/adyen-mirakl/statuses/cdb8772d43031cec260c1271faa79431d08907f4"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"rmcotton"}}