-
Notifications
You must be signed in to change notification settings - Fork 0
/
assets.groovy
44 lines (38 loc) · 1.26 KB
/
assets.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import dynapiclient.rest.*
import dynapiclient.jsonrpc.*
import dynapiclient.auth.*
// *** Keys intended to be defined in local ~/.groovy/assets_secret.groovy
if (auth.marvel.isEmpty()) {
auth {
marvel {
publicKey = '<undefined>'
privateKey = '<undefined>'
}
}
}
rest {
jsonplaceholder = new RestDynClient(
base: 'http://jsonplaceholder.typicode.com/')
marvel = new RestDynClient(
base: 'http://gateway.marvel.com/',
path: '/v1/public',
paramsHandler: this.&marvelAuthenticate,
metaLoader: { new OpenApiDoc(it) },
exceptionOnError: false
)
}
jsonrpc {
kanboard = new JsonRpcClient(
base: 'http://demo.kanboard.net/jsonrpc.php',
clientHandler: { it.auth.basic 'demo', 'demo123' }
)
random = new JsonRpcClient(
base: 'https://api.random.org/json-rpc/1/invoke',
paramsHandler: { (it instanceof Map? it : [:]) + [apiKey: auth.random.apiKey] }
)
}
void marvelAuthenticate(Map callParams, String method) {
def ts = System.currentTimeMillis().toString()
def hash = EncryptionUtils.md5(ts + auth.marvel.privateKey + auth.marvel.publicKey)
callParams.query += [apikey: auth.marvel.publicKey, hash: hash, ts: ts]
}