@dc-qash/sdk 1.2.2 → 1.3.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/dist/lib.d.ts CHANGED
@@ -16,6 +16,33 @@ export type Partner = {
16
16
  revoked_at: number | null;
17
17
  logo_url: string | null;
18
18
  };
19
+ export type CheckingAccountCreationData = {
20
+ account_holder: string;
21
+ label: string;
22
+ currency: string;
23
+ metadata?: Record<string, any> | string | null;
24
+ };
25
+ export type BaseAccount = {
26
+ _id: string;
27
+ type: "checking_account" | "partner_settlement";
28
+ responsible_partner: string;
29
+ label: string;
30
+ metadata: Record<string, any> | string | null;
31
+ account_holder: string;
32
+ account_number: string;
33
+ currency: string;
34
+ settled_balance: number;
35
+ allowed_overdraft: number;
36
+ created_at: number;
37
+ closed_at: number | null;
38
+ };
39
+ export type CheckingAccount = {
40
+ type: "checking_account";
41
+ };
42
+ export type PartnerSettlementAccount = {
43
+ type: "partner_settlement";
44
+ };
45
+ export type Account = CheckingAccount | PartnerSettlementAccount;
19
46
  export type IndividualAccountHolderCreationData = {
20
47
  name: string;
21
48
  discord_id: string | null;
@@ -28,6 +55,7 @@ export type BaseAccountHolder = {
28
55
  type: "individual" | "business" | "institution";
29
56
  responsible_partner: string;
30
57
  name: string;
58
+ metadata: Record<string, any> | string | null;
31
59
  created_at: number;
32
60
  updated_at: number | null;
33
61
  revoked_at: number | null;
@@ -77,8 +105,9 @@ declare class QashCBS {
77
105
  #private;
78
106
  constructor(sdk: QashSDK);
79
107
  getAccountHolders(): Promise<AccountHolder[]>;
80
- getAccounts(query?: AccountListQuery): Promise<any[]>;
108
+ getAccounts(query?: AccountListQuery): Promise<Account[]>;
81
109
  getAccountHolder(account_holder_id: string): Promise<AccountHolder>;
82
110
  createIndividualAccountHolder(data: IndividualAccountHolderCreationData): Promise<AccountHolder>;
111
+ createCheckingAccount(data: CheckingAccountCreationData): Promise<CheckingAccount>;
83
112
  }
84
113
  export {};
package/dist/lib.js CHANGED
@@ -118,7 +118,6 @@ class QashCBS {
118
118
  });
119
119
  }
120
120
  // Get accounts
121
- // TODO: Account type
122
121
  getAccounts(query = {}) {
123
122
  return new Promise(async (resolve, reject) => {
124
123
  const builtQuery = buildQuery(query);
@@ -161,5 +160,19 @@ class QashCBS {
161
160
  }
162
161
  });
163
162
  }
163
+ // Create account - Checking
164
+ createCheckingAccount(data) {
165
+ return new Promise(async (resolve, reject) => {
166
+ try {
167
+ let _q = await fetch(`${__classPrivateFieldGet(this, _QashCBS_sdk, "f").environment}/v1/cbs/accounts`, { method: "POST", body: JSON.stringify(Object.assign({ type: "checking_account" }, data)), headers: { Authorization: `Basic ${__classPrivateFieldGet(this, _QashCBS_sdk, "f").apiKey}` } }).then(r => r.json());
168
+ if (_q.error || _q.errors)
169
+ throw _q.errors || [_q.error];
170
+ return resolve(_q);
171
+ }
172
+ catch (e) {
173
+ reject(Array.isArray(e) ? e : ["unexpected_issue"]);
174
+ }
175
+ });
176
+ }
164
177
  }
165
178
  _QashCBS_sdk = new WeakMap();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dc-qash/sdk",
3
3
  "type": "module",
4
- "version": "1.2.2",
4
+ "version": "1.3.0",
5
5
  "description": "SDK for Qash, a DemocracyCraft clearing house",
6
6
  "main": "dist/lib.js",
7
7
  "types": "dist/lib.d.ts",