/* $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
                       := 'PersonJobAvailability';

BEGIN

  xxas_com_sr_pkg.set_rest_service
    (p_service_name       => l_SERVICE
    ,p_description        => 'Person Job Availability'
    ,p_path               => '/people/{personId}/jobs/{jobId}/availability'
    ,p_consumes           => 'application/xml'
    ,p_produces           => 'application/xml'
    );
   
  xxas_com_sr_pkg.set_rest_method
    (p_service_name       => l_SERVICE
    ,p_method_name        => 'GetJobAvailability'
    ,p_description        => 'Get a person''s job availability'
    ,p_methods            => 'GET'
    ,p_sql                =>
      q'[
    SELECT XMLForest
             (xxas_com_avail_pkg.get_free_busy({pathParam.jobId}) AS "freeBusy"
             ,xxas_com_avail_pkg.get_color({pathParam.jobId}) AS "color"
             ,xxas_com_avail_pkg.get_availability({pathParam.jobId}) AS "title"
             ,xxas_com_avail_pkg.get_description({pathParam.jobId}) AS "description"
             ,xxas_com_avail_pkg.get_update_datetime({pathParam.jobId}) AS "lastUpdated"
             ,lower(xxas_com_avail_pkg.get_icon({pathParam.jobId})) AS "icon"
             ) "data"
    FROM  dual
    WHERE xxas_com_avail_pkg.get_free_busy({pathParam.jobId}) &lt;&gt; 'U'
        ]'
    );
    
END;
/
COMMIT;
EXIT;
