Skip to content

Commit ab1dc3e

Browse files
authored
Merge pull request #76 from 3scale/find-application-by-service
find application by service_id
2 parents c2af769 + b83f363 commit ab1dc3e

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
/spec/reports/
99
/spec/examples.txt
1010
/tmp/
11+
/vendor/
1112
.env

lib/3scale/api/client.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ def show_application(id)
5353
# @param [Fixnum] id Application ID
5454
# @param [String] user_key Application User Key
5555
# @param [String] application_id Application app_id
56-
def find_application(id: nil, user_key: nil, application_id: nil)
57-
params = { application_id: id, user_key: user_key, app_id: application_id }.reject { |_, value| value.nil? }
56+
def find_application(id: nil, user_key: nil, application_id: nil, service_id: nil)
57+
params = {
58+
application_id: id,
59+
user_key: user_key,
60+
app_id: application_id,
61+
service_id: service_id,
62+
}.compact
5863
response = http_client.get('/admin/api/applications/find', params: params)
5964
extract(entity: 'application', from: response)
6065
end

spec/api/client_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@
168168
expect(client.find_application(user_key: 'hex')).to eq('user_key' => 'hex')
169169
end
170170

171+
it 'finds by user_key and service_id' do
172+
expect(http_client).to receive(:get)
173+
.with('/admin/api/applications/find', params: { user_key: 'hex', service_id: 100 })
174+
.and_return('application' => { 'user_key' => 'hex' })
175+
expect(client.find_application(user_key: 'hex', service_id: 100)).to eq('user_key' => 'hex')
176+
end
177+
171178
it 'finds by app_id' do
172179
expect(http_client).to receive(:get)
173180
.with('/admin/api/applications/find', params: { app_id: 'hex' })

0 commit comments

Comments
 (0)