From 3010dc4e0de6cb69857ffe5d05a8648b921e826e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Serge=20H=C3=A4nni?= Date: Wed, 30 Aug 2023 16:17:01 +0200 Subject: [PATCH] Add dynamic passenger types/options to the passenger API --- lib/ioki/model/passenger/passenger_option.rb | 27 ++++++++++++++++++++ lib/ioki/model/passenger/ride.rb | 1 + lib/ioki/model/passenger/ride_option.rb | 27 ++++++++++++++++++++ lib/ioki/model/passenger/ride_passenger.rb | 1 + 4 files changed, 56 insertions(+) create mode 100644 lib/ioki/model/passenger/passenger_option.rb create mode 100644 lib/ioki/model/passenger/ride_option.rb diff --git a/lib/ioki/model/passenger/passenger_option.rb b/lib/ioki/model/passenger/passenger_option.rb new file mode 100644 index 00000000..2e7ff1aa --- /dev/null +++ b/lib/ioki/model/passenger/passenger_option.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Ioki + module Model + module Passenger + 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 :localized_accessibility_information, on: :read, type: :string + attribute :localized_description, on: :read, type: :string + attribute :localized_info, on: :read, type: :string + attribute :localized_link, on: :read, type: :string + attribute :localized_link_text, on: :read, type: :string + attribute :localized_name, on: :read, type: :string + end + end + end +end diff --git a/lib/ioki/model/passenger/ride.rb b/lib/ioki/model/passenger/ride.rb index 5c7a7b3f..0197c87c 100644 --- a/lib/ioki/model/passenger/ride.rb +++ b/lib/ioki/model/passenger/ride.rb @@ -47,6 +47,7 @@ class Ride < Base attribute :fare, on: :read, type: :object, class_name: 'Fare' attribute :ticket, on: :read, type: :object, class_name: 'Ticket' attribute :offered_solutions, on: :read, type: :array, class_name: 'OfferedSolution' + attribute :options, on: :create, type: :array, class_name: 'RideOption' end end end diff --git a/lib/ioki/model/passenger/ride_option.rb b/lib/ioki/model/passenger/ride_option.rb new file mode 100644 index 00000000..5c9dd071 --- /dev/null +++ b/lib/ioki/model/passenger/ride_option.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Ioki + module Model + module Passenger + 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 :localized_accessibility_information, on: :read, type: :string + attribute :localized_description, on: :read, type: :string + attribute :localized_info, on: :read, type: :string + attribute :localized_link, on: :read, type: :string + attribute :localized_link_text, on: :read, type: :string + attribute :localized_name, on: :read, type: :string + end + end + end +end diff --git a/lib/ioki/model/passenger/ride_passenger.rb b/lib/ioki/model/passenger/ride_passenger.rb index 8cbeaec6..8ec595a6 100644 --- a/lib/ioki/model/passenger/ride_passenger.rb +++ b/lib/ioki/model/passenger/ride_passenger.rb @@ -15,6 +15,7 @@ class RidePassenger < Base attribute :type, on: [:create, :update], type: :string attribute :walker, on: [:read, :create, :update], omit_if_blank_on: [:create, :update], type: :boolean attribute :wheelchair, on: [:read, :create, :update], omit_if_blank_on: [:create, :update], type: :boolean + attribute :options, on: [:read, :create], type: :array, class_name: 'PassengerOption', omit_if_blank_on: :create end end end