@atomsolution/invoice-sdk-api 1.25.0 → 1.26.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/auth.d.ts CHANGED
@@ -15,15 +15,15 @@ export declare function getListProviders(): IProvider[];
15
15
  /**
16
16
  * Save one provider info (encrypted)
17
17
  */
18
- export declare function saveProviderInfo<T>(provider: string, detailInfo: T): void;
18
+ export declare function saveProviderInfo<T>(provider: string, merchantId: string, detailInfo: T): void;
19
19
  /**
20
20
  * Get one provider’s decrypted info
21
21
  */
22
- export declare function getProviderInfo(provider: string): {} | null;
22
+ export declare function getProviderInfo(provider: string, merchantId: string): {} | null;
23
23
  /**
24
24
  * Get all provider’s decrypted info
25
25
  */
26
- export declare function getAllProvidersInfo(): Record<string, unknown>;
26
+ export declare function getAllProvidersInfo(merchantId: string): Record<string, unknown>;
27
27
  /**
28
28
  * Sets only the given provider as default,
29
29
  * clearing isDefault on every other entry.
@@ -31,12 +31,12 @@ export declare function getAllProvidersInfo(): Record<string, unknown>;
31
31
  */
32
32
  export declare function setProviderDefault<T extends {
33
33
  isDefault: boolean;
34
- }>(provider: string): void;
34
+ }>(provider: string, merchantId: string): void;
35
35
  /**
36
36
  * Remove a single provider’s info
37
37
  */
38
- export declare function clearProvider(provider: string): void;
38
+ export declare function clearProvider(provider: string, merchantId: string): void;
39
39
  /**
40
40
  * (Optional) Remove all providers at once
41
41
  */
42
- export declare function clearAllProviders(): void;
42
+ export declare function clearAllProviders(merchantId: string): void;
package/dist/index.esm.js CHANGED
@@ -94,21 +94,25 @@ const PROVIDERS = [
94
94
  }
95
95
  }
96
96
  // {
97
- // name: "FPT",
98
- // route: Provider.FPT,
99
- // logo: fptLogo,
100
- // },
101
- // {
102
97
  // name: "Misa",
103
98
  // route: Provider.MISA,
104
99
  // logo: misaLogo,
100
+ // invoiceLookupUrls: {
101
+ // dev: "https://test-tracuuhoadon.minvoice.com.vn/single/invoice",
102
+ // prod: "https://tracuuhoadon.minvoice.com.vn/single/invoice",
103
+ // }
104
+ // },
105
+ // {
106
+ // name: "FPT",
107
+ // route: Provider.FPT,
108
+ // logo: fptLogo,
105
109
  // },
106
110
  ];
107
111
  function getListProviders() {
108
112
  return PROVIDERS;
109
113
  }
110
- function readEncryptedStore() {
111
- const cipher = localStorage.getItem(STORAGE_KEY);
114
+ function readEncryptedStore(merchantId) {
115
+ const cipher = localStorage.getItem("".concat(STORAGE_KEY, "_").concat(merchantId));
112
116
  if (!cipher) return {};
113
117
  try {
114
118
  const bytes = CryptoJS.AES.decrypt(cipher, SECRET);
@@ -119,41 +123,41 @@ function readEncryptedStore() {
119
123
  return {};
120
124
  }
121
125
  }
122
- function writeEncryptedStore(store) {
126
+ function writeEncryptedStore(store, merchantId) {
123
127
  const json = JSON.stringify(store);
124
128
  const cipher = CryptoJS.AES.encrypt(json, SECRET).toString();
125
- localStorage.setItem(STORAGE_KEY, cipher);
129
+ localStorage.setItem("".concat(STORAGE_KEY, "_").concat(merchantId), cipher);
126
130
  }
127
- function saveProviderInfo(provider, detailInfo) {
128
- const store = readEncryptedStore();
131
+ function saveProviderInfo(provider, merchantId, detailInfo) {
132
+ const store = readEncryptedStore(merchantId);
129
133
  store[provider] = __spreadProps(__spreadValues({}, detailInfo), { isDefault: false });
130
- writeEncryptedStore(store);
134
+ writeEncryptedStore(store, merchantId);
131
135
  }
132
- function getProviderInfo(provider) {
133
- const store = readEncryptedStore();
136
+ function getProviderInfo(provider, merchantId) {
137
+ const store = readEncryptedStore(merchantId);
134
138
  return store[provider] || null;
135
139
  }
136
- function getAllProvidersInfo() {
137
- const store = readEncryptedStore();
140
+ function getAllProvidersInfo(merchantId) {
141
+ const store = readEncryptedStore(merchantId);
138
142
  return store;
139
143
  }
140
- function setProviderDefault(provider) {
141
- const store = readEncryptedStore();
144
+ function setProviderDefault(provider, merchantId) {
145
+ const store = readEncryptedStore(merchantId);
142
146
  const entry = store[provider];
143
147
  if (!entry) return;
144
148
  Object.keys(store).forEach((key) => {
145
149
  store[key].isDefault = false;
146
150
  });
147
151
  entry.isDefault = true;
148
- writeEncryptedStore(store);
152
+ writeEncryptedStore(store, merchantId);
149
153
  }
150
- function clearProvider(provider) {
151
- const store = readEncryptedStore();
154
+ function clearProvider(provider, merchantId) {
155
+ const store = readEncryptedStore(merchantId);
152
156
  delete store[provider];
153
- writeEncryptedStore(store);
157
+ writeEncryptedStore(store, merchantId);
154
158
  }
155
- function clearAllProviders() {
156
- localStorage.removeItem(STORAGE_KEY);
159
+ function clearAllProviders(merchantId) {
160
+ localStorage.removeItem("".concat(STORAGE_KEY, "_").concat(merchantId));
157
161
  }
158
162
  class BaseAPI {
159
163
  constructor(configuration, basePath = "", axios = globalAxios) {
@@ -303,7 +307,6 @@ const DefaultApiAxiosParamCreator = function(configuration) {
303
307
  */
304
308
  getInvoice: (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (id, stax, options = {}) {
305
309
  assertParamExists("getInvoice", "id", id);
306
- assertParamExists("getInvoice", "stax", stax);
307
310
  let localVarPath;
308
311
  let localVarUrlObj;
309
312
  if (configuration) {
@@ -351,7 +354,6 @@ const DefaultApiAxiosParamCreator = function(configuration) {
351
354
  getInvoices: (_0, _1, _2, _3, _4, _5, ..._6) => __async(null, [_0, _1, _2, _3, _4, _5, ..._6], function* (fromDate, toDate, stax, start, count, serial, options = {}) {
352
355
  assertParamExists("getInvoices", "fromDate", fromDate);
353
356
  assertParamExists("getInvoices", "toDate", toDate);
354
- assertParamExists("getInvoices", "stax", stax);
355
357
  let localVarPath;
356
358
  let localVarUrlObj;
357
359
  if (configuration) {
@@ -491,7 +493,6 @@ const DefaultApiAxiosParamCreator = function(configuration) {
491
493
  */
492
494
  viewPrintInvoice: (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (id, stax, options = {}) {
493
495
  assertParamExists("viewPrintInvoice", "id", id);
494
- assertParamExists("viewPrintInvoice", "stax", stax);
495
496
  let localVarPath;
496
497
  let localVarUrlObj;
497
498
  if (configuration) {