Class: Ashby::Departments

Inherits:
Client
  • Object
show all
Defined in:
lib/ashby/departments.rb

Overview

Ashby::Departments provides methods to interact with the Ashby API's department-related endpoints.

Includes fetching a list of departments and retrieving a specific department by ID.

Example:

Ashby::Departments.all
Ashby::Departments.find(id: 'abc123')

Constant Summary

Constants inherited from Client

Client::API_URL

Class Method Summary collapse

Methods inherited from Client

build_url, headers, paginated_post, post

Class Method Details

.allObject

Fetches all departments



15
16
17
18
# File 'lib/ashby/departments.rb', line 15

def self.all
  response = post('department.list')
  response['results']
end

.find(id: nil) ⇒ Object

Finds a department by its Ashby ID

Raises:

  • (ArgumentError)


21
22
23
24
25
26
27
# File 'lib/ashby/departments.rb', line 21

def self.find(id: nil)
  raise ArgumentError, 'Department ID is required' if id.to_s.strip.empty?

  payload = { departmentId: id }
  response = post('department.info', payload)
  response['results']
end