From ced540c90ec1c8dae4e9c217e8df2c540e2f218f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20K=C5=ABjalis?= Date: Wed, 2 Jun 2021 19:12:46 +0300 Subject: [PATCH 1/2] Allow to fetch ubo declaration without user id --- lib/mangopay/ubo_declaration.rb | 4 +++- spec/mangopay/ubo_declaration_spec.rb | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/mangopay/ubo_declaration.rb b/lib/mangopay/ubo_declaration.rb index 074fff7..e1c0e14 100644 --- a/lib/mangopay/ubo_declaration.rb +++ b/lib/mangopay/ubo_declaration.rb @@ -14,8 +14,10 @@ def create(user_id, idempotency_key) MangoPay.request(:post, url(user_id), {}, {}, idempotency_key) end + # Fetches the Ubo declaration belonging to the given +user_id+ if given, with the given +document_id+. def fetch(user_id, id, idempotency_key) - MangoPay.request(:get, url(user_id, id), {}, {}, idempotency_key) + url = (user_id) ? url(user_id, id) : "#{MangoPay.api_path}/kyc/ubodeclarations/#{CGI.escape(id.to_s)}" + MangoPay.request(:get, url, {}, {}, idempotency_key) end def update(user_id, id, params = {}, idempotency_key) diff --git a/spec/mangopay/ubo_declaration_spec.rb b/spec/mangopay/ubo_declaration_spec.rb index 6928267..e85fc7b 100644 --- a/spec/mangopay/ubo_declaration_spec.rb +++ b/spec/mangopay/ubo_declaration_spec.rb @@ -14,6 +14,17 @@ expect(ubo_declaration_byId).not_to be_nil end + it 'fetches ubo declaration just by id' do + legal_user = new_legal_user + + ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'], nil) + + ubo_declaration_byId = MangoPay::UboDeclaration.fetch(nil, ubo_declaration['Id'], nil) + + expect(ubo_declaration).not_to be_nil + expect(ubo_declaration_byId).not_to be_nil + end + describe 'UPDATE' do it 'can update a UBO declaration' do legal_user = new_legal_user From 2d7585b139b3ca3c24bf817bae0be9043124907a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20K=C5=ABjalis?= Date: Fri, 4 Jun 2021 11:12:31 +0300 Subject: [PATCH 2/2] Update comment --- lib/mangopay/ubo_declaration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mangopay/ubo_declaration.rb b/lib/mangopay/ubo_declaration.rb index e1c0e14..cdbd929 100644 --- a/lib/mangopay/ubo_declaration.rb +++ b/lib/mangopay/ubo_declaration.rb @@ -14,7 +14,7 @@ def create(user_id, idempotency_key) MangoPay.request(:post, url(user_id), {}, {}, idempotency_key) end - # Fetches the Ubo declaration belonging to the given +user_id+ if given, with the given +document_id+. + # Fetches the Ubo declaration belonging to the given +user_id+ if given, with the given +id+. def fetch(user_id, id, idempotency_key) url = (user_id) ? url(user_id, id) : "#{MangoPay.api_path}/kyc/ubodeclarations/#{CGI.escape(id.to_s)}" MangoPay.request(:get, url, {}, {}, idempotency_key)