Class: KeycloakRails::Curl

Inherits:
Object
  • Object
show all
Defined in:
lib/keycloak_rails/curl.rb

Overview

https client with farady v > 2.0.0

Instance Method Summary collapse

Constructor Details

#initializeCurl

Returns a new instance of Curl.



6
7
8
# File 'lib/keycloak_rails/curl.rb', line 6

def initialize
  @faraday = Faraday.new(url: KeycloakRails.auth_server_url)
end

Instance Method Details

#get(path: '', headers: { 'Content-Type': 'application/json' }, body: {}) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/keycloak_rails/curl.rb', line 18

def get(path: '', headers: { 'Content-Type': 'application/json' }, body: {})
  request = @faraday.get(path) do |req|
    req.headers = headers
    req.body = body
  end
  extract_response(request)
end

#patch(path: '', headers: { 'Content-Type': 'application/json' }, body: {}) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/keycloak_rails/curl.rb', line 26

def patch(path: '', headers: { 'Content-Type': 'application/json' }, body: {})
  request = @faraday.patch(path) do |req|
    req.headers = headers
    req.body = body
  end
  extract_response(request)
end

#post(path: '', headers: { 'Content-Type': 'application/json' }, body: {}) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/keycloak_rails/curl.rb', line 10

def post(path: '', headers: { 'Content-Type': 'application/json' }, body: {})
  request = @faraday.post(path) do |req|
    req.headers = headers
    req.body = body
  end
  extract_response(request)
end

#put(path: '', headers: { 'Content-Type': 'application/json' }, body: {}) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/keycloak_rails/curl.rb', line 34

def put(path: '', headers: { 'Content-Type': 'application/json' }, body: {})
  request = @faraday.put(path) do |req|
    req.headers = headers
    req.body = body
  end
  extract_response(request)
end