Skip to content

Commit

Permalink
Add locale to Admin and add admin#show endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-ioki committed Sep 27, 2023
1 parent 0ea8a04 commit 500b938
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
6 changes: 6 additions & 0 deletions lib/ioki/apis/operator_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class OperatorApi
base_path: [API_BASE_PATH, 'admin'],
model_class: Ioki::Model::Operator::Permission
),
Endpoints::crud_endpoints(
:admin,
base_path: [API_BASE_PATH],
model_class: Ioki::Model::Operator::Admin,
except: [:create, :update, :delete, :index]
),
Endpoints.crud_endpoints(
:driver,
base_path: [API_BASE_PATH, 'products', :id],
Expand Down
38 changes: 31 additions & 7 deletions lib/ioki/model/operator/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,37 @@ module Ioki
module Model
module Operator
class Admin < 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 :email, on: :read, type: :string
attribute :first_name, on: :read, type: :string
attribute :last_name, on: :read, type: :string
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 :email,
on: :read,
type: :string

attribute :first_name,
on: :read,
type: :string

attribute :last_name,
on: :read,
type: :string

attribute :locale,
on: :read,
type: :string
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions spec/ioki/operator_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1253,4 +1253,16 @@
.to be_a(Ioki::Model::Operator::Task)
end
end

describe '#admin(admin_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/admins/0815')
[result_with_data, full_response]
end

expect(operator_client.admin('0815', options))
.to be_a(Ioki::Model::Operator::Admin)
end
end
end

0 comments on commit 500b938

Please sign in to comment.