aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src/http-client/types.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-10-19 02:44:28 -0300
committerSebastian <sebasjm@gmail.com>2023-10-19 02:56:14 -0300
commitf89e27a4e39412c4863fe26f821988a65ecec1b9 (patch)
tree2bc1a5c3971a38fa32268593ccce69f0281858e6 /packages/taler-util/src/http-client/types.ts
parentc6968c3c21d70bd76ce50f232650d183fa8cfa6e (diff)
downloadwallet-core-f89e27a4e39412c4863fe26f821988a65ecec1b9.tar.xz
update api
Diffstat (limited to 'packages/taler-util/src/http-client/types.ts')
-rw-r--r--packages/taler-util/src/http-client/types.ts56
1 files changed, 54 insertions, 2 deletions
diff --git a/packages/taler-util/src/http-client/types.ts b/packages/taler-util/src/http-client/types.ts
index 66ac39f59..5a76981df 100644
--- a/packages/taler-util/src/http-client/types.ts
+++ b/packages/taler-util/src/http-client/types.ts
@@ -1,6 +1,58 @@
import { codecForAmountString } from "../amounts.js";
import { Codec, buildCodecForObject, buildCodecForUnion, codecForBoolean, codecForConstString, codecForEither, codecForList, codecForMap, codecForNumber, codecForString, codecOptional } from "../codec.js";
import { codecForTimestamp } from "../time.js";
+import { TalerErrorDetail } from "../wallet-types.js";
+
+
+export type UserAndPassword = {
+ username: string,
+ password: string,
+}
+
+export type UserAndToken = {
+ username: string,
+ token: AccessToken,
+}
+
+export type PaginationParams = {
+ /**
+ * row identifier as the starting point of the query
+ */
+ offset?: string,
+ /**
+ * max number of element in the result response
+ * always greater than 0
+ */
+ limit?: number,
+ /**
+ * milliseconds the server should wait for at least one result to be shown
+ */
+ timoutMs?: number,
+ /**
+ * order
+ */
+ order: "asc" | "dec"
+}
+
+export type OperationResult<Body, ErrorEnum> =
+ | OperationOk<Body>
+ | OperationFail<ErrorEnum>;
+
+export interface OperationOk<T> {
+ type: "ok",
+ body: T;
+}
+export function isOperationOk<T, E>(c: OperationResult<T, E>): c is OperationOk<T> {
+ return c.type === "ok"
+}
+export function isOperationFail<T, E>(c: OperationResult<T, E>): c is OperationFail<E> {
+ return c.type === "fail"
+}
+export interface OperationFail<T> {
+ type: "fail",
+ case: T,
+ detail: TalerErrorDetail,
+}
///
@@ -502,14 +554,14 @@ export const codecForAddIncomingResponse =
type EmailAddress = string;
type PhoneNumber = string;
-type DecimalNumber = string;
+type DecimalNumber = number;
const codecForURL = codecForString
const codecForLibtoolVersion = codecForString
const codecForCurrencyName = codecForString
const codecForPaytoURI = codecForString
const codecForTalerWithdrawalURI = codecForString
-const codecForDecimalNumber = codecForString
+const codecForDecimalNumber = codecForNumber
enum TanChannel {
SMS = "sms",