@@ -2,6 +2,16 @@ module namespace e = 'http://elifesciences.org/modules/validate';
22import module namespace session = "http://basex.org/modules/session" ;
33import module namespace rest = "http://exquery.org/ns/restxq" ;
44declare namespace svrl = "http://purl.oclc.org/dsdl/svrl" ;
5+ declare variable $e:ror-client-id := fn:environment-variable ('ROR_CLIENT_ID' );
6+
7+ declare
8+ %rest:GET
9+ %rest:path('/ror-test' )
10+ function e:get-ror-client-id () {
11+ if ($e:ror-client-id)
12+ then <result>{$e:ror-client-id}</result>
13+ else <result>Variable was not found.</result>
14+ };
515
616(: Schematron :)
717
@@ -404,6 +414,7 @@ declare function e:introduce-rors($xml as item()) {
404414 let $json := try {
405415 http:send-request (
406416 <http:request method = 'get' href = "{('https://api.ror.org/v2/organizations?affiliation=' ||web:encode-url ($display))} " timeout = '2' >
417+ <http:header name = "Client-Id" value = "{$e:ror-client-id} " />
407418 </http:request>)//*:json }
408419 catch * {<json><number__of__results>0 </number__of__results></json>}
409420 return if ((number ($json//*:number__of__results) = 0 ) or not ($json//*:items/_[number (*:score [1 ]) ge 0.8 ]))
@@ -428,6 +439,7 @@ declare function e:introduce-rors($xml as item()) {
428439 let $json := try {
429440 http:send-request (
430441 <http:request method = 'get' href = "{('https://api.ror.org/v2/organizations?affiliation=' ||web:encode-url ($inst))} " timeout = '2' >
442+ <http:header name = "Client-Id" value = "{$e:ror-client-id} " />
431443 </http:request>)//*:json }
432444 catch * {<json><number__of__results>0 </number__of__results></json>}
433445 return if ((number ($json//*:number__of__results) = 0 ) or not ($json//*:items/_[number (*:score [1 ]) ge 0.8 ]))
@@ -787,6 +799,7 @@ declare function e:get-ror-rows($xml) as element(tr)* {
787799 let $json := try {
788800 http:send-request (
789801 <http:request method = 'get' href = "{('https://api.ror.org/v2/organizations?affiliation=' ||web:encode-url ($display))} " timeout = '2' >
802+ <http:header name = "Client-Id" value = "{$e:ror-client-id} " />
790803 </http:request>)//*:json }
791804 catch * {<json><number__of__results>0 </number__of__results></json>}
792805 where (number ($json//*:number__of__results) gt 0 ) and $json//*:items/_[number (*:score [1 ]) ge 0.8 ]
0 commit comments