All files / platform/modules/third-party/src/Controllers/Http ILThirdPartyController.js

100% Statements 10/10
100% Branches 2/2
100% Functions 3/3
100% Lines 10/10

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              6x       6x                                                                 6x 6x 6x 6x   6x                 6x       6x       1x  
'use strict';
 
// const Config = use('Config');
// const namespace = Config.get('modules.thirdParty.general.namespace');
 
class ILThirdPartyController {
  static get inject() {
    return [`C2C/Repositories/ThirdPartyRepo`];
  }
 
  constructor(thirdPartyRepo) {
    this.thirdPartyRepo = thirdPartyRepo;
  }
 
  /**
   * @swagger
   *
   * /api/v1/apps/third-parties:
   *   get:
   *     tags:
   *       - third-parties
   *     operationId: 'getAllThirdPartiesByIL'
   *     summary: 'getAllThirdPartiesByIL'
   *     description: 'Get all third parties by IL'
   *     security:
   *       - BasicAuth: []
   *     parameters:
   *       - $ref: '#/components/parameters/PageParam'
   *       - $ref: '#/components/parameters/LimitParam'
   *       - $ref: '#/components/parameters/SalonConnectedQueryParam'
   *       - $ref: '#/components/parameters/IdsParam'
   *     responses:
   *       200:
   *         description: ok
   *         content:
   *           application/json; charset=utf-8:
   *             schema:
   *               $ref: '#/components/schemas/SystemThirdPartyPaginationResponse'
   *       403:
   *         $ref: '#/components/responses/Forbidden'
   *       500:
   *         description:  system error
   */
  async index({ request, response, transform }) {
    const page = request.input('page', 1);
    const limit = request.input('limit', 10);
    const ids = request.input('ids');
    const salonConnected = request.input('salonConnected');
 
    const thirdParties = await this.thirdPartyRepo.getByPageWithSalonConnection(
      Number(page),
      Number(limit),
      {
        salonConnected: Number(salonConnected),
        ids: ids ? ids.split(',') : [],
      },
    );
 
    const transformed = await transform
      .include('salonFirstConnection,salonLastConnection,salons')
      .paginate(thirdParties, 'ThirdPartyTransformer');
 
    response.success(transformed);
  }
}
 
module.exports = ILThirdPartyController;