Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xquery version "3.0";
- module namespace DeviceResource="http://haptixgames.com/h2flow/api/DeviceResource";
- import module namespace functx = "http://www.functx.com";
- import module namespace xqjson="http://xqilla.sourceforge.net/lib/xqjson";
- (: import module namespace objectifier="http://haptixgames.com/xqjson/xml/objectifier" at "/db/apps/shared/modules/xqjson-objectifier.xql"; :)
- declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
- declare function DeviceResource:execute($http-invocation as map, $http-methods as map)
- {
- (:blah:)
- <a><some>data</some></a>
- };
- declare
- %rest:POST("{$payload}")
- %rest:path("/h2flow/devices")
- %rest:query-param("token", "{$api-token}", "null")
- %rest:query-param("method", "{$http-method}", "GET")
- %rest:consumes("application/vnd.com.haptixgames.v1+png") (: Content-Type :) (: add to mime-types.xml :)
- %rest:produces("application/vnd.com.haptixgames.v1+png") (: Accept :)
- %output:media-type("image/png")
- function DeviceResource:png($api-token as xs:string*, $http-method as xs:string*, $payload as xs:Base64Binary)
- {
- let $http-invocation := map
- {
- 'consumes' := "application/vnd.com.haptixgames.v1+png",
- 'produces' := "application/vnd.com.haptixgames.v1+png",
- 'api-token' := $api-token,
- 'http-method' := $http-method,
- 'payload' := $payload
- }
- let $http-methods := map
- {
- 'GET' := map
- {
- 'function' := DeviceResource:png-GET($payload),
- 'authenticated' := true()
- },
- 'POST' := map
- {
- 'function' := DeviceResource:png-POST($payload),
- 'authenticated' := true()
- },
- 'PUT' := map
- {
- 'function' := DeviceResource:png-PUT($payload),
- 'authenticated' := true()
- },
- 'DELETE' := map
- {
- 'function' := DeviceResource:png-DELETE($payload),
- 'authenticated' := true()
- }
- }
- return DeviceResource:execute($http-invocation, $http-methods)
- };
- declare
- %rest:POST("{$payload}")
- %rest:path("/h2flow/devices")
- %rest:query-param("token", "{$api-token}", "null")
- %rest:query-param("method", "{$http-method}", "GET")
- %rest:consumes("application/vnd.com.haptixgames.v1+json") (: Content-Type :)
- %rest:produces("application/vnd.com.haptixgames.v1+json") (: Accept :)
- %output:media-type("application/json")
- %output:method("json")
- function DeviceResource:json($api-token as xs:string*, $http-method as xs:string*, $payload as xs:string)
- {
- let $http-invocation := map
- {
- 'consumes' := "application/vnd.com.haptixgames.v1+json",
- 'produces' := "application/vnd.com.haptixgames.v1+json",
- 'api-token' := $api-token,
- 'http-method' := $http-method,
- 'payload' := $payload
- }
- let $http-methods := map
- {
- 'GET' := map
- {
- 'function' := DeviceResource:json-GET($payload),
- 'authenticated' := true()
- },
- 'POST' := map
- {
- 'function' := DeviceResource:json-POST($payload),
- 'authenticated' := true()
- },
- 'PUT' := map
- {
- 'function' := DeviceResource:json-PUT($payload),
- 'authenticated' := true()
- },
- 'DELETE' := map
- {
- 'function' := DeviceResource:json-DELETE($payload),
- 'authenticated' := true()
- }
- }
- return DeviceResource:execute($http-invocation, $http-methods)
- };
- declare %private function DeviceResource:json-GET($payload-json)
- {
- ()
- };
- declare %private function DeviceResource:json-POST($payload-json)
- {
- ()
- };
- declare %private function DeviceResource:json-PUT($payload-json)
- {
- ()
- };
- declare %private function DeviceResource:json-DELETE($payload-json)
- {
- ()
- };
- declare %private function DeviceResource:png-GET($payload-json)
- {
- ()
- };
- declare %private function DeviceResource:png-POST($payload-json)
- {
- ()
- };
- declare %private function DeviceResource:png-PUT($payload-json)
- {
- ()
- };
- declare %private function DeviceResource:png-DELETE($payload-json)
- {
- ()
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement