@dc-qash/sdk 1.1.1 → 1.2.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
@@ -43,12 +43,34 @@ export type AccountListQuery = {
43
43
  holder?: string | string[];
44
44
  currency?: string | string[];
45
45
  };
46
+ export type CurrencyExchangeRate = {
47
+ currency: string;
48
+ rate: number;
49
+ };
50
+ export type CurrencySymbol = {
51
+ value: string;
52
+ is_after: boolean;
53
+ };
54
+ export type Currency = {
55
+ _id: string;
56
+ code: string;
57
+ name: string;
58
+ symbol: CurrencySymbol;
59
+ exchange_rates: CurrencyExchangeRate[];
60
+ };
46
61
  export default class QashSDK {
47
62
  apiKey: string;
48
63
  environment: QashAPIEnv;
49
64
  constructor(apiKey: string, environment?: QashAPIEnv);
50
65
  getAuthorizedPartner(): Promise<Partner>;
51
66
  CBS: QashCBS;
67
+ Datasets: QashDatasets;
68
+ }
69
+ declare class QashDatasets {
70
+ #private;
71
+ constructor(sdk: QashSDK);
72
+ getCurrencies(): Promise<Currency[]>;
73
+ getCurrency(currency_id: string): Promise<Currency>;
52
74
  }
53
75
  declare class QashCBS {
54
76
  #private;
package/dist/lib.js CHANGED
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _QashCBS_sdk;
12
+ var _QashDatasets_sdk, _QashCBS_sdk;
13
13
  // Types
14
14
  export var QashAPIEnv;
15
15
  (function (QashAPIEnv) {
@@ -43,6 +43,7 @@ export default class QashSDK {
43
43
  this.apiKey = apiKey;
44
44
  this.environment = environment;
45
45
  this.CBS = new QashCBS(this);
46
+ this.Datasets = new QashDatasets(this);
46
47
  }
47
48
  // Get authorized partner
48
49
  getAuthorizedPartner() {
@@ -59,6 +60,42 @@ export default class QashSDK {
59
60
  });
60
61
  }
61
62
  }
63
+ // Datasets
64
+ class QashDatasets {
65
+ constructor(sdk) {
66
+ _QashDatasets_sdk.set(this, void 0);
67
+ __classPrivateFieldSet(this, _QashDatasets_sdk, sdk, "f");
68
+ }
69
+ // Get currencies
70
+ getCurrencies() {
71
+ return new Promise(async (resolve, reject) => {
72
+ try {
73
+ let _q = await fetch(`${__classPrivateFieldGet(this, _QashDatasets_sdk, "f").environment}/datasets/currencies`).then(r => r.json());
74
+ if (_q.error || _q.errors)
75
+ throw _q.errors || [_q.error];
76
+ return resolve(_q);
77
+ }
78
+ catch (e) {
79
+ reject(Array.isArray(e) ? e : ["unexpected_issue"]);
80
+ }
81
+ });
82
+ }
83
+ // Get currency
84
+ getCurrency(currency_id) {
85
+ return new Promise(async (resolve, reject) => {
86
+ try {
87
+ let _q = await fetch(`${__classPrivateFieldGet(this, _QashDatasets_sdk, "f").environment}/datasets/currency/${currency_id}`).then(r => r.json());
88
+ if (_q.error || _q.errors)
89
+ throw _q.errors || [_q.error];
90
+ return resolve(_q);
91
+ }
92
+ catch (e) {
93
+ reject(Array.isArray(e) ? e : ["unexpected_issue"]);
94
+ }
95
+ });
96
+ }
97
+ }
98
+ _QashDatasets_sdk = new WeakMap();
62
99
  // CBS
63
100
  class QashCBS {
64
101
  constructor(sdk) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dc-qash/sdk",
3
3
  "type": "module",
4
- "version": "1.1.1",
4
+ "version": "1.2.0",
5
5
  "description": "SDK for Qash, a DemocracyCraft clearing house",
6
6
  "main": "dist/lib.js",
7
7
  "types": "dist/lib.d.ts",