diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dc1253..1dea66a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.2 (2020-04-14) + +- Fix nil record with Bank Batch Report returns + ## 0.1.1 (2020-03-04) - Upgrade `rake` to `13.0.1` diff --git a/Gemfile.lock b/Gemfile.lock index 0e82eab..7d007bd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - bambora-client (0.1.0) + bambora-client (0.1.2) excon (< 1.0) faraday (< 1.0) gyoku (~> 1.0) @@ -19,15 +19,15 @@ GEM crack (0.4.3) safe_yaml (~> 1.0.0) diff-lcs (1.3) - excon (0.71.0) - faraday (0.17.1) + excon (0.73.0) + faraday (0.17.3) multipart-post (>= 1.2, < 3) gyoku (1.3.1) builder (>= 2.1.2) hashdiff (1.0.0) jaro_winkler (1.5.3) method_source (0.9.2) - mime-types (3.3) + mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2019.1009) multipart-post (2.1.1) diff --git a/lib/bambora/bank/batch_report_resource.rb b/lib/bambora/bank/batch_report_resource.rb index 1f9ddde..ec026a9 100644 --- a/lib/bambora/bank/batch_report_resource.rb +++ b/lib/bambora/bank/batch_report_resource.rb @@ -61,9 +61,13 @@ def show(report_data) private def add_messages_to_response(response) + # bambora can return null or empty record results, don't decorate with messages + return response if response.dig(:response, :record).nil? + response.dig(:response, :record).map! do |record| record.merge!(messages: record[:messageId].split(',').map { |id| MESSAGES[id] }) end + response end diff --git a/lib/bambora/client/version.rb b/lib/bambora/client/version.rb index 3e0e319..6b5f40d 100644 --- a/lib/bambora/client/version.rb +++ b/lib/bambora/client/version.rb @@ -2,6 +2,6 @@ module Bambora class Client - VERSION = '0.1.1' + VERSION = '0.1.2' end end diff --git a/spec/bambora/bank/batch_report_resource_spec.rb b/spec/bambora/bank/batch_report_resource_spec.rb index 1104de6..acf1d5d 100644 --- a/spec/bambora/bank/batch_report_resource_spec.rb +++ b/spec/bambora/bank/batch_report_resource_spec.rb @@ -223,6 +223,38 @@ module Bank expect(reports.show(request_data)).to eq expected_response end end + + context 'with nil records' do + let(:response_body) do + { + response: { + version: '1.0', + code: 1, + message: 'Report generated', + records: { + total: 0, + }, + }, + } + end + + let(:expected_response) do + { + response: { + version: '1.0', + code: 1, + message: 'Report generated', + records: { + total: 0, + }, + }, + } + end + + it 'returns the expected response' do + expect(reports.show(request_data)).to eq expected_response + end + end end end end