Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## [Released]

## [0.13.0] - 2025-08-1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2025-08-01


- Add aggregation request

## [0.12.0] - 2025-06-26

- Add timeout error
Expand Down
4 changes: 4 additions & 0 deletions lib/boapi/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def create_report(params)
send_request(:post, '/api/v2/reports', params)
end

def reports_aggregation(params)
send_request(:post, '/api/v2/reports/aggregation', params)
end

# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
def send_request(method, path, params = nil)
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.12.0'
VERSION = '0.13.0'
end
42 changes: 42 additions & 0 deletions spec/boapi/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -605,4 +605,46 @@
expect(response.data).to eq(ReportFixtures.successful_create_report_response_message)
end
end

describe '.create_aggregation' do
let(:response) do
Boapi::Client.new(account_id: account_id, account_secret: account_secret).reports_aggregation(params)
end
let(:http_status) { 201 }

let(:url) { "#{Boapi.configuration.api_host}/api/v2/reports/aggregation" }

let(:params) do
{
type: 'credit_card',
language: 'en',
format: 'csv',
date_from: '2025-01-01T00:00:00+00:00',
date_to: '2025-03-16T23:59:59+00:00',
date_type: 'created_at',
group_by: nil,
transaction_parameters: {
gateway_type: %w[Bapb Bgpb],
currency: 'all',
type: %w[p2p payment capture]
}
}
end

before do
stub_request(:post, url).with(body: params.to_json)
.to_return(
status: http_status,
body: AggregationFixtures.successful_create_aggregation_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(AggregationFixtures.successful_create_aggregation_response_message)
end
end
end
62 changes: 62 additions & 0 deletions spec/fixtures/aggregation_fixtures.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# frozen_string_literal: true

# rubocop:disable Metrics/MethodLength
module AggregationFixtures
module_function

def successful_create_aggregation_response_message
{
'grouped_data' => [
{
'count' => 6,
'currency' => 'BYN',
'gateway_type' => 'Bapb',
'status' => 'successful',
'type' => 'payment',
'volume' => 5
}, {
'count' => 9,
'currency' => 'BYN',
'gateway_type' => 'Bgpb',
'status' => 'successful',
'type' => 'p2p',
'volume' => 29.23
}, {
'count' => 1,
'currency' => 'BYN',
'gateway_type' => 'Bgpb',
'status' => 'failed',
'type' => 'payment',
'volume' => 5
}, {
'count' => 1,
'currency' => 'USD',
'gateway_type' => 'Bgpb',
'status' => 'failed',
'type' => 'payment',
'volume' => 5.93
}, {
'count' => 3,
'currency' => 'BYN',
'gateway_type' => 'Bgpb',
'status' => 'incomplete',
'type' => 'p2p',
'volume' => 0.3
}, {
'count' => 57,
'currency' => 'BYN',
'gateway_type' => 'Bgpb',
'status' => 'failed',
'type' => 'p2p',
'volume' => 486.1
}
],
'total_count' => 46_892
}
end

def successful_create_aggregation_response
%({"data":#{successful_create_aggregation_response_message.to_json}})
end
end
# rubocop:enable Metrics/MethodLength
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
require 'fixtures/balance_fixtures'
require 'fixtures/balance_record_fixtures'
require 'fixtures/report_fixtures'
require 'fixtures/aggregation_fixtures'

WebMock.disable_net_connect!(allow_localhost: false)

Expand Down
Loading