Skip to content

Commit

Permalink
Fix passenger_api models
Browse files Browse the repository at this point in the history
  • Loading branch information
A5308Y committed Nov 25, 2021
1 parent c9160d8 commit d7f7da7
Show file tree
Hide file tree
Showing 51 changed files with 754 additions and 108 deletions.
16 changes: 16 additions & 0 deletions lib/ioki/model/passenger/announcement.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

module Ioki
module Model
module Passenger
class Announcement < Base
attribute :ends_at, on: :read, type: :date_time
attribute :severity, on: :read, type: :string
attribute :show_on_every_app_start, on: :read, type: :boolean
attribute :starts_at, on: :read, type: :date_time
attribute :text, on: :read, type: :string
attribute :title, on: :read, type: :string
end
end
end
end
16 changes: 16 additions & 0 deletions lib/ioki/model/passenger/area.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

module Ioki
module Model
module Passenger
class Area < Ioki::Model::Base
# Note that this does not inherit from Base because :type behaves differently here.

unvalidated true

attribute :coordinates, type: :array, on: :read
attribute :type, type: :string, on: :read
end
end
end
end
24 changes: 24 additions & 0 deletions lib/ioki/model/passenger/assistance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

module Ioki
module Model
module Passenger
class Assistance < Ioki::Model::Base
# Note that this does not inherit from Base because :created_at, :updated_at and :id are not defined.

def self.schema_path
'passenger_api--ride_inquiry--assistance'
end

def self.specification_scope
nil
end

attribute :href, on: :read, type: :string
attribute :text, on: :read, type: :string
attribute :title, on: :read, type: :string
attribute :type, on: :read, type: :string
end
end
end
end
14 changes: 14 additions & 0 deletions lib/ioki/model/passenger/availability.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module Ioki
module Model
module Passenger
class Availability < Base
unvalidated true # No specification available

attribute :available, on: :read, type: :boolean
attribute :next_availability, on: :read, type: :date_time
end
end
end
end
4 changes: 4 additions & 0 deletions lib/ioki/model/passenger/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def self.valid_models
end

class Base < Ioki::Model::Base
def self.specification_scope
'passenger_api'
end

attribute :id, on: :read, type: :string
attribute :type, on: :read, type: :string
attribute :created_at, on: :read, type: :date_time
Expand Down
4 changes: 2 additions & 2 deletions lib/ioki/model/passenger/booking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module Model
module Passenger
class Booking < Base
attribute :verification_code, type: :string, on: [:read, :update]
attribute :ride_version, type: :integer, on: :create
attribute :payment_method, type: :object, on: :create, model_class: PaymentMethod
attribute :ride_version, type: :integer, on: :create, unvalidated: true # The model does not return it but it's used when sending data to the server.
attribute :payment_method, type: :object, on: :create, model_class: PaymentMethod, unvalidated: true # The model does not return it but it's used when sending data to the server.
end
end
end
Expand Down
24 changes: 24 additions & 0 deletions lib/ioki/model/passenger/bounding_box.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

require 'ioki/model/passenger/coordinate'

module Ioki
module Model
module Passenger
class BoundingBox < Ioki::Model::Base
# Note that this does not inherit from Base because it does not implement :created_at, :updated_at, :type and :id.

def self.schema_path
'bounding_box'
end

def self.specification_scope
nil
end

attribute :min, on: :read, type: :object, model_class: Coordinate
attribute :max, on: :read, type: :object, model_class: Coordinate
end
end
end
end
38 changes: 20 additions & 18 deletions lib/ioki/model/passenger/calculated_point.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@ module Ioki
module Model
module Passenger
class CalculatedPoint < Base
attribute :city, on: :read, type: :string
attribute :country, on: :read, type: :string
attribute :county, on: :read, type: :string
attribute :display_times, on: :read, type: :array
attribute :formatted_street, on: :read, type: :string
attribute :lat, on: :read, type: :float
attribute :lng, on: :read, type: :float
attribute :location_name, on: :read, type: :string
attribute :postal_code, on: :read, type: :string
attribute :station_id, on: :read, type: :string # Not necessary anymore
attribute :street_name, on: :read, type: :string
attribute :street_number, on: :read, type: :string
attribute :time, on: :read, type: :date_time
attribute :negotiation_time, on: :read, type: :date_time
attribute :city, on: :read, type: :string
attribute :country, on: :read, type: :string
attribute :county, on: :read, type: :string
attribute :display_times, on: :read, type: :array
attribute :formatted_street, on: :read, type: :string
attribute :lat, on: :read, type: :float
attribute :lng, on: :read, type: :float
attribute :location_name, on: :read, type: :string
attribute :postal_code, on: :read, type: :string
attribute :station_id, on: :read, type: :string
attribute :street_name, on: :read, type: :string
attribute :street_number, on: :read, type: :string
attribute :time, on: :read, type: :date_time
attribute :negotiation_time, on: :read, type: :date_time
attribute :negotiation_time_max, on: :read, type: :date_time
attribute :waypoint_type, on: :read, type: :string
attribute :walking_duration, on: :read, type: :integer
attribute :walking_track, on: :read, type: :string
attribute :station, on: :read, type: :object, model_class: Station
attribute :waypoint_type, on: :read, type: :string
attribute :walking_duration, on: :read, type: :integer
attribute :walking_track, on: :read, type: :string
attribute :station, on: :read, type: :object, model_class: Station
attribute :fixed_location, on: :read, type: :boolean
attribute :pause_id, on: :read, type: :strings
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/ioki/model/passenger/cancellation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ module Ioki
module Model
module Passenger
class Cancellation < Base
attribute :ride_id, on: [:create, :read], type: :string
attribute :ride_version, on: [:create, :read], type: :integer
attribute :code, on: [:create, :read], type: :string
attribute :passenger_cancellation_reason, on: [:create, :read], type: :string
# attribute :cancellation_statement_id, type: :string
unvalidated true # Specification not available. Only used for creation.

attribute :ride_version, on: :create, type: :integer
attribute :code, on: :create, type: :string
attribute :cancellation_statement_id, on: :create, type: :string
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions lib/ioki/model/passenger/cancellation_statement.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

module Ioki
module Model
module Passenger
class CancellationStatement < Base
attribute :identifier, on: :read, type: :string
attribute :title, on: :read, type: :string
end
end
end
end
7 changes: 7 additions & 0 deletions lib/ioki/model/passenger/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ module Ioki
module Model
module Passenger
class Client < Ioki::Model::Base
# Note that this does not inherit from Base because :created_at, :updated_at and :id are not defined.

def self.specification_scope
nil
end

attribute :type, on: :read, type: :string
attribute :current_version, on: :read, type: :string
attribute :default_map_center_lat, on: :read, type: :float
attribute :default_map_center_lng, on: :read, type: :float
Expand Down
21 changes: 21 additions & 0 deletions lib/ioki/model/passenger/constraints.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'ioki/model/passenger/area'

module Ioki
module Model
module Passenger
class Constraints < Ioki::Model::Base
# Note that this does not inherit from Base because it does not implement :created_at, :updated_at, :type and :id.

unvalidated true

attribute :max_passengers, on: :read, type: :integer
attribute :max_wheelchairs, on: :read, type: :integer
attribute :max_walkers, on: :read, type: :integer
attribute :max_storage_spaces, on: :read, type: :integer
attribute :area, on: :read, type: :object, model_class: Area
end
end
end
end
15 changes: 15 additions & 0 deletions lib/ioki/model/passenger/coordinate.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Ioki
module Model
module Passenger
class Coordinate < Ioki::Model::Base
# Note that this does not inherit from Base because it does not define :created_at, :id, :type and :updated_at.
unvalidated true # No specification available.

attribute :lat, on: :read, type: :float
attribute :lng, on: :read, type: :float
end
end
end
end
5 changes: 3 additions & 2 deletions lib/ioki/model/passenger/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ module Ioki
module Model
module Passenger
class Driver < Base
attribute :connected_vehicle, type: :object, on: :read, model_class: Vehicle
attribute :display_name, type: :string, on: :read
attribute :connected_vehicle_id, on: :read, type: :string
attribute :display_name, on: :read, type: :string
attribute :version, on: :read, type: :integer
end
end
end
Expand Down
19 changes: 19 additions & 0 deletions lib/ioki/model/passenger/email.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Ioki
module Model
module Passenger
class Email < Ioki::Model::Base
def self.specification_scope
'passenger_api'
end

attribute :type, on: :read, type: :string
attribute :confirmed, on: :read, type: :boolean
attribute :email_address, on: [:read, :update], type: :string
attribute :newsletter, on: :read, type: :boolean
attribute :receipt, on: :read, type: :boolean
end
end
end
end
28 changes: 28 additions & 0 deletions lib/ioki/model/passenger/estimation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

require 'ioki/model/passenger/calculated_point'

module Ioki
module Model
module Passenger
class Estimation < Ioki::Model::Base
# Note that this does not inherit from Base because it does not implement :created_at, :updated_at and :id.

def self.specification_scope
nil
end

def self.schema_path
'passenger_api--ride_inquiry--estimation'
end

attribute :type, on: :read, type: :string
attribute :confidence, on: :read, type: :float
attribute :dropoff, on: :read, type: :object, model_class: CalculatedPoint
attribute :estimation_type, on: :read, type: :string
attribute :meta_data, on: :read, type: :object # Quote from the API docs: "Additional metadata about the estimation, no specified format (yet)"
attribute :pickup, on: :read, type: :object, model_class: CalculatedPoint
end
end
end
end
18 changes: 18 additions & 0 deletions lib/ioki/model/passenger/fare.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

require 'ioki/model/passenger/money'
require 'ioki/model/passenger/personal_discount'

module Ioki
module Model
module Passenger
class Fare < Base
attribute :booking_price_object, on: :read, type: :object, model_class: Money
attribute :booking_price_type, on: :read, type: :string
attribute :final_price_object, on: :read, type: :object, model_class: Money
attribute :personal_discount, on: :read, type: :object, model_class: PersonalDiscount
attribute :version, on: :read, type: :integer
end
end
end
end
2 changes: 2 additions & 0 deletions lib/ioki/model/passenger/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module Ioki
module Model
module Passenger
class Features < Base
unvalidated true # Specification not available

attribute :analytics_tracking, type: :boolean, on: :read
attribute :failed_payment_handling, type: :boolean, on: :read
attribute :marketing_automation, type: :boolean, on: :read
Expand Down
13 changes: 13 additions & 0 deletions lib/ioki/model/passenger/image_upload.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'ioki/model/passenger/image_version'

module Ioki
module Model
module Passenger
class ImageUpload < Base
attribute :versions, on: :read, type: :array, model_class: ImageVersion
end
end
end
end
16 changes: 16 additions & 0 deletions lib/ioki/model/passenger/image_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

module Ioki
module Model
module Passenger
class ImageVersion < Base
unvalidated true # Specification not available

attribute :large, on: :read, type: :string
attribute :medium, on: :read, type: :string
attribute :small, on: :read, type: :string
attribute :mini, on: :read, type: :string
end
end
end
end
14 changes: 14 additions & 0 deletions lib/ioki/model/passenger/mobile_ticket_data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module Ioki
module Model
module Passenger
class MobileTicketData < Base
unvalidated true # Specification not available.

attribute :purchase_id, on: :read, type: :string
attribute :customer_code, on: :read, type: :string
end
end
end
end
Loading

0 comments on commit d7f7da7

Please sign in to comment.