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
13 changes: 13 additions & 0 deletions lib/ioki/apis/operator_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,19 @@ class OperatorApi
path: [API_BASE_PATH, 'products', :id, 'stations', 'batch_deletion_requests', :id],
model_class: Ioki::Model::Operator::BatchDeletionRequest
),
Endpoints::Create.new(
:vehicle_batch_deletion_request,
base_path: [API_BASE_PATH, 'products', :id, 'vehicles'],
path: 'batch_deletion_requests',
model_class: Ioki::Model::Operator::BatchDeletionRequest,
outgoing_model_class: Ioki::Model::Operator::VehicleBatch
),
Endpoints::ShowSingular.new(
:vehicle_batch_deletion_request,
base_path: nil,
path: [API_BASE_PATH, 'products', :id, 'vehicles', 'batch_deletion_requests', :id],
model_class: Ioki::Model::Operator::BatchDeletionRequest
),
Endpoints.crud_endpoints(
:purchase,
base_path: [API_BASE_PATH, 'providers', :id],
Expand Down
17 changes: 17 additions & 0 deletions lib/ioki/model/operator/vehicle_batch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Ioki
module Model
module Operator
class VehicleBatch < Base
def self.schema_path
'operator_api--v20210101--vehicle_batch_archive_schema'
end

attribute :vehicle_ids,
on: :create,
type: :array
end
end
end
end
28 changes: 28 additions & 0 deletions spec/ioki/operator_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3217,4 +3217,32 @@
expect(operator_client.line_state('0815', options)).to be_a Ioki::Model::Operator::LineState
end
end

describe '#create_vehicle_batch_deletion_request(product_id)' do
let(:vehicle_batch) { Ioki::Model::Operator::VehicleBatch.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/vehicles/batch_deletion_requests')
expect(params[:method]).to eq(:post)
[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)
end
end

describe '#vehicle_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/vehicles/batch_deletion_requests/4711')
[result_with_data, full_response]
end

expect(operator_client.vehicle_batch_deletion_request('0815', '4711', options))
.to be_a(Ioki::Model::Operator::BatchDeletionRequest)
end
end
end