Skip to content

Commit

Permalink
Add user endpoints for operator api
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-ioki committed May 23, 2023
1 parent 1751667 commit aea4164
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 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 @@ -191,6 +191,12 @@ class OperatorApi
base_path: [API_BASE_PATH, 'products', :id, 'lines', :id],
except: [:create, :delete],
model_class: Ioki::Model::Operator::LineStop
),
Endpoints.crud_endpoints(
:user,
base_path: [API_BASE_PATH, 'providers', :id],
model_class: Ioki::Model::Operator::User,
except: [:create, :update, :delete]
)
].freeze
end
Expand Down
34 changes: 29 additions & 5 deletions spec/ioki/operator_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@
end

expect(operator_client.create_line('0815', line, options))
.to eq(Ioki::Model::Operator::Line.new)
.to be_a(Ioki::Model::Operator::Line)
end
end

Expand All @@ -1108,7 +1108,7 @@
end

expect(operator_client.update_line('0815', line, options))
.to eq(Ioki::Model::Operator::Line.new)
.to be_a(Ioki::Model::Operator::Line)
end
end

Expand All @@ -1120,7 +1120,7 @@
end

expect(operator_client.delete_line('0815', '4711', options))
.to eq(Ioki::Model::Operator::Line.new)
.to be_a(Ioki::Model::Operator::Line)
end
end

Expand All @@ -1134,7 +1134,7 @@
end

expect(operator_client.create_line_stop('0815', '0815', line_stop, options))
.to eq(Ioki::Model::Operator::LineStop.new)
.to be_a(Ioki::Model::Operator::LineStop)
end
end

Expand All @@ -1146,7 +1146,31 @@
end

expect(operator_client.delete_line_stop('0815', '0815', '4711', options))
.to eq(Ioki::Model::Operator::LineStop.new)
.to be_a(Ioki::Model::Operator::LineStop)
end
end

describe '#users(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')
result_with_index_data
end

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

describe '#user(provider_id, user_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/4711')
[result_with_data, full_response]
end

expect(operator_client.user('0815', '4711', options))
.to be_a(Ioki::Model::Operator::User)
end
end
end

0 comments on commit aea4164

Please sign in to comment.