Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/boapi/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/boapi/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Boapi
VERSION = '0.14.0'
VERSION = '0.15.0'
end
25 changes: 25 additions & 0 deletions spec/boapi/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 32 additions & 0 deletions spec/fixtures/report_fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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