Class: ChinoRuby::Users
Instance Method Summary
collapse
-
#create_user(user_schema_id, username, password, attributes) ⇒ Object
-
#delete_user(user_id, force) ⇒ Object
-
#get_user(user_id) ⇒ Object
-
#list_users(user_schema_id, limit = nil, offset = nil) ⇒ Object
-
#me ⇒ Object
-
#update_user(user_id, username, password, attributes) ⇒ Object
-
#update_user_partial(user_id, attributes = nil, username = nil, password = nil) ⇒ Object
#delete_resource, #get_resource, #initialize, #parse_response, #patch_resource, #post_resource, #post_resource_with_string_result, #put_resource, #return_uri
Methods inherited from CheckValues
#check_boolean, #check_int, #check_json, #check_string
Instance Method Details
#create_user(user_schema_id, username, password, attributes) ⇒ Object
664
665
666
667
668
669
670
671
672
673
|
# 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) ⇒ Object
708
709
710
711
712
|
# 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) ⇒ Object
639
640
641
642
643
644
|
# 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) ⇒ Object
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
|
# 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 ⇒ Object
633
634
635
636
637
|
# 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) ⇒ Object
675
676
677
678
679
680
681
682
683
684
|
# 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) ⇒ Object
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
|
# 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
|