info:
  name: Multiple Resource Types
  type: http
  seq: 3
http:
  method: GET
  url: '{{base_url}}/api/saved-filters?resource_type={{resource_type}}'
  auth: inherit

docs: |-
  ## Multiple Resource Types

  Tests that the saved filters system works correctly with different resource types (media-items, collections, devices, etc.).

  **Scenario:**
  1. Create filters for different resource types
  2. Verify filters are scoped correctly by resource_type
  3. Test that same filter name can exist for different resource types

  **Test Steps:**

  **Step 1: Create filters for different resource types**
  ```bash
  # Create filter for media-items
  curl -X POST \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "My Favorites",
      "resource_type": "media-items",
      "filters": {"genre_filter": "Science Fiction"}
    }' \
    "{{base_url}}/api/saved-filters"

  # Create filter for collections (same name!)
  curl -X POST \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "My Favorites",
      "resource_type": "collections",
      "filters": {"sort_by": "name"}
    }' \
    "{{base_url}}/api/saved-filters"

  # Create filter for devices (same name!)
  curl -X POST \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "My Favorites",
      "resource_type": "devices",
      "filters": {"device_type": "ereader"}
    }' \
    "{{base_url}}/api/saved-filters"
  ```

  **Step 2: List filters by resource type**
  ```bash
  # Get only media-items filters
  curl -H "Authorization: Bearer YOUR_TOKEN" \
    "{{base_url}}/api/saved-filters?resource_type=media-items"

  # Expected response:
  # [
  #   {
  #     "id": "...",
  #     "name": "My Favorites",
  #     "resource_type": "media-items",
  #     "filters": {"genre_filter": "Science Fiction"},
  #     ...
  #   }
  # ]

  # Get only collections filters
  curl -H "Authorization: Bearer YOUR_TOKEN" \
    "{{base_url}}/api/saved-filters?resource_type=collections"

  # Expected response:
  # [
  #   {
  #     "id": "...",
  #     "name": "My Favorites",
  #     "resource_type": "collections",
  #     "filters": {"sort_by": "name"},
  #     ...
  #   }
  # ]

  # Get only devices filters
  curl -H "Authorization: Bearer YOUR_TOKEN" \
    "{{base_url}}/api/saved-filters?resource_type=devices"

  # Expected response:
  # [
  #   {
  #     "id": "...",
  #     "name": "My Favorites",
  #     "resource_type": "devices",
  #     "filters": {"device_type": "ereader"},
  #     ...
  #   }
  # ]
  ```

  **Expected Behavior:**
  - Same filter name allowed for different resource types
  - Each resource_type query returns only that type's filters
  - resource_type parameter is REQUIRED (no "get all" endpoint)
  - Missing resource_type returns 400 Bad Request

  **Validation:**
  ```bash
  # Test missing resource_type parameter
  curl -H "Authorization: Bearer YOUR_TOKEN" \
    "{{base_url}}/api/saved-filters"

  # Expected: 400 Bad Request
  # {
  #   "error": "resource_type query parameter is required"
  # }
  ```

  **Use Cases:**
  - **media-items**: Filter books by genre, author, series, etc.
  - **collections**: Filter collections by name, book count, etc.
  - **devices**: Filter devices by type, sync status, etc.
  - **Extensible**: New resource types can be added without schema changes

  **Filter Structure by Resource Type:**

  **Media Items Filter Fields:**
  ```json
  {
    "search": "keyword",
    "author_filter": "Author Name",
    "genre_filter": "Science Fiction",
    "series_filter": "Series Name",
    "language_filter": "en",
    "year_min": "2000",
    "year_max": "2024",
    "sort": "title ASC"
  }
  ```

  **Collections Filter Fields:**
  ```json
  {
    "sort_by": "name",
    "order": "asc",
    "include_auto": "true"
  }
  ```

  **Devices Filter Fields:**
  ```json
  {
    "device_type": "ereader",
    "sync_enabled": "true",
    "sort": "last_sync DESC"
  }
  ```

  **Benefits of Generic Design:**
  - Single endpoint handles all resource types
  - No need for separate endpoints per resource
  - Flexible JSONB storage allows any filter structure
  - Easy to add new resource types in future
