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

BEGIN

  xxas_com_sr_pkg.set_rest_service
    (p_service_name       => l_SERVICE
    ,p_description        => 'MSSReviewPage'
    ,p_consumes           => 'application/xml'
    ,p_produces           => 'application/xml'
    ,p_path               => 'mss-review-page');

  xxas_com_sr_pkg.set_rest_method
    (p_service_name       => l_SERVICE
    ,p_method_name        => 'ChangeAssignmentReviewPage'
    ,p_description        => 'Creates the Change Assignment Review Page'
    ,p_methods            => 'POST'
    ,p_path               => 'change-asg'
    ,p_plsql              =>
      q'[
        DECLARE
          l_resp xxas_http_resp_obj;
        BEGIN
          l_resp := xxas_http_response
                      .ok(xxas_change_assignment_pkg.submit_review_change_asg
                            (p_form_data_xml        => {requestBody}
                            ,p_source_block         => {requestParam.sourceBlock}
                            ,p_person_id            => {requestParam.personId}
                            ,p_assignment_id        => {requestParam.asgId}
                            ,p_transaction_id       => {requestParam.transId}
                            ,p_transaction_step_id  => {requestParam.transStepId}
                            )
                         )
                      .build();

         {response} := l_resp;

        END
      ]'
    );

  xxas_com_sr_pkg.set_rest_method
    (p_service_name       => l_SERVICE
    ,p_method_name        => 'ChangeManagerReviewPage'
    ,p_description        => 'Creates the Change Manager Review Page'
    ,p_methods            => 'POST'
    ,p_path               => 'change-mgr'
    ,p_plsql              =>
      q'[
        DECLARE
          l_resp xxas_http_resp_obj;
        BEGIN
          l_resp := xxas_http_response
                      .ok(xxas_change_manager_pkg.submit_review_change_manager
                            (p_form_data_xml        => {requestBody}
                            ,p_source_block         => {requestParam.sourceBlock}
                            ,p_person_id            => {requestParam.personId}
                            ,p_assignment_id        => {requestParam.asgId}
                            ,p_transaction_id       => {requestParam.transId}
                            ,p_transaction_step_id  => {requestParam.transStepId}
                            )
                         )
                      .build();

         {response} := l_resp;

        END
      ]'
    );

  xxas_com_sr_pkg.set_rest_method
    (p_service_name       => l_SERVICE
    ,p_method_name        => 'EmpLeaverReqReviewPage'
    ,p_description        => 'Creates the Employee Leaver Request Review Page'
    ,p_methods            => 'POST'
    ,p_path               => 'emp-leaver-req'
    ,p_plsql              =>
      q'[
        DECLARE
          l_resp xxas_http_resp_obj;
        BEGIN
          l_resp := xxas_http_response
                      .ok(xxas_periods_of_service_pkg.submit_review_emp_leaver_req
                            (p_form_data_xml        => {requestBody}
                            ,p_source_block         => {requestParam.sourceBlock}
                            ,p_person_id            => {requestParam.personId}
                            ,p_transaction_id       => {requestParam.transId}
                            ,p_transaction_step_id  => {requestParam.transStepId}
                            )
                         )
                      .build();

         {response} := l_resp;

        END
      ]'
    );

  xxas_com_sr_pkg.set_rest_method
    (p_service_name       => l_SERVICE
    ,p_method_name        => 'CWKLeaverReqReviewPage'
    ,p_description        => 'Creates the CWK Employee Leaver Request Review Page'
    ,p_methods            => 'POST'
    ,p_path               => 'cwk-leaver-req'
    ,p_plsql              =>
      q'[
        DECLARE
          l_resp xxas_http_resp_obj;
        BEGIN
          l_resp := xxas_http_response
                      .ok(xxas_periods_of_placement_pkg.submit_review_cwk_leaver_req
                            (p_form_data_xml        => {requestBody}
                            ,p_source_block         => {requestParam.sourceBlock}
                            ,p_person_id            => {requestParam.personId}
                            ,p_transaction_id       => {requestParam.transId}
                            ,p_transaction_step_id  => {requestParam.transStepId}
                            )
                         )
                      .build();

         {response} := l_resp;

        END
      ]'
    );

  xxas_com_sr_pkg.set_rest_method
    (p_service_name       => l_SERVICE
    ,p_method_name        => 'ChangePayReviewPage'
    ,p_description        => 'Creates the Change Pay Review Page'
    ,p_methods            => 'POST'
    ,p_path               => 'change-pay'
    ,p_plsql              =>
      q'[
        DECLARE
          l_resp xxas_http_resp_obj;
        BEGIN
          l_resp := xxas_http_response
                      .ok(xxas_change_pay_pkg.submit_review_change_pay
                            (p_form_data_xml        => {requestBody}
                            ,p_source_block         => {requestParam.sourceBlock}
                            ,p_person_id            => {requestParam.personId}
                            ,p_assignment_id        => {requestParam.asgId}
                            ,p_transaction_id       => {requestParam.transId}
                            ,p_transaction_step_id  => {requestParam.transStepId}
                            )
                         )
                      .build();

         {response} := l_resp;

        END
      ]'
    );

END;
/
COMMIT;
EXIT;
