Class: RippleKeycloak::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/ripple_keycloak/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:

  • (configuration)


15
16
17
18
19
20
# File 'lib/ripple_keycloak/client.rb', line 15

def configure
  @configuration = Configuration.new
  yield(configuration)
  auth
  'Authenticated successfully'
end

.delete_formatted(resource, json: true, authed: true, **options) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/ripple_keycloak/client.rb', line 51

def delete_formatted(resource, json: true, authed: true, **options)
  if authed
    options = add_auth_header(options)
    resource = "admin/realms/#{realm}/" + resource
  end
  options = format_as_json(options) if json

  return_or_raise delete("#{base_uri}/#{resource}", options)
end

.get_formatted(resource, authed: true, **options) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/ripple_keycloak/client.rb', line 42

def get_formatted(resource, authed: true, **options)
  if authed
    options = add_auth_header(options)
    resource = "admin/realms/#{realm}/" + resource
  end

  return_or_raise get("#{base_uri}/#{resource}", options)
end

.post_formatted(resource, json: true, authed: true, **options) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/ripple_keycloak/client.rb', line 22

def post_formatted(resource, json: true, authed: true, **options)
  if authed
    options = add_auth_header(options)
    resource = "admin/realms/#{realm}/" + resource
  end
  options = format_as_json(options) if json

  return_or_raise post("#{base_uri}/#{resource}", options)
end

.put_formatted(resource, json: true, authed: true, **options) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/ripple_keycloak/client.rb', line 32

def put_formatted(resource, json: true, authed: true, **options)
  if authed
    options = add_auth_header(options)
    resource = "admin/realms/#{realm}/" + resource
  end
  options = format_as_json(options) if json

  return_or_raise put("#{base_uri}/#{resource}", options)
end

Instance Method Details

#delete(resource, body = {}) ⇒ Object



134
135
136
# File 'lib/ripple_keycloak/client.rb', line 134

def delete(resource, body = {})
  self.class.delete_formatted(resource, body: body)
end

#get(resource) ⇒ Object



130
131
132
# File 'lib/ripple_keycloak/client.rb', line 130

def get(resource)
  self.class.get_formatted(resource)
end

#post(resource, body) ⇒ Object



122
123
124
# File 'lib/ripple_keycloak/client.rb', line 122

def post(resource, body)
  self.class.post_formatted(resource, body: body)
end

#put(resource, body) ⇒ Object



126
127
128
# File 'lib/ripple_keycloak/client.rb', line 126

def put(resource, body)
  self.class.put_formatted(resource, body: body)
end