(Object path, Object... optionalArgs)
| 7941 | } |
| 7942 | |
| 7943 | public Object sign(Object path, Object... optionalArgs) |
| 7944 | { |
| 7945 | Object api = Helpers.getArg(optionalArgs, 0, new java.util.ArrayList<Object>(java.util.Arrays.asList())); |
| 7946 | Object method = Helpers.getArg(optionalArgs, 1, "GET"); |
| 7947 | Object parameters = Helpers.getArg(optionalArgs, 2, new java.util.HashMap<String, Object>() {{}}); |
| 7948 | Object headers = Helpers.getArg(optionalArgs, 3, null); |
| 7949 | Object body = Helpers.getArg(optionalArgs, 4, null); |
| 7950 | Object authentication = Helpers.GetValue(api, 0); // public, private |
| 7951 | Object type = Helpers.GetValue(api, 1); // spot, margin, future, delivery |
| 7952 | Object query = this.omit(parameters, this.extractParams(path)); |
| 7953 | Object containsSettle = Helpers.isGreaterThan(Helpers.getIndexOf(path, "settle"), Helpers.opNeg(1)); |
| 7954 | if (Helpers.isTrue(Helpers.isTrue(containsSettle) && Helpers.isTrue(((String)path).endsWith(((String)"batch_cancel_orders"))))) |
| 7955 | { |
| 7956 | // special case where we need to extract the settle from the path |
| 7957 | // but the body is an array of strings |
| 7958 | Object settle = this.safeDict(parameters, 0); |
| 7959 | path = this.implodeParams(path, settle); |
| 7960 | // remove the first element from params |
| 7961 | Object newParams = new java.util.ArrayList<Object>(java.util.Arrays.asList()); |
| 7962 | Object anyParams = ((Object)parameters); |
| 7963 | for (var i = 1; Helpers.isLessThan(i, Helpers.getArrayLength(anyParams)); i++) |
| 7964 | { |
| 7965 | ((java.util.List<Object>)newParams).add(Helpers.GetValue(parameters, i)); |
| 7966 | } |
| 7967 | parameters = newParams; |
| 7968 | query = newParams; |
| 7969 | } else if (Helpers.isTrue(Helpers.isArray(parameters))) |
| 7970 | { |
| 7971 | // endpoints like createOrders use an array instead of an object |
| 7972 | // so we infer the settle from one of the elements |
| 7973 | // they have to be all the same so relying on the first one is fine |
| 7974 | Object first = this.safeValue(parameters, 0, new java.util.HashMap<String, Object>() {{}}); |
| 7975 | path = this.implodeParams(path, first); |
| 7976 | } else |
| 7977 | { |
| 7978 | path = this.implodeParams(path, parameters); |
| 7979 | } |
| 7980 | Object endPart = ((Helpers.isTrue((Helpers.isEqual(path, ""))))) ? "" : (Helpers.add("/", path)); |
| 7981 | Object entirePath = Helpers.add(Helpers.add("/", type), endPart); |
| 7982 | if (Helpers.isTrue(Helpers.isTrue((Helpers.isEqual(type, "subAccounts"))) || Helpers.isTrue((Helpers.isEqual(type, "withdrawals"))))) |
| 7983 | { |
| 7984 | entirePath = endPart; |
| 7985 | } |
| 7986 | Object url = Helpers.GetValue(Helpers.GetValue(Helpers.GetValue(this.urls, "api"), authentication), type); |
| 7987 | if (Helpers.isTrue(Helpers.isEqual(url, null))) |
| 7988 | { |
| 7989 | throw new NotSupported((String)Helpers.add(Helpers.add(Helpers.add(this.id, " does not have a testnet for the "), type), " market type.")) ; |
| 7990 | } |
| 7991 | url = Helpers.add(url, entirePath); |
| 7992 | if (Helpers.isTrue(Helpers.isEqual(authentication, "public"))) |
| 7993 | { |
| 7994 | if (Helpers.isTrue(Helpers.getArrayLength(Helpers.objectKeys(query)))) |
| 7995 | { |
| 7996 | url = Helpers.add(url, Helpers.add("?", this.urlencode(query))); |
| 7997 | } |
| 7998 | } else |
| 7999 | { |
| 8000 | this.checkRequiredCredentials(); |
nothing calls this directly
no test coverage detected