Skip to content
Open
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
5 changes: 5 additions & 0 deletions lib/ioki/apis/operator_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ class OperatorApi
path: 'overview',
model_class: Ioki::Model::Operator::Vehicle
),
Endpoints::ShowSingular.new(
:vehicle_state,
base_path: [API_BASE_PATH, 'products', :id],
model_class: Ioki::Model::Operator::VehicleState
),
Endpoints::Index.new(
:permissions,
base_path: [API_BASE_PATH, 'admin'],
Expand Down
27 changes: 27 additions & 0 deletions lib/ioki/model/operator/vehicle_state.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

module Ioki
module Model
module Operator
class VehicleState < Base
attribute :type,
on: :read,
type: :string

attribute :limit_reached,
on: :read,
type: :boolean

attribute :vehicles,
on: :read,
type: :array,
class_name: 'VehicleStates::Vehicle'

attribute :resource_configurations,
on: :read,
type: :array,
class_name: 'VehicleStates::ResourceConfiguration'
end
end
end
end
123 changes: 123 additions & 0 deletions lib/ioki/model/operator/vehicle_states/resource_configuration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# frozen_string_literal: true

module Ioki
module Model
module Operator
module VehicleStates
class ResourceConfiguration < Base
attribute :type,
on: :read,
type: :string

attribute :id,
on: :read,
type: :string

attribute :created_at,
on: :read,
type: :date_time

attribute :updated_at,
on: :read,
type: :date_time

attribute :vehicle_id,
on: :read,
type: :string

attribute :name,
on: :read,
type: :string

attribute :default,
on: :read,
type: :boolean

attribute :bicycle_racks,
on: :read,
type: :integer

attribute :child_booster_seat,
on: :read,
type: :integer

attribute :child_safety_seat,
on: :read,
type: :integer

attribute :hand_luggage_storage_spaces,
on: :read,
type: :integer

attribute :medical_seats,
on: :read,
type: :integer

attribute :pet_transportation_bays,
on: :read,
type: :integer

attribute :power_plugs,
on: :read,
type: :integer

attribute :resource_1,
on: :read,
type: :integer

attribute :resource_2,
on: :read,
type: :integer

attribute :resource_3,
on: :read,
type: :integer

attribute :resource_4,
on: :read,
type: :integer

attribute :resource_5,
on: :read,
type: :integer

attribute :seats,
on: :read,
type: :integer

attribute :special_seats,
on: :read,
type: :integer

attribute :storage_spaces,
on: :read,
type: :integer

attribute :suitcase_storage_spaces,
on: :read,
type: :integer

attribute :walker_bays,
on: :read,
type: :integer

attribute :walker_storage_spaces,
on: :read,
type: :integer

attribute :wheelchair_bays,
on: :read,
type: :integer

attribute :wheelchair_storage_spaces,
on: :read,
type: :integer

attribute :wlan_access_points,
on: :read,
type: :integer
end
end
end
end
end
67 changes: 67 additions & 0 deletions lib/ioki/model/operator/vehicle_states/vehicle.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# frozen_string_literal: true

module Ioki
module Model
module Operator
module VehicleStates
class Vehicle < Base
attribute :type,
on: :read,
type: :string

attribute :id,
on: :read,
type: :string

attribute :created_at,
on: :read,
type: :date_time

attribute :updated_at,
on: :read,
type: :date_time

attribute :autonomous,
on: :read,
type: :boolean

attribute :description,
on: :read,
type: :string

attribute :external_id,
on: :read,
type: :string

attribute :fuel_type,
on: :read,
type: :string

attribute :license_plate,
on: :read,
type: :string

attribute :manufacturer,
on: :read,
type: :string

attribute :matching_rank,
on: :read,
type: :integer

attribute :model,
on: :read,
type: :string

attribute :nickname,
on: :read,
type: :string

attribute :phone_number,
on: :read,
type: :string
end
end
end
end
end
11 changes: 11 additions & 0 deletions spec/ioki/operator_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3085,4 +3085,15 @@
expect(operator_client.line_state('0815', options)).to be_a Ioki::Model::Operator::LineState
end
end

describe '#vehicle_state(product_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/vehicle_state')
[result_with_data, full_response]
end

expect(operator_client.vehicle_state('0815', options)).to be_a Ioki::Model::Operator::VehicleState
end
end
end