Class: Ashby::Users
Overview
Ashby::Users provides access to user-related functionality in the Ashby API.
Includes support for:
- Fetching all users with pagination
- Searching users by email
- Looking up users by their Ashby ID
Example usage:
Ashby::Users.all
Ashby::Users.find_by_email(email: '[email protected]')
Ashby::Users.find_by_id(id: 'user_xyz789')
Constant Summary
Constants inherited from Client
Class Method Summary collapse
-
.all ⇒ Object
Fetches all users with pagination support.
-
.find_by_email(email: nil) ⇒ Object
Find a user by their email.
-
.find_by_id(id: nil) ⇒ Object
Finds a user by their Ashby ID.
Methods inherited from Client
build_url, headers, paginated_post, post
Class Method Details
.all ⇒ Object
Fetches all users with pagination support
18 19 20 |
# File 'lib/ashby/users.rb', line 18 def self.all paginated_post('user.list') end |
.find_by_email(email: nil) ⇒ Object
Find a user by their email
23 24 25 26 27 28 29 30 31 |
# File 'lib/ashby/users.rb', line 23 def self.find_by_email(email: nil) payload = {} payload[:email] = email if email raise ArgumentError, 'You must provide an email' if payload.empty? response = post('user.search', payload) response['results'] end |
.find_by_id(id: nil) ⇒ Object
Finds a user by their Ashby ID
34 35 36 37 38 39 40 |
# File 'lib/ashby/users.rb', line 34 def self.find_by_id(id: nil) raise ArgumentError, 'User ID is required' if id.to_s.strip.empty? payload = { userId: id } response = post('user.info', payload) response['results'] end |