From df6ea1f228972f3954834862692411849e093a44 Mon Sep 17 00:00:00 2001 From: Tobias Matz Date: Tue, 9 Jun 2026 12:30:31 +0200 Subject: [PATCH 1/2] Add LineBatch model --- lib/ioki/model/operator/line_batch.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/ioki/model/operator/line_batch.rb diff --git a/lib/ioki/model/operator/line_batch.rb b/lib/ioki/model/operator/line_batch.rb new file mode 100644 index 00000000..f733a0dc --- /dev/null +++ b/lib/ioki/model/operator/line_batch.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Ioki + module Model + module Operator + class LineBatch < Base + def self.schema_path + 'operator_api--v20210101--line_batch_archive_schema' + end + + attribute :line_ids, + on: :create, + type: :array + end + end + end +end From 60ba32a69284156f0079ee0510cb3340f82030ff Mon Sep 17 00:00:00 2001 From: Tobias Matz Date: Tue, 9 Jun 2026 12:30:42 +0200 Subject: [PATCH 2/2] Add endpoints for batch deleting lines --- lib/ioki/apis/operator_api.rb | 13 +++++++++++++ spec/ioki/operator_api_spec.rb | 32 +++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/lib/ioki/apis/operator_api.rb b/lib/ioki/apis/operator_api.rb index ffdb9f9e..c8532bf2 100644 --- a/lib/ioki/apis/operator_api.rb +++ b/lib/ioki/apis/operator_api.rb @@ -763,6 +763,19 @@ class OperatorApi base_path: [API_BASE_PATH, 'providers', :id], model_class: Ioki::Model::Operator::Purchase, only: [:index, :show] + ), + Endpoints::Create.new( + :line_batch_deletion_request, + base_path: [API_BASE_PATH, 'products', :id, 'lines'], + path: 'batch_deletion_requests', + model_class: Ioki::Model::Operator::BatchDeletionRequest, + outgoing_model_class: Ioki::Model::Operator::LineBatch + ), + Endpoints::ShowSingular.new( + :line_batch_deletion_request, + base_path: nil, + path: [API_BASE_PATH, 'products', :id, 'lines', 'batch_deletion_requests', :id], + model_class: Ioki::Model::Operator::BatchDeletionRequest ) ].freeze end diff --git a/spec/ioki/operator_api_spec.rb b/spec/ioki/operator_api_spec.rb index 8a6f8374..0a3e0385 100644 --- a/spec/ioki/operator_api_spec.rb +++ b/spec/ioki/operator_api_spec.rb @@ -3286,9 +3286,8 @@ [result_with_data, full_response] end - expect(operator_client.create_vehicle_batch_deletion_request( - '0815', vehicle_batch, options - )).to be_a(Ioki::Model::Operator::BatchDeletionRequest) + expect(operator_client.create_vehicle_batch_deletion_request('0815', vehicle_batch, options)) + .to be_a(Ioki::Model::Operator::BatchDeletionRequest) end end @@ -3303,4 +3302,31 @@ .to be_a(Ioki::Model::Operator::BatchDeletionRequest) end end + + describe '#create_line_batch_deletion_request(product_id)' do + let(:line_batch) { Ioki::Model::Operator::LineBatch.new } + + it 'calls request on the client with expected params' do + expect(operator_client).to receive(:request) do |params| + expect(params[:url].to_s).to eq('operator/products/0815/lines/batch_deletion_requests') + expect(params[:method]).to eq(:post) + [result_with_data, full_response] + end + + expect(operator_client.create_line_batch_deletion_request('0815', line_batch, options)) + .to be_a(Ioki::Model::Operator::BatchDeletionRequest) + end + end + + describe '#line_batch_deletion_request(product_id, batch_deletion_request_id)' do + it 'calls request on the client with expected params' do + expect(operator_client).to receive(:request) do |params| + expect(params[:url].to_s).to eq('operator/products/0815/lines/batch_deletion_requests/4711') + [result_with_data, full_response] + end + + expect(operator_client.line_batch_deletion_request('0815', '4711', options)) + .to be_a(Ioki::Model::Operator::BatchDeletionRequest) + end + end end