Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operator Api | Refine operator models #128

Merged
merged 6 commits into from
Sep 20, 2022
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
26 changes: 13 additions & 13 deletions lib/ioki/model/operator/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,37 @@ class Driver < Base
type: :string

attribute :first_name,
on: [:create, :read, :update],
omit_if_blank_on: [:create, :update],
type: :string
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :last_name,
on: [:create, :read, :update],
omit_if_blank_on: [:create, :update],
type: :string
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :locale,
on: [:create, :read, :update],
omit_if_blank_on: [:create, :read],
omit_if_nil_on: [:create, :update],
omit_if_blank_on: [:create, :update],
type: :string

attribute :locked_at,
on: :read,
type: :date_time

attribute :phone_number,
on: [:create, :read, :update],
omit_if_blank_on: [:create, :read],
type: :string
on: [:create, :read, :update],
type: :string

attribute :pin,
on: :read,
type: :string

attribute :username,
on: [:create, :read, :update],
omit_if_blank_on: [:create, :update],
type: :string
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :version,
on: :read,
Expand Down
25 changes: 15 additions & 10 deletions lib/ioki/model/operator/place.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,33 @@ class Place < Base
type: :string

attribute :description,
on: [:create, :read, :update],
type: :string
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :lat,
on: [:create, :read, :update],
type: :float
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :float

attribute :lng,
on: [:create, :read, :update],
type: :float
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :float

attribute :location_name,
on: [:create, :read, :update],
type: :string
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :postal_code,
on: [:create, :read, :update],
type: :string

attribute :slug,
on: [:create, :read, :update],
type: :string
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :street_name,
on: [:create, :read, :update],
Expand Down
88 changes: 40 additions & 48 deletions lib/ioki/model/operator/station.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,95 +25,87 @@ class Station < Base
type: :boolean

attribute :boarding_time,
on: [:read, :create, :update],
omit_if_blank_on: [:create, :update],
type: :integer
on: [:read, :create, :update],
type: :integer

attribute :city,
on: [:read, :create, :update],
omit_if_blank_on: [:create, :update],
type: :string
on: [:read, :create, :update],
type: :string

attribute :country,
on: [:read, :create, :update],
omit_if_blank_on: [:create, :update],
type: :string
on: [:read, :create, :update],
type: :string

attribute :county,
on: [:read, :create, :update],
omit_if_blank_on: [:create, :update],
type: :string
on: [:read, :create, :update],
type: :string

attribute :deactivations,
on: :read,
type: :array,
class_name: 'Deactivation'

attribute :description,
on: [:read, :create, :update],
omit_if_blank_on: [:create, :update],
type: :string
on: [:read, :create, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :dhid,
on: [:read, :create, :update],
omit_if_blank_on: [:create, :update],
type: :string
on: [:read, :create, :update],
type: :string

attribute :fixed,
on: :read,
type: :boolean

attribute :lat,
on: [:read, :create, :update],
type: :float
on: [:read, :create, :update],
omit_if_nil_on: [:create, :update],
type: :float

attribute :lng,
on: [:read, :create, :update],
type: :float
on: [:read, :create, :update],
omit_if_nil_on: [:create, :update],
type: :float

attribute :location_name,
on: [:read, :create, :update],
type: :string
on: [:read, :create, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :parking_time,
on: [:read, :create, :update],
omit_if_blank_on: [:create, :update],
type: :integer
on: [:read, :create, :update],
type: :integer

attribute :postal_code,
on: [:read, :create, :update],
omit_if_blank_on: [:create, :update],
type: :string
on: [:read, :create, :update],
type: :string

attribute :station_type,
on: [:read, :create, :update],
omit_if_blank_on: [:create, :update],
type: :string
on: [:read, :create, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :street_name,
on: [:read, :create, :update],
omit_if_blank_on: [:create, :update],
type: :string
on: [:read, :create, :update],
type: :string

attribute :street_number,
on: [:read, :create, :update],
omit_if_blank_on: [:create, :update],
type: :string
on: [:read, :create, :update],
type: :string

attribute :tariff_codes,
on: [:read, :create, :update],
omit_if_blank_on: [:create, :update],
type: :array
on: [:read, :create, :update],
omit_if_nil_on: [:create, :update],
type: :array

attribute :walker_boarding_time,
on: [:read, :create, :update],
omit_if_blank_on: [:create, :update],
type: :integer
on: [:read, :create, :update],
type: :integer

attribute :wheelchair_boarding_time,
on: [:read, :create, :update],
omit_if_blank_on: [:create, :update],
type: :integer
on: [:read, :create, :update],
type: :integer
end
end
end
Expand Down
59 changes: 29 additions & 30 deletions lib/ioki/model/operator/task_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ class TaskList < Base
type: :date_time

attribute :ad_hoc_bookable,
on: [:create, :read, :update],
type: :boolean
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :boolean

attribute :deactivated,
on: :read,
Expand All @@ -42,33 +43,32 @@ class TaskList < Base
class_name: %w[Place Station]

attribute :end_location_id,
on: [:create, :read, :update],
omit_if_nil_on: :read,
type: :string
on: [:create, :read, :update],
type: :string

attribute :end_location_type,
on: [:create, :read, :update],
omit_if_nil_on: :read,
type: :string
on: [:create, :read, :update],
type: :string

attribute :ends_at,
on: [:create, :read, :update],
omit_if_nil_on: :read,
omit_if_nil_on: [:create, :update],
type: :date_time

attribute :matching_configuration_id,
on: [:create, :read, :update],
type: :string
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :paused,
on: :read,
type: :boolean

attribute :pauses,
on: [:read, :create],
omit_if_blank_on: [:create],
type: :array,
class_name: 'Pause'
on: [:read, :create],
omit_if_nil_on: [:create],
type: :array,
class_name: 'Pause'

attribute :planned_ends_at,
on: :read,
Expand All @@ -79,8 +79,9 @@ class TaskList < Base
type: :date_time

attribute :prebookable,
on: [:create, :read, :update],
type: :boolean
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :boolean

attribute :start_location,
on: :read,
Expand All @@ -89,30 +90,28 @@ class TaskList < Base

attribute :start_location_id,
on: [:create, :read, :update],
omit_if_nil_on: :read,
omit_if_nil_on: [:create, :update],
type: :string

attribute :start_location_type,
on: [:create, :read, :update],
omit_if_blank_on: :read,
type: :string
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :starts_at,
on: [:create, :read, :update],
omit_if_nil_on: :read,
omit_if_nil_on: [:create, :update],
type: :date_time

attribute :state,
on: [:create, :read, :update],
type: :string

attribute :state_options,
on: :read,
type: :array
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :vehicle_id,
on: [:create, :read, :reassign],
type: :string
on: [:create, :read, :reassign],
omit_if_nil_on: [:create, :reassign],
type: :string
end
end
end
Expand Down
15 changes: 9 additions & 6 deletions lib/ioki/model/operator/vehicle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ class Vehicle < Base
type: :string

attribute :fuel_type,
on: [:create, :read, :update],
type: :string
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :last_known_position,
on: :read,
type: :object,
class_name: 'VehiclePosition'

attribute :license_plate,
on: [:create, :read, :update],
type: :string
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :manufacturer,
on: [:create, :read, :update],
Expand All @@ -63,8 +65,9 @@ class Vehicle < Base
type: :string

attribute :nickname,
on: [:create, :read, :update],
type: :string
on: [:create, :read, :update],
omit_if_nil_on: [:create, :update],
type: :string

attribute :phone_number,
on: [:create, :read, :update],
Expand Down
1 change: 0 additions & 1 deletion spec/ioki/model/operator/task_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
it { is_expected.to define_attribute(:start_location_type).as(:string) }
it { is_expected.to define_attribute(:starts_at).as(:date_time) }
it { is_expected.to define_attribute(:state).as(:string) }
it { is_expected.to define_attribute(:state_options).as(:array) }
it { is_expected.to define_attribute(:vehicle_id).as(:string) }
end

Expand Down