From 28fcb9de2cbb6e861419f4d54ce3d15a8224f500 Mon Sep 17 00:00:00 2001 From: Artsiom Safonau Date: Tue, 24 Mar 2026 13:55:59 +0300 Subject: [PATCH 1/2] Add #get_report method --- Gemfile.lock | 4 ++-- README.md | 7 +++++++ lib/boapi/client.rb | 4 ++++ lib/boapi/version.rb | 2 +- spec/boapi/client_spec.rb | 25 +++++++++++++++++++++++++ spec/fixtures/report_fixtures.rb | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 71 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8ed5975..2890134 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - boapi (0.14.0) + boapi (0.15.0) faraday (> 0.7.6, < 1.0) faraday_middleware (> 0.1, < 1.0) @@ -88,4 +88,4 @@ DEPENDENCIES webmock (~> 3.18.1) BUNDLED WITH - 2.4.5 + 2.4.22 diff --git a/README.md b/README.md index 0055305..862640c 100644 --- a/README.md +++ b/README.md @@ -233,6 +233,13 @@ response.data # "{\"data\":{\"report\":{\"id\":\"961c3be2-c7b0-44ab-9f79-48cabd30c519\",\"status\":\"pending\",\"type\":\"balance_records_report\",\"format\":\"csv\",\"engine\":\"oban\",\"user_id\":1,\"language\":\"en\",\"updated_at\":\"2025-06-25T13:41:38.976093Z\",\"created_at\":\"2025-06-25T13:41:38.976093Z\",\"psp_id\":1,\"generated_at\":null,\"expiry_date\":null,\"file_url\":null,\"notification_email\":null,\"request_params\":{...}}}}" ``` +Get report +```ruby +client.get_report(report_id) +response.data +# "{\"data\":{\"report\":{\"id\":\"961c3be2-c7b0-44ab-9f79-48cabd30c519\",\"status\":\"successful\",\"type\":\"balance_records_report\",\"format\":\"csv\",\"engine\":\"oban\",\"user_id\":1,\"language\":\"en\",\"updated_at\":\"2025-06-25T13:41:38.976093Z\",\"created_at\":\"2025-06-25T13:41:38.976093Z\",\"psp_id\":1,\"generated_at\":null,\"expiry_date\":null,\"file_url\":https://s3.eu-west-1.amazonaws.com/wlsexports-test\"notification_email\":null,\"request_params\":{...}}}}" +``` + ## Errors Unauthorized diff --git a/lib/boapi/client.rb b/lib/boapi/client.rb index 794512d..79379e4 100644 --- a/lib/boapi/client.rb +++ b/lib/boapi/client.rb @@ -89,6 +89,10 @@ def create_report(params) send_request(:post, '/api/v2/reports', params) end + def get_report(id) + send_request(:get, "/api/v2/reports/#{id}") + end + def reports_aggregation(params) send_request(:post, '/api/v2/reports/aggregation', params) end diff --git a/lib/boapi/version.rb b/lib/boapi/version.rb index cd97221..31c010d 100644 --- a/lib/boapi/version.rb +++ b/lib/boapi/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Boapi - VERSION = '0.14.0' + VERSION = '0.15.0' end diff --git a/spec/boapi/client_spec.rb b/spec/boapi/client_spec.rb index 9034be2..2b64461 100644 --- a/spec/boapi/client_spec.rb +++ b/spec/boapi/client_spec.rb @@ -639,6 +639,31 @@ end end + describe '.get_report' do + let(:response) do + Boapi::Client.new(account_id: account_id, account_secret: account_secret).get_report(uid) + end + let(:http_status) { 200 } + + let(:uid) { '961c3be2-c7b0-44ab-9f79-48cabd30c519' } + let(:url) { "#{Boapi.configuration.api_host}/api/v2/reports/#{uid}" } + + context 'when valid params given' do + before do + stub_request(:get, url) + .to_return(status: http_status, body: ReportFixtures.successful_get_report_response) + end + + it 'returns successful response' do + expect(response.status).to be http_status + + expect(response.success?).to be true + expect(response.error?).to be false + expect(response.data).to eq(ReportFixtures.successful_get_report_message) + end + end + end + describe '.create_aggregation' do let(:response) do Boapi::Client.new(account_id: account_id, account_secret: account_secret).reports_aggregation(params) diff --git a/spec/fixtures/report_fixtures.rb b/spec/fixtures/report_fixtures.rb index dd716ae..8dd82ce 100644 --- a/spec/fixtures/report_fixtures.rb +++ b/spec/fixtures/report_fixtures.rb @@ -33,8 +33,40 @@ def successful_create_report_response_message } end + def successful_get_report_message + { + 'report' => { + 'id' => 'c3050350-358c-4336-9ba2-da187fc443f5', + 'status' => 'successful', + 'type' => 'balance_records', + 'format' => 'xlsx', + 'engine' => 'oban', + 'attempt' => 1, + 'updated_at' => '2025-12-15T12:22:38.821314Z', + 'language' => 'en', + 'user_id' => 1098, + 'created_at' => '2025-12-15T12:22:38.821314Z', + 'psp_id' => 1, + 'generated_at' => '2025-12-15T12:22:55.605715Z', + 'expiry_date' => '2025-12-18T12:22:55.618136Z', + 'file_url' => 'https://s3.eu-west-1.amazonaws.com/wlsexports-test/app/local_vol/reports/c3050350-358c-4136-9ba2-da187fc443f5/report_balance_records_202412312100_202511302059_c3050350.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJBYIPDD7GHCZUBWQ%2F20251215%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20251215T122255Z&X-Amz-Expires=259200&X-Amz-SignedHeaders=host&X-Amz-Signature=77e5f4e97f8544e26f90c75877df81167871b09736524f3110eabea1aa270f17', + 'notification_email' => 'test@test.com', + 'request_params' => { + 'currency' => 'USD', + 'shop_id' => 1673, + 'date_from' => '2024-12-31T21:00:00.000000Z', + 'date_to' => '2025-11-30T20:59:59.999999Z' + } + } + } + end + def successful_create_report_response %({"data":#{successful_create_report_response_message.to_json}}) end + + def successful_get_report_response + %({"data":#{successful_get_report_message.to_json}}) + end end # rubocop:enable Metrics/MethodLength From bd4cbbeeac7b7c65627f83bac9cbfb2bf71ece8c Mon Sep 17 00:00:00 2001 From: Artsiom Safonau Date: Tue, 24 Mar 2026 16:40:38 +0300 Subject: [PATCH 2/2] Update bundler --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2890134..5e00173 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,4 +88,4 @@ DEPENDENCIES webmock (~> 3.18.1) BUNDLED WITH - 2.4.22 + 2.4.5