Skip to content

Commit

Permalink
Merge pull request #74 from ioki-mobility/platform-api-task-list-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rmehner committed Mar 2, 2023
2 parents 2a6435c + 3b23d55 commit 3b620ba
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 50 deletions.
2 changes: 1 addition & 1 deletion lib/ioki/model/platform/calculated_point.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CalculatedPoint < Base
attribute :county, on: :read, type: :string
attribute :display_times, on: :read, type: :array
attribute :fixed_location, on: :read, type: :boolean
attribute :fixed_location, on: :read, type: :boolean
attribute :formatted_street, on: :read, type: :string
attribute :lat, on: :read, type: :float
attribute :lng, on: :read, type: :float
Expand All @@ -21,7 +22,6 @@ class CalculatedPoint < Base
attribute :negotiation_time_max, on: :read, type: :date_time
attribute :pause_id, on: :read, type: :string
attribute :postal_code, on: :read, type: :string
attribute :station, on: :read, type: :object, class_name: 'Station'
attribute :station_id, on: :read, type: :string
attribute :street_name, on: :read, type: :string
attribute :street_number, on: :read, type: :string
Expand Down
4 changes: 2 additions & 2 deletions lib/ioki/model/platform/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class Task < Base
attribute :completer, on: :read, type: :object # No model_class b/c it can have one of several types.
attribute :completer_id, on: :read, type: :string
attribute :completer_type, on: :read, type: :string
attribute :pause, on: :read, type: :object, class_name: 'Pause'
attribute :pause_id, on: :read, type: :string
attribute :rejectable, on: :read, type: :boolean
attribute :ride, on: :read, type: :object, class_name: 'Ride'
attribute :ride_id, on: :read, type: :string
attribute :state, on: :read, type: :string
attribute :task_list_id, on: :read, type: :string
attribute :waypoint_type, on: :read, type: :string
Expand Down
4 changes: 2 additions & 2 deletions lib/ioki/model/platform/task_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class TaskList < Base
attribute :driver, on: :read, type: :object, class_name: 'Driver'
attribute :ends_at, on: [:create, :update], type: :date_time, unvalidated: true
attribute :end_place, on: :read, type: :object, class_name: 'Place'
attribute :matching_configuration, on: :read, type: :object, class_name: 'MatchingConfiguration'
attribute :matching_configuration_id, on: [:create, :update], type: :string, unvalidated: true
attribute :end_place_id, on: [:create, :update], type: :object, class_name: 'Place', unvalidated: true
attribute :matching_configuration_id, on: :read, type: :string
attribute :matching_configuration_id, on: [:create, :update], type: :string, unvalidated: true
attribute :paused, on: :read, type: :boolean
attribute :pauses, on: [:read, :create], omit_if_blank_on: [:create], type: :array, class_name: 'Pause'
attribute :planned_ends_at, on: :read, type: :date_time
Expand Down
17 changes: 17 additions & 0 deletions spec/ioki/model/platform/calculated_point_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

RSpec.describe Ioki::Model::Platform::CalculatedPoint do
describe 'new' do
subject(:task_list) { described_class.new id: '123' }

it { is_expected.to have_attributes(id: '123') }
it { is_expected.to be_a(described_class) }
end

describe 'station' do
subject(:task_list) { described_class.new station_id: '123' }

it { is_expected.to have_attributes station_id: '123' }
it { is_expected.not_to respond_to :station }
end
end
67 changes: 67 additions & 0 deletions spec/ioki/model/platform/task_list_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# frozen_string_literal: true

RSpec.describe Ioki::Model::Platform::TaskList do
describe 'new' do
subject(:task_list) { described_class.new id: '123' }

it { is_expected.to have_attributes(id: '123') }
it { is_expected.to be_a(described_class) }
end

describe 'driver' do
subject(:task_list) { described_class.new driver: { id: '123' } }

it { is_expected.to have_attributes driver: have_attributes(id: '123') }
it { is_expected.to have_attributes driver: be_a(Ioki::Model::Platform::Driver) }
end

describe 'vehicle' do
subject(:task_list) { described_class.new vehicle: { id: '123', connected_driver_id: '123' } }

it { is_expected.to have_attributes vehicle: have_attributes(id: '123') }
it { is_expected.to have_attributes vehicle: have_attributes(connected_driver_id: '123') }
it { is_expected.to have_attributes vehicle: be_a(Ioki::Model::Platform::Vehicle) }
end

describe 'start_place' do
subject(:task_list) { described_class.new start_place: { id: '123' } }

it { is_expected.to have_attributes start_place: have_attributes(id: '123') }
it { is_expected.to have_attributes start_place: be_a(Ioki::Model::Platform::Place) }
end

describe 'end_place' do
subject(:task_list) { described_class.new end_place: { id: '123' } }

it { is_expected.to have_attributes end_place: have_attributes(id: '123') }
it { is_expected.to have_attributes end_place: be_a(Ioki::Model::Platform::Place) }
end

describe 'matching_configuration' do
subject(:task_list) { described_class.new matching_configuration: nil, matching_configuration_id: '123' }

it { is_expected.to have_attributes matching_configuration_id: '123' }
it { is_expected.not_to respond_to :matching_configuration }
end

describe 'tasks' do
subject(:task_list) { described_class.new tasks: [{ id: '123' }] }

it { is_expected.to have_attributes tasks: all(have_attributes(id: '123')) }
it { is_expected.to have_attributes tasks: all(be_a(Ioki::Model::Platform::Task)) }
end

describe 'pauses' do
subject(:task_list) { described_class.new pauses: [{ id: '123' }] }

it { is_expected.to have_attributes pauses: all(have_attributes(id: '123')) }
it { is_expected.to have_attributes pauses: all(be_a(Ioki::Model::Platform::Pause)) }
end

describe 'deactivations' do
subject(:task_list) { described_class.new deactivations: [{ id: '123' }] }

it { is_expected.to have_attributes deactivations: all(have_attributes(id: '123')) }
it { is_expected.to have_attributes deactivations: all(be_a(Ioki::Model::Platform::Deactivation)) }
end
end
30 changes: 29 additions & 1 deletion spec/ioki/model/platform/task_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
# frozen_string_literal: true

RSpec.describe Ioki::Model::Platform::Task do
describe 'new' do
subject(:task_list) { described_class.new id: '123' }

it { is_expected.to have_attributes(id: '123') }
it { is_expected.to be_a(described_class) }
end

describe 'calculated_point' do
subject(:task_list) { described_class.new calculated_point: { id: '123' } }

it { is_expected.to have_attributes calculated_point: have_attributes(id: '123') }
it { is_expected.to have_attributes calculated_point: be_a(Ioki::Model::Platform::CalculatedPoint) }
end

describe 'pause' do
subject(:task_list) { described_class.new pause: nil, pause_id: '123' }

it { is_expected.to have_attributes pause_id: '123' }
it { is_expected.not_to respond_to :pause }
end

describe 'ride' do
subject(:task_list) { described_class.new ride_id: '123' }

it { is_expected.to have_attributes ride_id: '123' }
it { is_expected.not_to respond_to :ride }
end

it { is_expected.to define_attribute(:id).as(:string) }
it { is_expected.to define_attribute(:type).as(:string) }
it { is_expected.to define_attribute(:created_at).as(:date_time) }
it { is_expected.to define_attribute(:updated_at).as(:date_time) }
it { is_expected.to define_attribute(:ride).as(:object).with(class_name: 'Ride') }
it { is_expected.to define_attribute(:ride_id).as(:string) }
end
13 changes: 9 additions & 4 deletions spec/ioki/passenger_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
[result_with_data, full_response]
end

expect(passenger_client.create_ride_inquiry(ride_inquiry, options)).to be_a Ioki::Model::Passenger::RideInquiry
expect(passenger_client.create_ride_inquiry(ride_inquiry, options))
.to be_a(Ioki::Model::Passenger::RideInquiry)
end
end

Expand All @@ -90,7 +91,8 @@
[result_with_data, full_response]
end

expect(passenger_client.create_ride(ride, options)).to be_a Ioki::Model::Passenger::Ride
expect(passenger_client.create_ride(ride, options))
.to be_a(Ioki::Model::Passenger::Ride)
end
end

Expand Down Expand Up @@ -124,7 +126,8 @@
[result_with_data, full_response]
end

expect(passenger_client.create_cancellation(ride, cancellation)).to be_a Ioki::Model::Passenger::Ride
expect(passenger_client.create_cancellation(ride, cancellation))
.to be_a(Ioki::Model::Passenger::Ride)
end
end

Expand All @@ -139,7 +142,8 @@
[result_with_data, full_response]
end

expect(passenger_client.create_booking(ride, booking, options)).to be_a Ioki::Model::Passenger::Booking
expect(passenger_client.create_booking(ride, booking, options))
.to be_a(Ioki::Model::Passenger::Booking)
end
end

Expand Down Expand Up @@ -185,6 +189,7 @@
expect(params[:body][:data]).to match(hash_including(first_name: 'Lupe', last_name: 'Smiles'))
[result_with_data, full_response]
end

expect(passenger_client.update_user(user, options)).to be_a Ioki::Model::Passenger::User
end
end
Expand Down
Loading

0 comments on commit 3b620ba

Please sign in to comment.