Skip to content

Commit

Permalink
Merge pull request #251 from ioki-mobility/feature/operator-create-re…
Browse files Browse the repository at this point in the history
…positioning-task

Operator API | Add creation of repositioning tasks
  • Loading branch information
phylor committed Aug 2, 2023
2 parents fe6e304 + 079c371 commit 8ee767c
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/ioki/apis/operator_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ class OperatorApi
base_path: [API_BASE_PATH, 'products', :id],
path: 'ride_inquiry',
model_class: Ioki::Model::Operator::RideInquiry
),
Endpoints::Create.new(
:repositioning_task,
base_path: [API_BASE_PATH, 'products', :id, 'task_lists', :id],
path: 'repositioning_tasks',
model_class: Ioki::Model::Operator::Task,
outgoing_model_class: Ioki::Model::Operator::RepositioningTask
)
].freeze
end
Expand Down
74 changes: 74 additions & 0 deletions lib/ioki/model/operator/repositioning_task.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# frozen_string_literal: true

module Ioki
module Model
module Operator
class RepositioningTask < Base
attribute :lat,
on: :create,
omit_if_nil_on: [:create],
type: :float

attribute :lng,
on: :create,
omit_if_nil_on: [:create],
type: :float

attribute :location_name,
on: :create,
omit_if_nil_on: [:create],
type: :string

attribute :street_name,
on: :create,
omit_if_nil_on: [:create],
type: :string

attribute :street_number,
on: :create,
omit_if_nil_on: [:create],
type: :string

attribute :postal_code,
on: :create,
omit_if_nil_on: [:create],
type: :string

attribute :city,
on: :create,
omit_if_nil_on: [:create],
type: :string

attribute :county,
on: :create,
omit_if_nil_on: [:create],
type: :string

attribute :country,
on: :create,
omit_if_nil_on: [:create],
type: :string

attribute :time_min,
on: :create,
omit_if_nil_on: [:create],
type: :date_time

attribute :time,
on: :create,
omit_if_nil_on: [:create],
type: :date_time

attribute :time_max,
on: :create,
omit_if_nil_on: [:create],
type: :date_time

attribute :dismissable,
on: :create,
omit_if_nil_on: [:create],
type: :boolean
end
end
end
end
14 changes: 14 additions & 0 deletions spec/ioki/operator_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1225,4 +1225,18 @@
.to be_a(Ioki::Model::Operator::RideInquiry)
end
end

describe '#create_repositioning_task(product_id, task_list_id)' do
let(:repositioning_task) { Ioki::Model::Operator::RepositioningTask.new }

it 'calls request on the client with expected params' do
expect(operator_client).to receive(:request) do |params|
expect(params[:url].to_s).to eq('operator/products/0815/task_lists/01/repositioning_tasks')
[result_with_data, full_response]
end

expect(operator_client.create_repositioning_task('0815', '01', repositioning_task, options))
.to be_a(Ioki::Model::Operator::Task)
end
end
end

0 comments on commit 8ee767c

Please sign in to comment.