/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2014 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
                       := 'Roles';
                       
BEGIN
      
  xxas_com_sr_pkg.set_rest_service
    (p_service_name       => l_SERVICE
    ,p_description        => 'Manage roles' 
    ,p_path               => 'roles'    
    ,p_consumes           => 'application/xml'
    ,p_produces           => 'application/xml'
    );
       
  xxas_com_sr_pkg.set_rest_method
    (p_service_name       => l_SERVICE
    ,p_method_name        => 'DeleteRole'
    ,p_description        => 'Deletes a role'
    ,p_methods            => 'DELETE'
    ,p_path               => '{roleId}'
    ,p_plsql              =>
      q'[
        DECLARE
        
          l_xml         XMLType;
          l_resp        xxas_http_resp_obj;
          
        BEGIN
        
          xxas_roles_pkg.delete_row
            (p_role_id => {pathParam.roleId});
              
          l_resp := xxas_http_response
                      .ok(xxas_com_msg_pkg.get_success_message_xml
                           (xxas_com_msg_type
                         (xxas_util_pkg.app, 'XXAS_COM_CHNG_SAVE', null)
                       ,'self')
                         )
                      .build();
         
         {response} := l_resp;                

        END
      ]'
    );
    
    
END;
/
COMMIT;
EXIT;
