From baee119e878ef8c16c49c10052ddd9b46cd2a564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Bo=CC=88ning?= Date: Mon, 20 Mar 2023 12:39:00 +0100 Subject: [PATCH] add endpoint for extended address info --- .../endpoints/cardano/addresses_endpoints.rb | 8 +++++++ spec/endpoints/addresses_endpoints_spec.rb | 22 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/blockfrostruby/endpoints/cardano/addresses_endpoints.rb b/lib/blockfrostruby/endpoints/cardano/addresses_endpoints.rb index ad74b90..9a26c2d 100644 --- a/lib/blockfrostruby/endpoints/cardano/addresses_endpoints.rb +++ b/lib/blockfrostruby/endpoints/cardano/addresses_endpoints.rb @@ -17,6 +17,14 @@ def get_specific_address(address) Request.get_response("#{@url}/addresses/#{address}", @project_id) end + # Calls get request on (@url)/addresses/(address)/extended. + # + # @param address [String] will be added to the url for get request. + # @return [Hash] formatted result with status and body keys. + def get_extended_address_info(address) + Request.get_response("#{@url}/addresses/#{address}/extended", @project_id) + end + # Calls get request on (@url)/addresses/(address)/total. # # @param address [String] will be added to the url for get request. diff --git a/spec/endpoints/addresses_endpoints_spec.rb b/spec/endpoints/addresses_endpoints_spec.rb index d68bbd2..27eb4b2 100644 --- a/spec/endpoints/addresses_endpoints_spec.rb +++ b/spec/endpoints/addresses_endpoints_spec.rb @@ -32,6 +32,28 @@ end end + context 'when calls get_extended_address_info method' do + context 'with valid address' do + it 'returns status 200, response body includes address, amount, stake_address, type, script' do + response = blockfrost_mainnet.get_extended_address_info(valid_address) + expect(response[:status]).to eq(200) + expect(response[:body]).to include(address: valid_address) + expect(response[:body]).to include(:amount) + expect(response[:body]).to include(:stake_address) + expect(response[:body]).to include(:type) + expect(response[:body]).to include(:script) + end + end + + context 'with invalid address' do + it 'returns status 400, response body includes error' do + response = blockfrost_mainnet.get_extended_address_info(invalid_address) + expect(response[:status]).to eq(400) + expect(response[:body]).to include(:error) + end + end + end + context 'when calls get_address_details method' do context 'with valid address' do it 'returns status 200, response body includes address' do