All files / src/lib/api-docs/endpoints wishlist.ts

100% Statements 106/106
100% Branches 0/0
100% Functions 0/0
100% Lines 106/106

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 1071x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * Wishlist Endpoints
 * User wishlist management endpoints
 */
 
import type { ApiEndpoint } from '@/types/api-docs';
 
export const wishlistEndpoints: ApiEndpoint[] = [
  {
    id: 'wishlist-get',
    method: 'GET',
    path: '/api/wishlist',
    summary: 'Get wishlist',
    description: 'Returns all items in the user wishlist',
    category: 'wishlist',
    requiresAuth: true,
    responses: [
      {
        status: 200,
        description: 'Wishlist items',
        example: {
          success: true,
          data: [
            {
              id: 1,
              title: 'Product Name',
              price: 29.99,
              discountedPrice: 24.99,
              reviews: 12,
              averageRating: 4.5,
              imgs: { thumbnails: ['/img1.jpg'], previews: ['/img1-full.jpg'] },
              addedAt: '2024-01-15T10:00:00Z',
            },
          ],
        },
      },
      {
        status: 401,
        description: 'Not authenticated',
        example: { success: false, error: { code: 'UNAUTHORIZED', message: 'Authentication required' } },
      },
    ],
  },
  {
    id: 'wishlist-add',
    method: 'POST',
    path: '/api/wishlist',
    summary: 'Add to wishlist',
    description: 'Adds a product to user wishlist',
    category: 'wishlist',
    requiresAuth: true,
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'productId', type: 'number', required: true, description: 'Product ID to add' },
      ],
      example: { productId: 101 },
    },
    responses: [
      {
        status: 201,
        description: 'Added to wishlist',
        example: { success: true, data: { id: 1, productId: 101, addedAt: '2024-01-15T10:00:00Z' } },
      },
      {
        status: 400,
        description: 'Product already in wishlist',
        example: { success: false, error: { code: 'VALIDATION_ERROR', message: 'Product already in wishlist' } },
      },
      {
        status: 401,
        description: 'Not authenticated',
        example: { success: false, error: { code: 'UNAUTHORIZED', message: 'Authentication required' } },
      },
    ],
  },
  {
    id: 'wishlist-remove',
    method: 'DELETE',
    path: '/api/wishlist/{id}',
    summary: 'Remove from wishlist',
    description: 'Removes a product from user wishlist',
    category: 'wishlist',
    requiresAuth: true,
    parameters: [
      { name: 'id', type: 'number', required: true, location: 'path', description: 'Product ID' },
    ],
    responses: [
      {
        status: 200,
        description: 'Removed from wishlist',
        example: { success: true, data: { message: 'Product removed from wishlist' } },
      },
      {
        status: 404,
        description: 'Product not in wishlist',
        example: { success: false, error: { code: 'NOT_FOUND', message: 'Product not found in wishlist' } },
      },
      {
        status: 401,
        description: 'Not authenticated',
        example: { success: false, error: { code: 'UNAUTHORIZED', message: 'Authentication required' } },
      },
    ],
  },
];