Class: BaseCRM::UsersService
- Inherits:
-
Object
- Object
- BaseCRM::UsersService
- Defined in:
- lib/basecrm/services/users_service.rb
Instance Method Summary collapse
-
#all ⇒ Enumerable
Retrieve all users.
-
#find(id) ⇒ User
Retrieve a single user.
-
#initialize(client) ⇒ UsersService
constructor
A new instance of UsersService.
-
#self ⇒ User
Retrieve an authenticating user.
-
#where(options = {}) ⇒ Array<User>
Retrieve all users.
Constructor Details
#initialize(client) ⇒ UsersService
Returns a new instance of UsersService.
5 6 7 |
# File 'lib/basecrm/services/users_service.rb', line 5 def initialize(client) @client = client end |
Instance Method Details
#all ⇒ Enumerable
Retrieve all users
get ‘/users’
If you want to use filtering or sorting (see #where).
15 16 17 |
# File 'lib/basecrm/services/users_service.rb', line 15 def all PaginatedResource.new(self) end |
#find(id) ⇒ User
Retrieve a single user
get ‘/users/BaseCRM#id’
Returns a single user according to the unique user ID provided If the specified user does not exist, this query returns an error
52 53 54 55 56 |
# File 'lib/basecrm/services/users_service.rb', line 52 def find(id) _, _, root = @client.get("/users/#{id}") User.new(root[:data]) end |
#self ⇒ User
Retrieve an authenticating user
get ‘/users/self’
Returns a single authenticating user, according to the authentication credentials provided
66 67 68 69 |
# File 'lib/basecrm/services/users_service.rb', line 66 def self _, _, root = @client.get("/users/self") User.new(root[:data]) end |
#where(options = {}) ⇒ Array<User>
Retrieve all users
get ‘/users’
Returns all users, according to the parameters provided
36 37 38 39 40 |
# File 'lib/basecrm/services/users_service.rb', line 36 def where( = {}) _, _, root = @client.get("/users", ) root[:items].map{ |item| User.new(item[:data]) } end |