class RippleKeycloak::BaseModel

Public Class Methods

all(first: nil, max: nil) click to toggle source
# File lib/ripple_keycloak/base_model.rb, line 16
def all(first: nil, max: nil)
  url = "#{@object_type}?"
  url += "first=#{first}&" if first
  url += "max=#{max}" if max

  client.get(url).parsed_response
end
delete(id) click to toggle source
# File lib/ripple_keycloak/base_model.rb, line 38
def delete(id)
  client.delete("#{@object_type}/#{id}").parsed_response
end
find(id) click to toggle source
# File lib/ripple_keycloak/base_model.rb, line 24
def find(id)
  client.get("#{@object_type}/#{id}").parsed_response
end
find_by(field:, value:) click to toggle source
# File lib/ripple_keycloak/base_model.rb, line 28
def find_by(field:, value:)
  results = search(value)
  if results.is_a? Array
    results.each do |instance|
      return instance if instance[field] == value
    end
  end
  raise NotFoundError, "Object type: #{@object_type}, field: #{field}, value: #{value}"
end
object_type(object_type) click to toggle source
# File lib/ripple_keycloak/base_model.rb, line 8
def object_type(object_type)
  @object_type = object_type
end

Private Class Methods

client() click to toggle source
# File lib/ripple_keycloak/base_model.rb, line 44
def client
  RippleKeycloak::Client.new
end