Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operator Api | add user autocomplete #273

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/ioki/apis/operator_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
21 changes: 21 additions & 0 deletions lib/ioki/model/operator/user_autocomplete.rb
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions lib/ioki/model/operator/user_autocompletes.rb
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions spec/ioki/operator_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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