@dc-qash/sdk 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib.d.ts +37 -2
- package/dist/lib.js +14 -2
- package/package.json +6 -2
package/dist/lib.d.ts
CHANGED
|
@@ -3,17 +3,52 @@ export declare enum QashAPIEnv {
|
|
|
3
3
|
STAGING = "https://api.staging.qash.cloud",
|
|
4
4
|
DEV = "https://api.dev.qash.cloud"
|
|
5
5
|
}
|
|
6
|
+
export type Partner = {
|
|
7
|
+
_id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
juridisctions: string[];
|
|
10
|
+
currencies: string[];
|
|
11
|
+
routing: {
|
|
12
|
+
identifier: string;
|
|
13
|
+
} | null;
|
|
14
|
+
is_cbs_partner: boolean;
|
|
15
|
+
joined_at: number;
|
|
16
|
+
revoked_at: number | null;
|
|
17
|
+
logo_url: string | null;
|
|
18
|
+
};
|
|
19
|
+
export type IndividualAccountHolderCreationData = {
|
|
20
|
+
name: string;
|
|
21
|
+
discord_id: string | null;
|
|
22
|
+
minecraft_id: string | null;
|
|
23
|
+
external_id: string | null;
|
|
24
|
+
};
|
|
25
|
+
export type BaseAccountHolder = {
|
|
26
|
+
_id: string;
|
|
27
|
+
type: "individual" | "business" | "institution";
|
|
28
|
+
responsible_partner: string;
|
|
29
|
+
name: string;
|
|
30
|
+
created_at: number;
|
|
31
|
+
updated_at: number | null;
|
|
32
|
+
revoked_at: number | null;
|
|
33
|
+
};
|
|
34
|
+
export type IndividualAccountHolder = BaseAccountHolder & {
|
|
35
|
+
discord_id: string | null;
|
|
36
|
+
minecraft_id: string | null;
|
|
37
|
+
external_id: string | null;
|
|
38
|
+
};
|
|
39
|
+
export type AccountHolder = IndividualAccountHolder;
|
|
6
40
|
export default class QashSDK {
|
|
7
41
|
apiKey: string;
|
|
8
42
|
environment: QashAPIEnv;
|
|
9
43
|
constructor(apiKey: string, environment?: QashAPIEnv);
|
|
10
|
-
getAuthorizedPartner(): Promise<
|
|
44
|
+
getAuthorizedPartner(): Promise<Partner>;
|
|
11
45
|
CBS: QashCBS;
|
|
12
46
|
}
|
|
13
47
|
declare class QashCBS {
|
|
14
48
|
#private;
|
|
15
49
|
constructor(sdk: QashSDK);
|
|
16
|
-
getAccountHolders(): Promise<
|
|
50
|
+
getAccountHolders(): Promise<AccountHolder[]>;
|
|
17
51
|
getAccounts(): Promise<any[]>;
|
|
52
|
+
createIndividualAccountHolder(data: IndividualAccountHolderCreationData): Promise<AccountHolder>;
|
|
18
53
|
}
|
|
19
54
|
export {};
|
package/dist/lib.js
CHANGED
|
@@ -26,7 +26,6 @@ export default class QashSDK {
|
|
|
26
26
|
this.CBS = new QashCBS(this);
|
|
27
27
|
}
|
|
28
28
|
// Get authorized partner
|
|
29
|
-
// TODO: Partner type
|
|
30
29
|
getAuthorizedPartner() {
|
|
31
30
|
return new Promise(async (resolve, reject) => {
|
|
32
31
|
try {
|
|
@@ -48,7 +47,6 @@ class QashCBS {
|
|
|
48
47
|
__classPrivateFieldSet(this, _QashCBS_sdk, sdk, "f");
|
|
49
48
|
}
|
|
50
49
|
// Get account holders
|
|
51
|
-
// TODO: AccountHolder type
|
|
52
50
|
// TODO: search query
|
|
53
51
|
getAccountHolders() {
|
|
54
52
|
return new Promise(async (resolve, reject) => {
|
|
@@ -79,5 +77,19 @@ class QashCBS {
|
|
|
79
77
|
}
|
|
80
78
|
});
|
|
81
79
|
}
|
|
80
|
+
// Create account holder - Individual
|
|
81
|
+
createIndividualAccountHolder(data) {
|
|
82
|
+
return new Promise(async (resolve, reject) => {
|
|
83
|
+
try {
|
|
84
|
+
let _q = await fetch(`${__classPrivateFieldGet(this, _QashCBS_sdk, "f").environment}/v1/cbs/account-holders`, { method: "POST", body: JSON.stringify(Object.assign({ type: "individual" }, data)), headers: { Authorization: `Basic ${__classPrivateFieldGet(this, _QashCBS_sdk, "f").apiKey}` } }).then(r => r.json());
|
|
85
|
+
if (_q.error || _q.errors)
|
|
86
|
+
throw _q.errors || [_q.error];
|
|
87
|
+
return resolve(_q);
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
reject(Array.isArray(e) ? e : ["unexpected_issue"]);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
82
94
|
}
|
|
83
95
|
_QashCBS_sdk = new WeakMap();
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dc-qash/sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"description": "SDK for Qash, a DemocracyCraft clearing house",
|
|
6
6
|
"main": "dist/lib.js",
|
|
7
|
+
"types": "dist/lib.d.ts",
|
|
7
8
|
"repository": "https://github.com/luzzardik/qash-js-sdk",
|
|
8
9
|
"author": "Kacy Luzzardi",
|
|
9
|
-
"private": false
|
|
10
|
+
"private": false,
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "rm -rf ./dist && tsc"
|
|
13
|
+
}
|
|
10
14
|
}
|