From ad0c2082f7b2c5a94840be4d54e8dd11a0b7b91e Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Tue, 23 Jan 2024 17:02:32 +0200 Subject: [PATCH] added endpoint for fetching card validation --- lib/mangopay/card.rb | 5 +++++ spec/mangopay/card_registration_spec.rb | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/mangopay/card.rb b/lib/mangopay/card.rb index 70de843..8c9c0cd 100644 --- a/lib/mangopay/card.rb +++ b/lib/mangopay/card.rb @@ -40,6 +40,11 @@ def validate(card_id, params) url = "#{MangoPay.api_path}/cards/#{card_id}/validation" MangoPay.request(:post, url, params) end + + def get_card_validation(card_id, validation_id) + url = "#{MangoPay.api_path}/cards/#{card_id}/validation/#{validation_id}" + MangoPay.request(:get, url) + end end end end diff --git a/spec/mangopay/card_registration_spec.rb b/spec/mangopay/card_registration_spec.rb index 4ed50da..3c030fe 100644 --- a/spec/mangopay/card_registration_spec.rb +++ b/spec/mangopay/card_registration_spec.rb @@ -100,5 +100,13 @@ expect(validated).to_not be_nil end + + it "fetches card validation" do + created = new_card_registration_completed + card_validation = create_card_validation(created['UserId'], created['CardId']) + fetched_card_validation = MangoPay::Card.get_card_validation(created['CardId'], card_validation['Id']) + + expect(card_validation['Id']).equal? fetched_card_validation['Id'] + end end end