/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2017 Applaud Solutions UK Ltd                |
 |                             All rights reserved                            |
 *===========================================================================*/

SET VERIFY OFF
SET FEEDBACK OFF
SET SCAN OFF
WHENEVER OSERROR  EXIT FAILURE ROLLBACK
WHENEVER SQLERROR EXIT FAILURE ROLLBACK

DECLARE

  --
  -- Local constants and variables
  --
  l_SERVICE CONSTANT xxas_com_service_repository.service_name%TYPE
                       := 'Accruals';

BEGIN

  xxas_com_sr_pkg.set_rest_service
    (p_service_name       => l_SERVICE
    ,p_description        => 'Accruals'
    ,p_consumes           => 'application/xml'
    ,p_produces           => 'application/xml'
    ,p_path               => 'accruals');

  xxas_com_sr_pkg.set_rest_method
    (p_service_name       => l_SERVICE
    ,p_method_name        => 'FindAccrualPlansForTeam'
    ,p_description        => 'Find all accrual plans enrolled in a team'
    ,p_methods            => 'GET'
    ,p_path               => '{managerPersonId}/most-entitlement-left'
    ,p_remove_root_ele    => true
    ,p_sql                =>
      q'[
        SELECT  XMLELEMENT("ROW"
                         ,XMLFOREST({pathParam.managerPersonId}  PERSON_ID
                                   ,{requestParam.accrualPlanId} ACCRUAL_PLAN_ID
                                   ,{requestParam.savedSearchId} SAVED_SEARCH_ID
                                   ,{requestParam.uomName}       UOM_NAME)) "data"
        FROM    DUAL
        ]'
    );
    
END;
/
COMMIT;
EXIT;
