iachat/enterprise/app/controllers/api/v1/accounts
Vinay Keerthi 58ca82c720
feat: Backend - Companies API endpoint with pagination and search (#12840)
## Description

Adds API endpoint to list companies with pagination, search, and
sorting.

Fixes
https://linear.app/chatwoot/issue/CW-5930/add-backend-routes-to-get-companies-result
Parent issue:
https://linear.app/chatwoot/issue/CW-5928/add-companies-tab-to-dashboard

## Type of change

- [x] New feature (non-breaking change which adds functionality)

## How Has This Been Tested?

Added comprehensive specs to
`spec/enterprise/controllers/api/v1/accounts/companies_controller_spec.rb`:
- Pagination (25 per page, multiple pages)
- Search by name and domain (case-insensitive)
- Counter cache for contacts_count
- Account scoping
- Authorization

To reproduce:
```bash
bundle exec rspec spec/enterprise/controllers/api/v1/accounts/companies_controller_spec.rb
bundle exec rubocop enterprise/app/controllers/api/v1/accounts/companies_controller.rb
```

## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [ ] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules

---------

Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
Co-authored-by: iamsivin <iamsivin@gmail.com>
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
Co-authored-by: Sojan Jose <sojan@pepalo.com>
2025-11-18 14:28:56 +05:30
..
agent_capacity_policies fix: Assignment V2 controller fix (#12415) 2025-09-11 19:32:33 +07:00
captain feat: Add UI for custom tools (#12585) 2025-10-06 09:05:54 -07:00
agent_capacity_policies_controller.rb fix: Assignment V2 controller fix (#12415) 2025-09-11 19:32:33 +07:00
applied_slas_controller.rb feat: SLA reports view (#9189) 2024-04-09 10:14:36 +10:00
audit_logs_controller.rb chore: Improve logging for ip look up and audit logs [CW-2145] (#7512) 2023-07-27 16:48:30 +05:30
companies_controller.rb feat: Backend - Companies API endpoint with pagination and search (#12840) 2025-11-18 14:28:56 +05:30
custom_roles_controller.rb chore: upgrade ruby version to 3.4.4 (#11524) 2025-05-21 19:40:07 +05:30
enterprise_accounts_controller.rb feat: Conversation API to return applied_sla and sla_events (#9174) 2024-04-01 23:30:07 +05:30
reporting_events_controller.rb feat: allow querying reporting events via the API (#12832) 2025-11-13 12:46:55 +05:30
saml_settings_controller.rb feat: Control the allowed login methods via Super Admin (#12892) 2025-11-17 21:55:12 -08:00
sla_policies_controller.rb chore: upgrade ruby version to 3.4.4 (#11524) 2025-05-21 19:40:07 +05:30