Skip to content

Commit

Permalink
Merge pull request #196 from mantaskujalis/feature/ubo_declaration_fe…
Browse files Browse the repository at this point in the history
…tching

Allow to fetch ubo declaration without user id
  • Loading branch information
SoloJr authored Jun 10, 2021
2 parents 496ad82 + 2d7585b commit 854bd21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/mangopay/ubo_declaration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 +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)
Expand Down
11 changes: 11 additions & 0 deletions spec/mangopay/ubo_declaration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 854bd21

Please sign in to comment.