Skip to content

Commit

Permalink
Merge pull request #358 from ioki-mobility/passenger-api/create-ride-…
Browse files Browse the repository at this point in the history
…series

Passenger API | Add creation of ride series
  • Loading branch information
phylor authored Apr 9, 2024
2 parents edaaaa3 + f11b128 commit ad5981c
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/ioki/apis/passenger_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ class PassengerApi
path: 'rating',
model_class: Ioki::Model::Passenger::Rating
),
Endpoints::Create.new(
:ride_series,
base_path: [API_BASE_PATH, 'rides', :id],
path: 'ride_series',
model_class: Ioki::Model::Passenger::RideSeries
),
Endpoints.crud_endpoints(
:station,
base_path: [API_BASE_PATH],
Expand Down
21 changes: 21 additions & 0 deletions lib/ioki/model/passenger/ride_series.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module Ioki
module Model
module Passenger
class RideSeries < Base
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 :base_ride_id, on: :read, type: :string
attribute :additional_dates, on: [:read, :create], type: :array
attribute :processing_started_at, on: :read, type: :date_time
attribute :processing_finished_at, on: :read, type: :date_time
attribute :rides, on: :read, type: :array, class_name: 'Ride'
attribute :results, on: :read, type: :array, class_name: 'RideSeriesResultItem'
end
end
end
end
19 changes: 19 additions & 0 deletions lib/ioki/model/passenger/ride_series_result_item.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 RideSeriesResultItem < Base
attribute :type, on: :read, type: :string
attribute :ride_date, on: :read, type: :date_time
attribute :processed, on: :read, type: :boolean
attribute :ride_id, on: :read, type: :string
attribute :ride_create_success, on: :read, type: :boolean
attribute :ride_create_error_code, on: :read, type: :string
attribute :ride_state_after_matching, on: :read, type: :string
attribute :booking_success, on: :read, type: :boolean
attribute :booking_error_code, on: :read, type: :string
end
end
end
end
14 changes: 14 additions & 0 deletions spec/ioki/passenger_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -517,4 +517,18 @@
.to be_a Ioki::Model::Passenger::RedeemedPromoCode
end
end

describe '#create_ride_series' do
let(:ride) { Ioki::Model::Passenger::Ride.new(id: 'RIDE_ID') }
let(:ride_series) { Ioki::Model::Passenger::RideSeries.new }

it 'calls request on the client with expected params' do
expect(passenger_client).to receive(:request) do |params|
expect(params[:url].to_s).to eq('passenger/rides/RIDE_ID/ride_series')
[result_with_data, full_response]
end

expect(passenger_client.create_ride_series(ride, ride_series, options)).to be_a Ioki::Model::Passenger::RideSeries
end
end
end

0 comments on commit ad5981c

Please sign in to comment.