class ChinoRuby::Users

Public Instance Methods

create_user(user_schema_id, username, password, attributes) click to toggle source
# File lib/chino_ruby/classes.rb, line 664
def create_user(user_schema_id, username, password, attributes)
  check_string(user_schema_id)
  check_string(username)
  check_string(password)
  check_json(attributes)
  data = {"username": username, "password": password, "attributes": attributes}.to_json
  user = User.new
  user.from_json(post_resource("/user_schemas/#{user_schema_id}/users", data).to_json, true)
  user
end
delete_user(user_id, force) click to toggle source
# File lib/chino_ruby/classes.rb, line 708
def delete_user(user_id, force)
  check_string(user_id)
  check_boolean(force)
  delete_resource("/users/#{user_id}", force)
end
get_user(user_id) click to toggle source
# File lib/chino_ruby/classes.rb, line 639
def get_user(user_id)
  check_string(user_id)
  u = User.new
  u.from_json(get_resource("/users/#{user_id}").to_json, true)
  u
end
list_users(user_schema_id, limit=nil, offset=nil) click to toggle source
# File lib/chino_ruby/classes.rb, line 646
def list_users(user_schema_id, limit=nil, offset=nil)
  check_string(user_schema_id)
  users = GetUsersResponse.new
  if limit==nil && offset==nil
    users.from_json(get_resource("/user_schemas/#{user_schema_id}/users", ChinoRuby::QUERY_DEFAULT_LIMIT, 0).to_json)
  else
    users.from_json(get_resource("/user_schemas/#{user_schema_id}/users", limit, offset).to_json)
  end
  us = users.users
  users.users = []
  us.each do |u|
    user = User.new
    user.from_json(u.to_json)
    users.users.push(user)
  end
  users
end
me() click to toggle source
# File lib/chino_ruby/classes.rb, line 633
def me
  u = User.new
  u.from_json(get_resource("/users/me").to_json, true)
  u
end
update_user(user_id, username, password, attributes) click to toggle source
# File lib/chino_ruby/classes.rb, line 675
def update_user(user_id, username, password, attributes)
  check_string(user_id)
  check_string(username)
  check_string(password)
  check_json(attributes)
  data = {"username": username, "password": password, "attributes": attributes}.to_json
  user = User.new
  user.from_json(put_resource("/users/#{user_id}", data).to_json, true)
  user
end
update_user_partial(user_id, attributes=nil, username=nil, password=nil) click to toggle source
# File lib/chino_ruby/classes.rb, line 686
def update_user_partial(user_id, attributes=nil, username=nil, password=nil)
  check_string(user_id)
  data = Hash.new
  if attributes
    check_json(attributes)
    data['attributes'] = attributes
  end
  if username
    check_string(username)
    data['username'] = username
  end
  if password
    check_string(password)
    data['password'] = password
  end
  data = data.to_json

  user = User.new
  user.from_json(patch_resource("/users/#{user_id}", data).to_json, true)
  user
end