feat(merchants): add raw data import (csv) for merchants (#1992)

* feat(merchants): add csv import endpoint for merchants

* docs: update endpoint docs

* fix(merchant): recommended ai fixes
This commit is contained in:
Blaž Dular
2026-06-06 16:33:32 +02:00
committed by GitHub
parent d88d6e9e58
commit 94422955f8
18 changed files with 512 additions and 37 deletions
+37
View File
@@ -47,6 +47,43 @@ RSpec.describe 'API V1 Merchants', type: :request do
run_test!
end
end
post 'Import merchants from CSV' do
tags 'Merchants'
security [ { apiKeyAuth: [] } ]
consumes 'multipart/form-data'
produces 'application/json'
parameter name: :file, in: :formData, type: :file, required: true,
description: 'CSV file with columns: name* (required), color, website_url'
response '201', 'merchants imported' do
schema '$ref' => '#/components/schemas/MerchantImportResult'
let(:file) do
Rack::Test::UploadedFile.new(
StringIO.new("name,color,website_url\nCoffee Shop,#e99537,https://coffeeshop.com"),
'text/csv',
true,
original_filename: 'merchants.csv'
)
end
run_test!
end
response '401', 'unauthorized' do
schema '$ref' => '#/components/schemas/ErrorResponse'
let(:'X-Api-Key') { nil }
run_test!
end
response '422', 'missing file or invalid CSV' do
schema '$ref' => '#/components/schemas/ErrorResponse'
let(:file) { nil }
run_test!
end
end
end
path '/api/v1/merchants/{id}' do
+9
View File
@@ -571,6 +571,15 @@ RSpec.configure do |config|
updated_at: { type: :string, format: :'date-time' }
}
},
MerchantImportResult: {
type: :object,
required: %w[imported skipped merchants],
properties: {
imported: { type: :integer, description: 'Number of merchants successfully created' },
skipped: { type: :integer, description: 'Number of rows skipped (duplicates or invalid)' },
merchants: { type: :array, items: { '$ref' => '#/components/schemas/MerchantDetail' } }
}
},
Tag: {
type: :object,
required: %w[id name color],