From 7bc870ecdaad60d83e8969b2508dc0f104fc42f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serge=20H=C3=A4nni?= Date: Thu, 6 Jul 2023 15:02:28 +0200 Subject: [PATCH] Add dynamic passenger types/options to the platform API --- .../model/platform/multilanguage_string.rb | 13 ++++++++++ lib/ioki/model/platform/passenger_option.rb | 26 +++++++++++++++++++ lib/ioki/model/platform/passenger_type.rb | 13 ++++++++++ lib/ioki/model/platform/product.rb | 3 +++ lib/ioki/model/platform/ride.rb | 1 + lib/ioki/model/platform/ride_option.rb | 26 +++++++++++++++++++ lib/ioki/model/platform/ride_passenger.rb | 1 + lib/ioki/model/platform/translation.rb | 13 ++++++++++ 8 files changed, 96 insertions(+) create mode 100644 lib/ioki/model/platform/multilanguage_string.rb create mode 100644 lib/ioki/model/platform/passenger_option.rb create mode 100644 lib/ioki/model/platform/ride_option.rb create mode 100644 lib/ioki/model/platform/translation.rb diff --git a/lib/ioki/model/platform/multilanguage_string.rb b/lib/ioki/model/platform/multilanguage_string.rb new file mode 100644 index 00000000..aee5c82b --- /dev/null +++ b/lib/ioki/model/platform/multilanguage_string.rb @@ -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 diff --git a/lib/ioki/model/platform/passenger_option.rb b/lib/ioki/model/platform/passenger_option.rb new file mode 100644 index 00000000..e1451fea --- /dev/null +++ b/lib/ioki/model/platform/passenger_option.rb @@ -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 diff --git a/lib/ioki/model/platform/passenger_type.rb b/lib/ioki/model/platform/passenger_type.rb index 23be47a9..7459acac 100644 --- a/lib/ioki/model/platform/passenger_type.rb +++ b/lib/ioki/model/platform/passenger_type.rb @@ -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 diff --git a/lib/ioki/model/platform/product.rb b/lib/ioki/model/platform/product.rb index 33084aad..8c405c34 100644 --- a/lib/ioki/model/platform/product.rb +++ b/lib/ioki/model/platform/product.rb @@ -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' diff --git a/lib/ioki/model/platform/ride.rb b/lib/ioki/model/platform/ride.rb index 6ef51c4f..6aa641d9 100644 --- a/lib/ioki/model/platform/ride.rb +++ b/lib/ioki/model/platform/ride.rb @@ -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' diff --git a/lib/ioki/model/platform/ride_option.rb b/lib/ioki/model/platform/ride_option.rb new file mode 100644 index 00000000..7f25a872 --- /dev/null +++ b/lib/ioki/model/platform/ride_option.rb @@ -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 diff --git a/lib/ioki/model/platform/ride_passenger.rb b/lib/ioki/model/platform/ride_passenger.rb index 8c5456ec..f4f32c2a 100644 --- a/lib/ioki/model/platform/ride_passenger.rb +++ b/lib/ioki/model/platform/ride_passenger.rb @@ -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 diff --git a/lib/ioki/model/platform/translation.rb b/lib/ioki/model/platform/translation.rb new file mode 100644 index 00000000..a7f18923 --- /dev/null +++ b/lib/ioki/model/platform/translation.rb @@ -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