21 Commits
Author SHA1 Message Date
Brenda Wallace 0f8942508e Refactor API request handling: introduce RequestShape concern, update query and request body validation, and enhance link handling in specs 2026-10-26 20:45:16 +13:00
Brenda Wallace a4a44389d4 Add query shape validation and related tests for API requests 2026-10-26 20:40:16 +13:00
Brenda Wallace a79f24cf5e Refactor API controllers and specs for improved request handling and error responses 2026-10-25 18:44:05 +13:00
Brenda Wallace 1135c763de Tidy API resources: read_only and owned macros, private hook helpers
Declare read-only resources and the owner relationship once each, make
the resource hook helpers private, simplify token auth, and cache the
generated API docs for an hour.
2026-10-25 11:48:28 +13:00
Brenda Wallace 086140205d fixing authorize in the APi 2026-10-25 11:44:02 +13:00
Brenda Wallace e7387a37e0 Add API tests for dashed keys, resource ownership, and write operations
- Implement tests for handling dashed attribute names in API responses and requests in `dashed_keys_request_spec.rb`.
- Enhance error handling tests in `errors_request_spec.rb` for invalid filters and attributes.
- Refactor garden, harvest, and seed request specs to use shared examples for resource write operations.
- Introduce shared examples in `api_writes.rb` to streamline testing of create, update, and delete actions across various resources.
- Update pagination and sorting tests to include new scenarios for offsets and computed attributes.
- Remove redundant code and improve test clarity by utilizing shared contexts and helper methods.
2026-10-24 18:19:11 +13:00
Brenda Wallace 200514c5cc Refactor API controllers and resources to remove redundant resource_class assignments and improve parameter handling in API documentation 2026-10-24 18:19:11 +13:00
Brenda Wallace c87a164b0a Refactor code structure for improved readability and maintainability 2026-10-24 18:19:11 +13:00
Brenda Wallace 73f62d4983 Add API resources for photos, plantings, and seeds; update application configuration
- Introduced `PhotoResource`, `PlantingResource`, and `SeedResource` to manage respective models.
- Updated application configuration to include API base URL.
- Modified production and test environments to set API base URL dynamically.
- Removed outdated JSONAPI resources initializers and patches.
- Refactored routes to use resourceful routing for API endpoints.
- Updated request specs to reflect changes in API responses and relationships.
- Added helper methods for generating related links in request specs.
2026-10-24 18:19:11 +13:00
Brenda Wallace a0b24381ac Refactor activities to jobs across the application
- Renamed all instances of 'Activity' to 'Job' in views, controllers, and models.
- Updated routes to reflect the change from activities to jobs.
- Modified database schema to rename the activities table to jobs and adjusted related columns.
- Updated locale files to change activity-related translations to jobs.
- Adjusted tests to ensure they reference jobs instead of activities.
- Removed the category field from jobs as they are now a plain list.
- Updated seed data and sample data generation to create jobs instead of activities.
2026-10-22 17:16:25 +13:00
Brenda Wallace 77bf9d5e92 Rename activities to jobs and update related files for consistency 2026-10-22 17:06:55 +13:00
Brenda Wallace 26a7b196f7 Move crop search to postgres (no elasticsearch) 2026-10-21 12:58:48 +13:00
Brenda Wallace 238880ef36 Revert "Refactor crop search functionality to use Postgres extensions for improved matching and update pagination logic"
This reverts commit 998a362b34.
2026-10-21 08:22:10 +13:00
Brenda Wallace 998a362b34 Refactor crop search functionality to use Postgres extensions for improved matching and update pagination logic 2026-10-21 08:06:42 +13:00
5ada7e7f77 Add crops search API endpoint (#4622)
* Add crops search API endpoint

- Added GET /api/v1/crops/search endpoint.
- Updated CropSearchService to support additional search options.
- Manually updated Swagger documentation in swagger/v1/swagger.json.
- Added request specs to verify the new endpoint.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Add crops search API endpoint

- Added GET /api/v1/crops/search endpoint.
- Updated CropSearchService to support additional search options.
- Manually updated Swagger documentation in swagger/v1/swagger.json.
- Added request specs to verify the new endpoint.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-05-04 18:12:36 +09:30
google-labs-jules[bot]andDaniel O'Connor 02db5b8130 Add API token generation, authentication, and CRUD for a number of the API resources (#4237)
* feat: Add API token generation and authentication

This commit introduces API token generation and authentication for write operations.

- Adds a section to the user's profile edit page to generate and display an API token.
- Reuses the `authentications` table to store the API token, avoiding the need for a database migration.
- Implements token-based authentication for the API using the `Authorization: Token token=...` header.
- Enables write operations for all API resources and ensures they are protected by the new authentication mechanism.
- Adds feature and request specs to test the new functionality.

* feat: Add API token generation and authentication

This commit introduces API token generation and authentication for write operations.

- Adds a section to the user's profile edit page to generate and display an API token.
- Reuses the `authentications` table to store the API token, avoiding the need for a database migration.
- Implements token-based authentication for the API using the `Authorization: Token token=...` header.
- Enables write operations for all API resources and ensures they are protected by the new authentication mechanism.
- Adds feature and request specs to test the new functionality.

* Mark as editable

* Refactor

* WIP - Authentication

* Implement more test coverage

* Split 401 and 403

* Before Create hooks

* Update harvest specs, defaulting to the first plant part - this may not be right

* Update coverage

* Update coverage

* Rubocop

* Rubocop

* Rubocop

* Fix coverage

* For now, mark photos immutable again

* Fix specs

* Fix specs

* Rubocop

* Fix specs

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Daniel O'Connor <daniel.oconnor@gmail.com>
2025-09-10 19:50:06 +09:30
google-labs-jules[bot] e5c71f1dc4 Merge pull request #4230 from Growstuff/feature/add-more-filters
feat: Add more filters to API resources
2025-09-09 21:34:49 +09:30
Brenda 7257b2ada1 Update with frozen literals 2020-01-10 16:50:52 +13:00
Brenda Wallace fc0058d677 all our api controllers inheriting from base 2017-11-13 19:19:18 +13:00
Brenda Wallace d07fd1a277 Added seeds and harvests to api, and tidied up resources 2017-11-13 19:19:18 +13:00
Brenda Wallace c96695258b Basic read only api 2017-11-13 19:19:18 +13:00