Skip to content

Commit

Permalink
Merge pull request #377 from ioki-mobility/add-vehicle-telemetry-to-f…
Browse files Browse the repository at this point in the history
…leet-state

Operator Api | Add `VehicleTelemetry` model
  • Loading branch information
tom-ioki committed May 7, 2024
2 parents 861838e + a8b42e0 commit c594689
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lib/ioki/model/operator/telemetry.rb
@@ -0,0 +1,33 @@
# frozen_string_literal: true

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

attribute :battery_level,
on: :read,
type: :float

attribute :remaining_distance,
on: :read,
type: :float

attribute :charging_state,
on: :read,
type: :string

attribute :estimated_time_until_full_recharge,
on: :read,
type: :float

attribute :last_synced_at,
on: :read,
type: :date_time
end
end
end
end
5 changes: 5 additions & 0 deletions lib/ioki/model/operator/vehicle.rb
Expand Up @@ -126,6 +126,11 @@ class Vehicle < Base
omit_if_nil_on: [:create, :update],
type: :integer

attribute :telemetry,
on: :read,
type: :object,
class_name: 'Telemetry'

attribute :version,
on: [:update, :read],
omit_if_nil_on: [:update],
Expand Down
10 changes: 10 additions & 0 deletions spec/ioki/model/operator/telemetry_spec.rb
@@ -0,0 +1,10 @@
# frozen_string_literal: true

RSpec.describe Ioki::Model::Operator::Telemetry do
it { is_expected.to define_attribute(:id).as(:string) }
it { is_expected.to define_attribute(:battery_level).as(:float) }
it { is_expected.to define_attribute(:remaining_distance).as(:float) }
it { is_expected.to define_attribute(:charging_state).as(:string) }
it { is_expected.to define_attribute(:estimated_time_until_full_recharge).as(:float) }
it { is_expected.to define_attribute(:last_synced_at).as(:date_time) }
end
1 change: 1 addition & 0 deletions spec/ioki/model/operator/vehicle_spec.rb
Expand Up @@ -33,4 +33,5 @@
it { is_expected.to define_attribute(:storage_spaces).as(:integer) }
it { is_expected.to define_attribute(:walker_bays).as(:integer) }
it { is_expected.to define_attribute(:wheelchair_bays).as(:integer) }
it { is_expected.to define_attribute(:telemetry).as(:object).with(class_name: 'Telemetry') }
end

0 comments on commit c594689

Please sign in to comment.