Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
A5308Y committed Dec 1, 2021
1 parent efc11df commit 5daf628
Show file tree
Hide file tree
Showing 20 changed files with 1,279 additions and 954 deletions.
4 changes: 3 additions & 1 deletion lib/ioki/model/passenger/features.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'ioki/model/passenger/minimum_age_confirmation'

module Ioki
module Model
module Passenger
Expand All @@ -11,7 +13,7 @@ class Features < Ioki::Model::Base
attribute :analytics_tracking, type: :boolean, on: :read
attribute :failed_payment_handling, type: :boolean, on: :read
attribute :marketing_automation, type: :boolean, on: :read
attribute :minimum_age_confirmation, type: :boolean, on: :read
attribute :minimum_age_confirmation, type: :object, on: :read, model_class: MinimumAgeConfirmation
attribute :newsletter, type: :boolean, on: :read
attribute :non_purchasable_personal_discounts, type: :boolean, on: :read
attribute :payment, type: :boolean, on: :read
Expand Down
15 changes: 15 additions & 0 deletions lib/ioki/model/passenger/minimum_age_confirmation.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 MinimumAgeConfirmation < Ioki::Model::Base
# Note that this does not inherit from Base because it does not define :id, :type, :created_at and :updated_at.

unvalidated true # No specification available.

attribute :minimum_age, on: :read, type: :integer
end
end
end
end
1 change: 1 addition & 0 deletions lib/ioki/model/passenger/ride_inquiry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module Passenger
class RideInquiry < Base
attribute :origin, type: :object, on: :create, model_class: RequestedPoint, unvalidated: true # The model does not return it but it's used when sending data to the server.
attribute :destination, type: :object, on: :create, model_class: RequestedPoint, unvalidated: true # The model does not return it but it's used when sending data to the server.
attribute :product_id, type: :string, on: :create, unvalidated: true # The model does not return it but it's used when sending data to the server.
attribute :assistances, on: :read, type: :array, model_class: Assistance
attribute :availability, on: :read, type: :object, model_class: Availability
attribute :constraints, on: :read, type: :object, model_class: Constraints
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

48 changes: 28 additions & 20 deletions spec/ioki/model/models_without_open_api_specifications_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

RSpec.describe 'models without open api specifications', vcr: { record: :all } do
RSpec.describe 'models without open api specifications', :vcr do
describe 'platform_api models' do
setup_platform_client(:platform_client)
let(:product) { platform_client.products.first }
Expand Down Expand Up @@ -89,7 +89,7 @@
before do
passenger_client.config.api_token = platform_client.create_request_token(
platform_client.providers.first,
platform_client.users(platform_client.providers.first).first,
platform_client.users(platform_client.providers.first).last,
Ioki::Model::Platform::PassengerRequestToken.new(
client_identifier: 'dev.passengerapi.test.backend'
)
Expand Down Expand Up @@ -159,45 +159,53 @@
it 'has data for all defined attributes' do
expect(passenger_client.rides(product).first.route).to be_a(Ioki::Model::Passenger::Route)
expect(passenger_client.rides(product).first.route.track).to be_a(String)
pending('Needs a ride with a ticket that has a ticket with mobile_ticket_data')
expect(passenger_client.rides(product).first.ticket.mobile_ticket_data).to be_a(Ioki::Model::Passenger::MobileTicketData)
pending('Needs a ride with a ticket that has mobile_ticket_data')
expect(passenger_client.rides(product).first.ticket.mobile_ticket_data.purchase_id).to be_a(String)
expect(passenger_client.rides(product).first.ticket.mobile_ticket_data.customer_code).to be_a(String)
end

it 'cancellation' do
pending('cancellation.rb -> cancel outgoing model only')
skip('cancellation.rb -> cancel outgoing model only')
end
end

describe 'models accessible on the ride_inqury creation endpoint' do
let(:ride_inqury) do
Ioki::Model::Passenger::RideInquiry.new(origin: { lat: 1, lng: 1 }, destination: { lat: 1, lng: 1 })
Ioki::Model::Passenger::RideInquiry.new(
origin: { lat: 1, lng: 1 },
destination: { lat: 1, lng: 1 },
product_id: product.id
)
end

it 'has data for all defined attributes' do
returned_ride_inquiry = passenger_client.create_ride_inquiry(product, ride_inqury)
returned_ride_inquiry = passenger_client.create_ride_inquiry(ride_inqury)
expect(returned_ride_inquiry.availability).to be_a(Ioki::Model::Passenger::Availability)
expect(returned_ride_inquiry.constraints).to be_a(Ioki::Model::Passenger::Constraints)
end
end

describe 'models accessible on the client endpoint' do
it 'has data for all defined attributes' do
expect(passenger_client.bootstrap.client.features).to be_a(Ioki::Model::Passenger::Features)
expect(passenger_client.bootstrap.client.features.analytics_tracking).to be(true).or(be(false))
expect(passenger_client.bootstrap.client.features.failed_payment_handling).to be(true).or(be(false))
expect(passenger_client.bootstrap.client.features.marketing_automation).to be(true).or(be(false))
expect(passenger_client.bootstrap.client.features.minimum_age_confirmation).to be(true).or(be(false))
expect(passenger_client.bootstrap.client.features.newsletter).to be(true).or(be(false))
expect(passenger_client.bootstrap.client.features.non_purchasable_personal_discounts).to be(true).or(be(false))
expect(passenger_client.bootstrap.client.features.payment).to be(true).or(be(false))
expect(passenger_client.bootstrap.client.features.promo_codes).to be(true).or(be(false))
expect(passenger_client.bootstrap.client.features.purchasable_personal_discounts).to be(true).or(be(false))
expect(passenger_client.bootstrap.client.features.referrals).to be(true).or(be(false))
expect(passenger_client.bootstrap.client.features.service_credits).to be(true).or(be(false))
expect(passenger_client.bootstrap.client.features.unique_customer_id).to be(true).or(be(false))
expect(passenger_client.bootstrap.client.features.user_email_required).to be(true).or(be(false))
features = passenger_client.bootstrap.client.features

expect(features).to be_a(Ioki::Model::Passenger::Features)
expect(features.analytics_tracking).to be(true).or(be(false))
expect(features.failed_payment_handling).to be(true).or(be(false))
expect(features.marketing_automation).to be(true).or(be(false))
pending('Needs a client with a minimum_age_confirmation feature enabled')
expect(features.minimum_age_confirmation).to be_a(Ioki::Model::Passenger::MinimumAgeConfirmation)
expect(features.minimum_age_confirmation.minimum_age).to be_a(Integer)
expect(features.newsletter).to be(true).or(be(false))
expect(features.non_purchasable_personal_discounts).to be(true).or(be(false))
expect(features.payment).to be(true).or(be(false))
expect(features.promo_codes).to be(true).or(be(false))
expect(features.purchasable_personal_discounts).to be(true).or(be(false))
expect(features.referrals).to be(true).or(be(false))
expect(features.service_credits).to be(true).or(be(false))
expect(features.unique_customer_id).to be(true).or(be(false))
expect(features.user_email_required).to be(true).or(be(false))
end
end
end
Expand Down

0 comments on commit 5daf628

Please sign in to comment.