(Object path, Object... optionalArgs)
| 2230 | } |
| 2231 | |
| 2232 | public Object sign(Object path, Object... optionalArgs) |
| 2233 | { |
| 2234 | Object api = Helpers.getArg(optionalArgs, 0, "public"); |
| 2235 | Object method = Helpers.getArg(optionalArgs, 1, "GET"); |
| 2236 | Object parameters = Helpers.getArg(optionalArgs, 2, new java.util.HashMap<String, Object>() {{}}); |
| 2237 | Object headers = Helpers.getArg(optionalArgs, 3, null); |
| 2238 | Object body = Helpers.getArg(optionalArgs, 4, null); |
| 2239 | Object url = Helpers.add("/", this.implodeParams(path, parameters)); |
| 2240 | Object query = this.omit(parameters, this.extractParams(path)); |
| 2241 | if (Helpers.isTrue(Helpers.isEqual(api, "private"))) |
| 2242 | { |
| 2243 | this.checkRequiredCredentials(); |
| 2244 | Object apiKey = this.apiKey; |
| 2245 | if (Helpers.isTrue(Helpers.isLessThan(Helpers.getIndexOf(apiKey, "account"), 0))) |
| 2246 | { |
| 2247 | throw new AuthenticationError((String)Helpers.add(this.id, " sign() requires an account-key, master-keys are not-supported")) ; |
| 2248 | } |
| 2249 | Object nonce = String.valueOf(this.nonce()); |
| 2250 | Object finalUrl = url; |
| 2251 | Object request = this.extend(new java.util.HashMap<String, Object>() {{ |
| 2252 | put( "request", finalUrl ); |
| 2253 | put( "nonce", nonce ); |
| 2254 | }}, query); |
| 2255 | Object payload = this.json(request); |
| 2256 | payload = this.stringToBase64(payload); |
| 2257 | Object signature = this.hmac(this.encode(payload), this.encode(this.secret), sha384()); |
| 2258 | final Object finalPayload = payload; |
| 2259 | headers = new java.util.HashMap<String, Object>() {{ |
| 2260 | put( "Content-Type", "text/plain" ); |
| 2261 | put( "X-GEMINI-APIKEY", GeminiCore.this.apiKey ); |
| 2262 | put( "X-GEMINI-PAYLOAD", finalPayload ); |
| 2263 | put( "X-GEMINI-SIGNATURE", signature ); |
| 2264 | }}; |
| 2265 | } else |
| 2266 | { |
| 2267 | if (Helpers.isTrue(Helpers.getArrayLength(Helpers.objectKeys(query)))) |
| 2268 | { |
| 2269 | url = Helpers.add(url, Helpers.add("?", this.urlencode(query))); |
| 2270 | } |
| 2271 | } |
| 2272 | url = Helpers.add(Helpers.GetValue(Helpers.GetValue(this.urls, "api"), api), url); |
| 2273 | if (Helpers.isTrue(Helpers.isTrue((Helpers.isEqual(method, "POST"))) || Helpers.isTrue((Helpers.isEqual(method, "DELETE"))))) |
| 2274 | { |
| 2275 | body = this.json(query); |
| 2276 | } |
| 2277 | final Object finalUrl = url; |
| 2278 | final Object finalMethod = method; |
| 2279 | final Object finalBody = body; |
| 2280 | final Object finalHeaders = headers; |
| 2281 | return new java.util.HashMap<String, Object>() {{ |
| 2282 | put( "url", finalUrl ); |
| 2283 | put( "method", finalMethod ); |
| 2284 | put( "body", finalBody ); |
| 2285 | put( "headers", finalHeaders ); |
| 2286 | }}; |
| 2287 | } |
| 2288 | |
| 2289 | public Object handleErrors(Object httpCode, Object reason, Object url, Object method, Object headers, Object body, Object response, Object requestHeaders, Object requestBody) |
nothing calls this directly
no test coverage detected