Skip to content

Commit

Permalink
Add custom index endpoint users_autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-ioki committed Sep 19, 2023
1 parent bde4bba commit df052fd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lib/ioki/apis/operator_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,18 @@ class OperatorApi
path: 'repositioning_tasks',
model_class: Ioki::Model::Operator::Task,
outgoing_model_class: Ioki::Model::Operator::RepositioningTask
),
#Endpoints.custom_endpoints(
# 'users',
# actions: { 'autocomplete' => :get },
# path: [API_BASE_PATH, 'providers', :id, 'users'],
# model_class: Ioki::Model::Operator::UserAutocomplete
#),
Endpoints::Index.new(
:users_autocomplete,
base_path: [API_BASE_PATH, 'providers', :id, 'users'],
path: 'autocomplete',
model_class: Ioki::Model::Operator::UserAutocomplete
)
].freeze
end
Expand Down
14 changes: 13 additions & 1 deletion spec/ioki/operator_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@
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/stations/overview')
[result_with_data, full_response]
result_with_index_data
end

expect(operator_client.station_overview('0815', options))
Expand Down Expand Up @@ -1253,4 +1253,16 @@
.to be_a(Ioki::Model::Operator::Task)
end
end

describe '#users_autocomplete(provider_id, ...)' do
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/providers/0815/users/autocomplete')
result_with_index_data
end

expect(operator_client.users_autocomplete('0815', options))
.to all(be_a(Ioki::Model::Operator::UserAutocomplete))
end
end
end

0 comments on commit df052fd

Please sign in to comment.