lib/basecrm/services/users_service.rb in basecrm-1.3.2 vs lib/basecrm/services/users_service.rb in basecrm-1.3.3
- old
+ new
@@ -5,21 +5,21 @@
def initialize(client)
@client = client
end
# Retrieve all users
- #
+ #
# get '/users'
#
# If you want to use filtering or sorting (see #where).
- # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
+ # @return [Enumerable] Paginated resource you can use to iterate over all the resources.
def all
PaginatedResource.new(self)
end
# Retrieve all users
- #
+ #
# get '/users'
#
# Returns all users, according to the parameters provided
#
# @param options [Hash] Search options
@@ -30,40 +30,40 @@
# @option options [Integer] :page (1) Page number to start from. Page numbering starts at 1, and omitting the `page` parameter will return the first page.
# @option options [Integer] :per_page (25) Number of records to return per page. The default limit is *25*, and the maximum number that can be returned is *100*.
# @option options [String] :role Role of user to search for.
# @option options [String] :sort_by (id:asc) A field to sort by. The **default** order is **ascending**. If you want to change the sort order to descending, append `:desc` to the field e.g. `sort_by=name:desc`.
# @option options [String] :status Status of user accounts to search for.
- # @return [Array<User>] The list of Users for the first page, unless otherwise specified.
+ # @return [Array<User>] The list of Users for the first page, unless otherwise specified.
def where(options = {})
_, _, root = @client.get("/users", options)
root[:items].map{ |item| User.new(item[:data]) }
end
-
+
# Retrieve a single user
- #
+ #
# get '/users/{id}'
#
# Returns a single user according to the unique user ID provided
# If the specified user does not exist, this query returns an error
#
# @param id [Integer] Unique identifier of a User
- # @return [User] Searched resource object.
+ # @return [User] Searched resource object.
def find(id)
_, _, root = @client.get("/users/#{id}")
User.new(root[:data])
end
-
-
+
+
# Retrieve an authenticating user
- #
+ #
# get '/users/self'
#
# Returns a single authenticating user, according to the authentication credentials provided
#
- # @return [User] Resource object.
+ # @return [User] Resource object.
def self
_, _, root = @client.get("/users/self")
User.new(root[:data])
end