module TheCity::API::Users
Public Instance Methods
Returns the user associated with the current access token
@req_scope user_basic @opt_scope user_extended @return [TheCity::User] The authenticated user. @param options [Hash] A customizable set of options. @option options [Boolean] :force_download Forces the request to hit the server and flush the cached response
# File lib/the_city/api/users.rb, line 36 def me(options={}) @me = nil if options.delete(:force_download) @me ||= object_from_response(TheCity::User, :get, "/me", options, {:current_user => true, :client => self}) end
Returns the permissions for the current user
@req_scope user_permissions @opt_scope group_content @return [TheCity::Permissions] The permission object for the current user. @overload permissions(options={})
@param options [Hash] A customizable set of options.
# File lib/the_city/api/users.rb, line 51 def permissions(*args) arguments = TheCity::Arguments.new(args) object_from_response(TheCity::Permissions, :get, "/me/permissions", arguments.options) end
@return [TheCity::User] The requested user. @raise [TheCity::Error::NotFound] Error
raised when the user cannot be found. @req_scope user_trusted @overload user(id)
@param id [Integer] The id of the user.
@overload user(id, options={})
@param id [Integer] The id of the user. @param options [Hash] A customizable set of options. @option options [Boolean] :force_download Forces the request to hit the server and flush the cached response
# File lib/the_city/api/users.rb, line 19 def user(*args) @users ||= {} arguments = TheCity::Arguments.new(args) uid = args.shift @users[uid] = nil if arguments.options.delete(:force_download) @users[uid] ||= object_from_response(TheCity::User, :get, "/users/#{uid}", arguments.options, {:client => self}) end
Returns true if the specified user exists
@req_scope user_trusted @return [Boolean] true if the user exists, otherwise false. @param user [Integer, String, TheCity::User] A City user id, or object.
# File lib/the_city/api/users.rb, line 61 def user?(user) user_id = case user when ::Integer user when ::String user.to_i when TheCity::User user.id end get("/users/#{user_id}") true rescue TheCity::Error::NotFound false end