Advertisement
Guest User

Untitled

a guest
Feb 26th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 4.93 KB | None | 0 0
  1. xquery version "3.0";
  2.  
  3. module namespace DeviceResource="http://haptixgames.com/h2flow/api/DeviceResource";
  4.  
  5. import module namespace functx = "http://www.functx.com";
  6. import module namespace xqjson="http://xqilla.sourceforge.net/lib/xqjson";
  7.  
  8. (: import module namespace objectifier="http://haptixgames.com/xqjson/xml/objectifier" at "/db/apps/shared/modules/xqjson-objectifier.xql"; :)
  9.  
  10. declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
  11.  
  12. declare function DeviceResource:execute($http-invocation as map, $http-methods as map)
  13. {
  14.     (:blah:)
  15.        
  16.     <a><some>data</some></a>
  17. };
  18.  
  19. declare
  20.     %rest:POST("{$payload}")
  21.     %rest:path("/h2flow/devices")
  22.     %rest:query-param("token", "{$api-token}", "null")
  23.     %rest:query-param("method", "{$http-method}", "GET")
  24.     %rest:consumes("application/vnd.com.haptixgames.v1+png") (: Content-Type :) (: add to mime-types.xml :)
  25.     %rest:produces("application/vnd.com.haptixgames.v1+png") (: Accept :)
  26.     %output:media-type("image/png")
  27. function DeviceResource:png($api-token as xs:string*, $http-method as xs:string*, $payload as xs:Base64Binary)
  28. {
  29.     let $http-invocation := map
  30.     {
  31.         'consumes'      :=  "application/vnd.com.haptixgames.v1+png",
  32.         'produces'      :=  "application/vnd.com.haptixgames.v1+png",
  33.         'api-token'     :=  $api-token,
  34.         'http-method'   :=  $http-method,
  35.         'payload'       :=  $payload
  36.     }
  37.    
  38.     let $http-methods := map
  39.     {
  40.         'GET'       :=  map
  41.                         {
  42.                             'function'      :=  DeviceResource:png-GET($payload),
  43.                             'authenticated' :=  true()
  44.                         },
  45.         'POST'      :=  map
  46.                         {
  47.                             'function'      :=  DeviceResource:png-POST($payload),
  48.                             'authenticated' :=  true()
  49.                         },
  50.         'PUT'       :=  map
  51.                         {
  52.                             'function'      :=  DeviceResource:png-PUT($payload),
  53.                             'authenticated' :=  true()
  54.                         },
  55.         'DELETE'    :=  map
  56.                         {
  57.                             'function'      :=  DeviceResource:png-DELETE($payload),
  58.                             'authenticated' :=  true()
  59.                         }
  60.     }
  61.        
  62.     return DeviceResource:execute($http-invocation, $http-methods)
  63. };
  64.  
  65. declare
  66.     %rest:POST("{$payload}")
  67.     %rest:path("/h2flow/devices")
  68.     %rest:query-param("token", "{$api-token}", "null")
  69.     %rest:query-param("method", "{$http-method}", "GET")
  70.     %rest:consumes("application/vnd.com.haptixgames.v1+json") (: Content-Type :)
  71.     %rest:produces("application/vnd.com.haptixgames.v1+json") (: Accept :)
  72.     %output:media-type("application/json")
  73.     %output:method("json")
  74. function DeviceResource:json($api-token as xs:string*, $http-method as xs:string*, $payload as xs:string)
  75. {
  76.     let $http-invocation := map
  77.     {
  78.         'consumes'      :=  "application/vnd.com.haptixgames.v1+json",
  79.         'produces'      :=  "application/vnd.com.haptixgames.v1+json",
  80.         'api-token'     :=  $api-token,
  81.         'http-method'   :=  $http-method,
  82.         'payload'       :=  $payload
  83.     }
  84.    
  85.     let $http-methods := map
  86.     {
  87.         'GET'       :=  map
  88.                         {
  89.                             'function'      :=  DeviceResource:json-GET($payload),
  90.                             'authenticated' :=  true()
  91.                         },
  92.         'POST'      :=  map
  93.                         {
  94.                             'function'      :=  DeviceResource:json-POST($payload),
  95.                             'authenticated' :=  true()
  96.                         },
  97.         'PUT'       :=  map
  98.                         {
  99.                             'function'      :=  DeviceResource:json-PUT($payload),
  100.                             'authenticated' :=  true()
  101.                         },
  102.         'DELETE'    :=  map
  103.                         {
  104.                             'function'      :=  DeviceResource:json-DELETE($payload),
  105.                             'authenticated' :=  true()
  106.                         }
  107.     }
  108.        
  109.     return DeviceResource:execute($http-invocation, $http-methods)
  110. };
  111.  
  112. declare %private function DeviceResource:json-GET($payload-json)
  113. {
  114.     ()  
  115. };
  116.  
  117. declare %private function DeviceResource:json-POST($payload-json)
  118. {
  119.     ()  
  120. };
  121.  
  122. declare %private function DeviceResource:json-PUT($payload-json)
  123. {
  124.     ()  
  125. };
  126.  
  127. declare %private function DeviceResource:json-DELETE($payload-json)
  128. {
  129.     ()  
  130. };
  131.  
  132. declare %private function DeviceResource:png-GET($payload-json)
  133. {
  134.     ()  
  135. };
  136.  
  137. declare %private function DeviceResource:png-POST($payload-json)
  138. {
  139.     ()  
  140. };
  141.  
  142. declare %private function DeviceResource:png-PUT($payload-json)
  143. {
  144.     ()  
  145. };
  146.  
  147. declare %private function DeviceResource:png-DELETE($payload-json)
  148. {
  149.     ()  
  150. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement