Skip to content

Commit

Permalink
Add dynamic passenger types/options to the platform API
Browse files Browse the repository at this point in the history
  • Loading branch information
phylor committed Sep 5, 2023
1 parent dffab1b commit 7bc870e
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/ioki/model/platform/multilanguage_string.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module Ioki
module Model
module Platform
class MultilanguageString < Base
attribute :type, on: :read, type: :string
attribute :name, on: :read, type: :string
attribute :translations, on: :read, type: :array, class_name: 'Translation'
end
end
end
end
26 changes: 26 additions & 0 deletions lib/ioki/model/platform/passenger_option.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

module Ioki
module Model
module Platform
class PassengerOption < Base
attribute :name, on: [:read, :create], type: :string
attribute :value, on: :create, type: :string # could also be a boolean or an integer

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 :bookable, on: :read, type: :boolean
attribute :data_type, on: :read, type: :string
attribute :option_type, on: :read, type: :string
attribute :name_translations, on: :read, type: :object, class_name: 'MultilanguageString'
attribute :description_translations, on: :read, type: :object, class_name: 'MultilanguageString'
attribute :info_translations, on: :read, type: :object, class_name: 'MultilanguageString'
attribute :link_translations, on: :read, type: :object, class_name: 'MultilanguageString'
attribute :link_text_translations, on: :read, type: :object, class_name: 'MultilanguageString'
end
end
end
end
13 changes: 13 additions & 0 deletions lib/ioki/model/platform/passenger_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ class PassengerType < Base
unvalidated true # Specification not available.

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 :bookable, on: :read, type: :boolean
attribute :name, on: :read, type: :string
attribute :slug, on: :read, type: :string
attribute :option_type, on: :read, type: :string
attribute :name_translations, on: :read, type: :object, class_name: 'MultilanguageString'
attribute :description_translations, on: :read, type: :object, class_name: 'MultilanguageString'
attribute :info_translations, on: :read, type: :object, class_name: 'MultilanguageString'
attribute :link_translations, on: :read, type: :object, class_name: 'MultilanguageString'
attribute :link_text_translations, on: :read, type: :object, class_name: 'MultilanguageString'
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/ioki/model/platform/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class Product < Base
attribute :prebookable, on: :read, type: :boolean
attribute :provider, type: :object, on: :read, class_name: 'Provider'
attribute :ride_options, on: :read, type: :object, class_name: 'RideOptions'
attribute :passenger_options, on: :read, type: :array, class_name: 'PassengerOption'
attribute :passenger_types, on: :read, type: :array, class_name: 'PassengerType'
attribute :product_ride_options, on: :read, type: :array, class_name: 'RideOption'
attribute :ride_rating_criteria, on: :read, type: :array
attribute :service_time_info, on: :read, type: :string
attribute :timezone, on: :read, type: :object, class_name: 'Timezone'
Expand Down
1 change: 1 addition & 0 deletions lib/ioki/model/platform/ride.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Ride < Base
attribute :estimated_direct_duration, on: :read, type: :integer
attribute :fare, on: :read, type: :object, class_name: 'Fare'
attribute :needs_cancellation_code, on: :read, type: :boolean
attribute :options, type: :array, on: [:create, :read], class_name: 'RideOption'
attribute :origin, type: :object, on: [:create, :read], class_name: 'RequestedPoint'
attribute :passenger_can_be_called, on: :read, type: :boolean
attribute :passengers, type: :array, on: [:create, :read], class_name: 'RidePassenger'
Expand Down
26 changes: 26 additions & 0 deletions lib/ioki/model/platform/ride_option.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

module Ioki
module Model
module Platform
class RideOption < Base
attribute :name, on: [:read, :create], type: :string
attribute :value, on: :create, type: :string # could also be a boolean or an integer

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 :bookable, on: :read, type: :boolean
attribute :data_type, on: :read, type: :string
attribute :option_type, on: :read, type: :string
attribute :name_translations, on: :read, type: :object, class_name: 'MultilanguageString'
attribute :description_translations, on: :read, type: :object, class_name: 'MultilanguageString'
attribute :info_translations, on: :read, type: :object, class_name: 'MultilanguageString'
attribute :link_translations, on: :read, type: :object, class_name: 'MultilanguageString'
attribute :link_text_translations, on: :read, type: :object, class_name: 'MultilanguageString'
end
end
end
end
1 change: 1 addition & 0 deletions lib/ioki/model/platform/ride_passenger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class RidePassenger < Base
attribute :public_transport_ticket, type: :boolean, on: [:create, :update], omit_if_blank_on: [:create, :update]
attribute :walker, type: :boolean, on: [:create, :update], omit_if_blank_on: [:create, :update]
attribute :wheelchair, type: :boolean, on: [:create, :update], omit_if_blank_on: [:create, :update]
attribute :options, on: [:read, :create], type: :array, class_name: 'PassengerOption'
end
end
end
Expand Down
13 changes: 13 additions & 0 deletions lib/ioki/model/platform/translation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module Ioki
module Model
module Platform
class Translation < Base
attribute :type, on: :read, type: :string
attribute :language, on: :read, type: :string
attribute :text, on: :read, type: :string
end
end
end
end

0 comments on commit 7bc870e

Please sign in to comment.