Skip to content

Commit

Permalink
Add delete method to http client
Browse files Browse the repository at this point in the history
  • Loading branch information
gregawoods committed Oct 26, 2023
1 parent ca8c658 commit 987db6e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/keycloak/http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ def put(uri, body = {}, access_token: nil)
end
end

def delete(uri, body = {}, access_token: nil)
uri = URI.parse(uri)

request(:delete, uri, access_token) do |request|
request.body = body.to_json
request['Content-Type'] = 'application/json'
end
end

def post_form(uri, params, access_token: nil)
uri = URI.parse(uri)

Expand Down
2 changes: 1 addition & 1 deletion lib/keycloak/realm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def refresh(refresh_token)
})
end

[:get, :post, :put].each do |method|
[:get, :post, :put, :delete].each do |method|
define_method method do |endpoint, *args, **kwargs|
kwargs[:access_token] = service_user_token
http_client.send(method, "#{host}/admin/realms/#{realm}/#{endpoint}", *args, **kwargs)
Expand Down

0 comments on commit 987db6e

Please sign in to comment.