/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2015 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
                       := 'Footer';

BEGIN

  xxas_com_sr_pkg.set_rest_service
    (p_service_name       => l_SERVICE
    ,p_description        => 'Footer Content'
    ,p_path               => '/footer'
    ,p_consumes           => 'application/xml'
    ,p_produces           => 'application/xml');

  
  xxas_com_sr_pkg.set_rest_method
    (p_service_name       => l_SERVICE
    ,p_method_name        => 'Footer'
    ,p_description        => 'Get footer data'
    ,p_methods            => 'GET'
    ,p_remove_root_ele    => true
    ,p_sql                =>
      q'[
        SELECT XMLElement
				("data"
					,XMLAttributes
                        ('true' as "json:force-array"
						,'http://json.org/' as "xmlns:json")
                    ,XMLAgg
						(XMLElement
							("footer"
								,XMLForest
                                    (XMLElement
                                        ("options"
                                        ,XMLForest
                                            (xxas_com_msg_pkg.get_string('XXAS_FOOTER_COLOR') as "backgroundColor"
                                            ,xxas_com_msg_pkg.get_string('XXAS_FOOTER_FULL_WIDTH') as "fullWidth"
                                            )
                                        ) as "meta"
                                    ,xxas_com_msg_pkg.get_string('XXAS_FOOTER_CSS')  as "css"
                                    ,xxas_com_msg_pkg.get_string('XXAS_FOOTER_HTML')  as "html"
                                    )
                            )
						)
				) "data"
        FROM dual
        ]'
    );

END;
/
COMMIT;
EXIT;
