diff --git a/README.md b/README.md index c8c59b7..73f4c64 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ response = client.transactions_list(params) response.status # 200 response.success? # true response.data -# {"pagination"=>{"date_from"=>"2023-02-20T09:02:54.516000Z", "date_to"=>"2023-02-20T09:02:54.516000Z", "date_type"=>"created_at", "has_next_page"=>true, "next_date"=>"2023-02-20T09:36:15.175000Z"}, "transactions"=>[{"amount"=>123, "created_at"=>"2023-02-270T09:12:54.516000Z", "currency"=>"trx_cur", "merchant_id"=>123, "paid_at"=>"2023-02-12T09:02:59.669000Z", "shop_id"=>123, "status"=>"trx_status", "type"=>"trx_type", "uid"=>"xxxxxxx-fa21-xxxx-xxxx-xxxxeec8661f"}ruby +# {"pagination"=>{"date_from"=>"2023-02-20T09:02:54.516000Z", "date_to"=>"2023-02-20T09:02:54.516000Z", "date_type"=>"created_at", "has_next_page"=>true, "next_date"=>"2023-02-20T09:36:15.175000Z"}, "transactions"=>[{"amount"=>123, "created_at"=>"2023-02-270T09:12:54.516000Z", "currency"=>"trx_cur", "merchant_id"=>123, "paid_at"=>"2023-02-12T09:02:59.669000Z", "shop_id"=>123, "status"=>"trx_status", "type"=>"trx_type", "uid"=>"xxxxxxx-fa21-xxxx-xxxx-xxxxeec8661f"} ``` Transactions list with response params @@ -111,6 +111,17 @@ response.data # {"pagination"=>{"date_from"=>"2023-02-20T09:02:59.669000Z", "date_to"=>"2023-02-20T09:02:59.669000Z", "date_type"=>"paid_at", "has_next_page"=>true, "next_date"=>"2023-02-20T09:36:15.994000Z"}, "transactions"=>[{"paid_at"=>"2023-02-20T09:12:34.567000Z", "provider_raw"=>{"ref_id"=>nil}, "shop_id"=>123, "uid"=>"e4800e1b-xxxx-xxxx-ae25-16f1xxxx661f"}]} ``` +Transactions export with response params + +```ruby +params = { response_parameters: "main", filter: { date_from: '2024-11-01T00:00:00.000000', date_to: '2024-11-02T00:00:00.000000', date_type: 'created_at', type: 'p2p' }, options: { limit: 1, sort_direction: 'desc' } } +response = client.transactions_export(params) +response.status # 200 +response.success? # true +response.data +# {"data":{"pagination":{"date_type":"created_at","has_next_page":false,"date_from":"2024-11-01T08:58:46.705000Z","date_to":"2024-11-01T08:58:46.705000Z","uid_from":"6ca3d635-6841-4ac9-b583-a3bf0eafc160","uid_to":"6ca3d635-6841-4ac9-b583-a3bf0eafc160"},"transactions":[{"amount":100,"closed_at":null,"code":"S.0000","converted_amount":null,"converted_currency":null,"created_at":"2024-11-01T08:58:46.705000Z","currency":"BYN","description":"Testtransactionp2psLAA","expired_at":null,"fraud":"","friendly_message":"Транзакцияпроведенауспешно.","language":"ru","manually_corrected_at":null,"merchant_id":55,"message":"Successfullyprocessed","paid_at":"2024-11-01T08:58:50.589000Z","parent_uid":null,"product_id":null,"reason":null,"recurring_type":null,"settled_at":null,"shop_id":1990,"status":"successful","subscription_id":null,"test":false,"tracking_id":"tracking_id_000","type":"p2p","uid":"6ca3d635-6841-4ac9-b583-a3bf0eafc160","updated_at":"2024-11-01T08:58:50.644000Z"}]}} +``` + Create rate ```ruby diff --git a/lib/boapi/client.rb b/lib/boapi/client.rb index 26e8d18..3b055f8 100644 --- a/lib/boapi/client.rb +++ b/lib/boapi/client.rb @@ -36,6 +36,10 @@ def transactions_deep_search(params) send_request(:post, '/api/v2/transactions/deep_search', params) end + def transactions_export(params) + send_request(:post, '/api/v2/transactions/export', params) + end + def merchant_balances_for_psp(merchant_id, params) send_request(:get, "/api/v2/psp/merchants/#{merchant_id}/balances", params) end diff --git a/spec/boapi/client_spec.rb b/spec/boapi/client_spec.rb index 572b8b7..fd83149 100644 --- a/spec/boapi/client_spec.rb +++ b/spec/boapi/client_spec.rb @@ -193,6 +193,44 @@ end end + describe '.transactions_export' do + let(:response) do + Boapi::Client.new(account_id: account_id, account_secret: account_secret).transactions_export(params) + end + + let(:url) { "#{Boapi.configuration.api_host}/api/v2/transactions/export" } + + context 'when valid params given' do + let(:params) do + { + filter: { + status: 'successful', + date_from: '2024-11-01T00:00:00.000000', + date_to: '2024-11-02T00:00:00.000000', + 'type': 'p2p' + }, + options: { + limit: 1 + } + } + end + let(:http_status) { 200 } + + before do + stub_request(:post, url) + .to_return(status: http_status, body: TransactionFixtures.successful_transactions_export_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(TransactionFixtures.successful_transactions_export_response_message) + end + end + end + describe '.merchant_balances_for_psp' do let(:response) do Boapi::Client.new(account_id: account_id, account_secret: account_secret) diff --git a/spec/fixtures/transaction_fixtures.rb b/spec/fixtures/transaction_fixtures.rb index 9e02ce1..ceeb9d2 100644 --- a/spec/fixtures/transaction_fixtures.rb +++ b/spec/fixtures/transaction_fixtures.rb @@ -45,4 +45,34 @@ def successful_transactions_list_response_message def successful_transactions_list_response %({"data":#{successful_transactions_list_response_message.to_json}}) end + + # rubocop:disable Metrics/MethodLength + def successful_transactions_export_response_message + { + 'transactions' => [ + { + 'amount' => 100, 'closed_at' => nil, 'code' => 'S.0000', 'converted_amount' => nil, + 'converted_currency' => nil, 'created_at' => '2024-11-01T08:58:46.705000Z', 'currency' => 'BYN', + 'description' => 'Test transaction p2ps LAA', 'expired_at' => nil, 'fraud' => '', + 'friendly_message' => 'Транзакция проведена успешно.', 'language' => 'ru', + 'manually_corrected_at' => nil, 'merchant_id' => 55, 'message' => 'Successfully processed', + 'paid_at' => '2024-11-01T08:58:50.589000Z', 'parent_uid' => nil, 'product_id' => nil, + 'reason' => nil, 'recurring_type' => nil, 'settled_at' => nil, 'shop_id' => 1990, + 'status' => 'successful', 'subscription_id' => nil, 'test' => false, + 'tracking_id' => 'tracking_id_000', 'type' => 'p2p', 'uid' => '6ca3d635-6841-4ac9-b583-a3bf0eafc160', + 'updated_at' => '2024-11-01T08:58:50.644000Z' + } + ], + 'pagination' => { + 'date_type' => 'created_at', 'has_next_page' => false, 'date_from' => '2024-11-01T08:58:46.705000Z', + 'date_to' => '2024-11-01T08:58:46.705000Z', 'uid_from' => '6ca3d635-6841-4ac9-b583-a3bf0eafc160', + 'uid_to' => '6ca3d635-6841-4ac9-b583-a3bf0eafc160' + } + } + end + # rubocop:enable Metrics/MethodLength + + def successful_transactions_export_response + %({"data":#{successful_transactions_export_response_message.to_json}}) + end end