@dc-qash/sdk 1.0.2 → 1.1.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dc-qash/sdk",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.1.0",
5
5
  "description": "SDK for Qash, a DemocracyCraft clearing house",
6
6
  "main": "dist/lib.js",
7
7
  "types": "dist/lib.d.ts",
@@ -10,5 +10,6 @@
10
10
  "private": false,
11
11
  "scripts": {
12
12
  "build": "rm -rf ./dist && tsc"
13
- }
13
+ },
14
+ "files": ["package.json", "dist"]
14
15
  }
package/.prettierrc.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "trailingComma": "es5",
3
- "tabWidth": 2,
4
- "useTabs": true,
5
- "singleQuote": true,
6
- "printWidth": 3000,
7
- "bracketSpacing": true
8
- }
9
-
package/src/lib.ts DELETED
@@ -1,114 +0,0 @@
1
- // Types
2
- export enum QashAPIEnv { PRODUCTION = "https://api.qash.cloud", STAGING = "https://api.staging.qash.cloud", DEV = "https://api.dev.qash.cloud" };
3
- export type Partner = {
4
- _id: string;
5
- name: string;
6
- juridisctions: string[];
7
- currencies: string[];
8
- routing: {
9
- identifier: string;
10
- } | null;
11
- is_cbs_partner: boolean;
12
- joined_at: number;
13
- revoked_at: number | null;
14
- logo_url: string | null;
15
- }
16
- export type IndividualAccountHolderCreationData = {
17
- name: string;
18
- discord_id: string | null;
19
- minecraft_id: string | null;
20
- external_id: string | null;
21
- }
22
- export type BaseAccountHolder = {
23
- _id: string;
24
- type: "individual" | "business" | "institution";
25
- responsible_partner: string;
26
- name: string;
27
- created_at: number;
28
- updated_at: number | null;
29
- revoked_at: number | null;
30
- }
31
- export type IndividualAccountHolder = BaseAccountHolder & {
32
- discord_id: string | null;
33
- minecraft_id: string | null;
34
- external_id: string | null;
35
- }
36
- export type AccountHolder = IndividualAccountHolder;
37
- // SDK
38
- export default class QashSDK {
39
- // Identification
40
- apiKey : string;
41
- environment : QashAPIEnv;
42
- constructor (apiKey : string, environment : QashAPIEnv = QashAPIEnv.PRODUCTION) {
43
- this.apiKey = apiKey;
44
- this.environment = environment;
45
- this.CBS = new QashCBS(this);
46
- }
47
-
48
- // Get authorized partner
49
- getAuthorizedPartner () : Promise<Partner> {
50
- return new Promise(async (resolve, reject) => {
51
- try {
52
- let _q = await fetch(`${this.environment}/v1/partner/@self`, { headers: { Authorization: `Basic ${this.apiKey}` } }).then(r => r.json());
53
- if (_q.error || _q.errors) throw _q.errors || [_q.error];
54
- return resolve(_q);
55
- } catch (e) {
56
- reject(Array.isArray(e) ? e : ["unexpected_issue"]);
57
- }
58
- });
59
- }
60
-
61
- // CBS
62
- public CBS;
63
- }
64
-
65
- // CBS
66
- class QashCBS {
67
- #sdk: QashSDK;
68
-
69
- constructor (sdk: QashSDK) {
70
- this.#sdk = sdk;
71
- }
72
-
73
- // Get account holders
74
- // TODO: search query
75
- getAccountHolders () : Promise<AccountHolder[]> {
76
- return new Promise(async (resolve, reject) => {
77
- try {
78
- let _q = await fetch(`${this.#sdk.environment}/v1/cbs/account-holders`, { headers: { Authorization: `Basic ${this.#sdk.apiKey}` } }).then(r => r.json());
79
- if (_q.error || _q.errors) throw _q.errors || [_q.error];
80
- return resolve(_q);
81
- } catch (e) {
82
- reject(Array.isArray(e) ? e : ["unexpected_issue"]);
83
- }
84
- });
85
- }
86
-
87
- // Get accounts
88
- // TODO: Account type
89
- // TODO: search query
90
- getAccounts () : Promise<any[]> {
91
- return new Promise(async (resolve, reject) => {
92
- try {
93
- let _q = await fetch(`${this.#sdk.environment}/v1/cbs/accounts`, { headers: { Authorization: `Basic ${this.#sdk.apiKey}` } }).then(r => r.json());
94
- if (_q.error || _q.errors) throw _q.errors || [_q.error];
95
- return resolve(_q);
96
- } catch (e) {
97
- reject(Array.isArray(e) ? e : ["unexpected_issue"]);
98
- }
99
- });
100
- }
101
-
102
- // Create account holder - Individual
103
- createIndividualAccountHolder (data: IndividualAccountHolderCreationData) : Promise<AccountHolder> {
104
- return new Promise(async (resolve, reject) => {
105
- try {
106
- let _q = await fetch(`${this.#sdk.environment}/v1/cbs/account-holders`, { method: "POST", body: JSON.stringify(Object.assign({ type: "individual" }, data)), headers: { Authorization: `Basic ${this.#sdk.apiKey}` } }).then(r => r.json());
107
- if (_q.error || _q.errors) throw _q.errors || [_q.error];
108
- return resolve(_q);
109
- } catch (e) {
110
- reject(Array.isArray(e) ? e : ["unexpected_issue"]);
111
- }
112
- });
113
- }
114
- }
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2021",
4
- "module": "es2022",
5
- "moduleResolution": "node",
6
- "esModuleInterop": true,
7
- "forceConsistentCasingInFileNames": true,
8
- "strict": true,
9
- "allowJs": true,
10
- "declaration": true,
11
- "experimentalDecorators": true,
12
- "emitDecoratorMetadata": true,
13
- "outDir": "./dist",
14
- "rootDir": "./src",
15
- "resolveJsonModule": true,
16
- "skipLibCheck": true
17
- },
18
- "include": ["./src/**/*.ts", "./src/**/*.js", "./src/lib.ts"],
19
- "exclude": []
20
- }