diff --git a/lib/ioki/apis/operator_api.rb b/lib/ioki/apis/operator_api.rb index 8ae88975..55bf32bd 100644 --- a/lib/ioki/apis/operator_api.rb +++ b/lib/ioki/apis/operator_api.rb @@ -214,6 +214,12 @@ class OperatorApi model_class: Ioki::Model::Operator::User, except: [:create, :update, :delete] ), + Endpoints.custom_endpoints( + 'users', + actions: { 'autocomplete' => :get }, + path: [API_BASE_PATH, 'providers', :id, 'users'], + model_class: Ioki::Model::Operator::UserAutocompletes + ), Endpoints::Create.new( :ride_inquiry, base_path: [API_BASE_PATH, 'products', :id], diff --git a/lib/ioki/model/operator/user_autocomplete.rb b/lib/ioki/model/operator/user_autocomplete.rb new file mode 100644 index 00000000..77b6edbc --- /dev/null +++ b/lib/ioki/model/operator/user_autocomplete.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Ioki + module Model + module Operator + class UserAutocomplete < Base + attribute :value, + on: :read, + type: :string + + attribute :label, + on: :read, + type: :string + + attribute :locked, + on: :read, + type: :boolean + end + end + end +end diff --git a/lib/ioki/model/operator/user_autocompletes.rb b/lib/ioki/model/operator/user_autocompletes.rb new file mode 100644 index 00000000..e0af2ac4 --- /dev/null +++ b/lib/ioki/model/operator/user_autocompletes.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Ioki + module Model + module Operator + class UserAutocompletes < Base + base 'Array', item_class_name: 'UserAutocomplete' + end + end + end +end diff --git a/spec/ioki/operator_api_spec.rb b/spec/ioki/operator_api_spec.rb index a15ae264..ae20fd33 100644 --- a/spec/ioki/operator_api_spec.rb +++ b/spec/ioki/operator_api_spec.rb @@ -1253,4 +1253,17 @@ .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') + expect(params[:method]).to eq(:get) + result_with_data + end + + expect(operator_client.users_autocomplete('0815', options)) + .to be_a(Ioki::Model::Operator::UserAutocompletes) + end + end end