repzo 1.0.111 → 1.0.112
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/lib/index.js +20 -0
- package/package.json +1 -1
- package/src/index.ts +25 -0
package/lib/index.js
CHANGED
|
@@ -2426,6 +2426,9 @@ export default class Repzo {
|
|
|
2426
2426
|
}
|
|
2427
2427
|
}
|
|
2428
2428
|
async _fetch(baseUrl, path, params) {
|
|
2429
|
+
if (params) {
|
|
2430
|
+
params = normalizeParams(params);
|
|
2431
|
+
}
|
|
2429
2432
|
let res = await axios.get(`${baseUrl}/${path}`, {
|
|
2430
2433
|
params,
|
|
2431
2434
|
headers: this.headers,
|
|
@@ -2762,3 +2765,20 @@ Repzo.CommandLog = class {
|
|
|
2762
2765
|
return this;
|
|
2763
2766
|
}
|
|
2764
2767
|
};
|
|
2768
|
+
function normalizeParams(params) {
|
|
2769
|
+
const normalized = {};
|
|
2770
|
+
for (const key in params) {
|
|
2771
|
+
const value = params[key];
|
|
2772
|
+
if (value === undefined || value === null) continue;
|
|
2773
|
+
if (
|
|
2774
|
+
typeof value === "object" &&
|
|
2775
|
+
!(value instanceof Date) &&
|
|
2776
|
+
!(value instanceof String)
|
|
2777
|
+
) {
|
|
2778
|
+
normalized[key] = JSON.stringify(value);
|
|
2779
|
+
} else {
|
|
2780
|
+
normalized[key] = value;
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
return normalized;
|
|
2784
|
+
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -111,6 +111,9 @@ export default class Repzo {
|
|
|
111
111
|
} as const;
|
|
112
112
|
public END_POINTS = this._end_points;
|
|
113
113
|
private async _fetch(baseUrl: string, path: string, params?: Params) {
|
|
114
|
+
if (params) {
|
|
115
|
+
params = normalizeParams(params);
|
|
116
|
+
}
|
|
114
117
|
let res = await axios.get(`${baseUrl}/${path}`, {
|
|
115
118
|
params,
|
|
116
119
|
headers: this.headers,
|
|
@@ -3713,3 +3716,25 @@ export default class Repzo {
|
|
|
3713
3716
|
},
|
|
3714
3717
|
};
|
|
3715
3718
|
}
|
|
3719
|
+
|
|
3720
|
+
function normalizeParams(params: Params): { [key: string]: any } {
|
|
3721
|
+
const normalized: Record<string, any> = {};
|
|
3722
|
+
|
|
3723
|
+
for (const key in params) {
|
|
3724
|
+
const value = params[key];
|
|
3725
|
+
|
|
3726
|
+
if (value === undefined || value === null) continue;
|
|
3727
|
+
|
|
3728
|
+
if (
|
|
3729
|
+
typeof value === "object" &&
|
|
3730
|
+
!(value instanceof Date) &&
|
|
3731
|
+
!(value instanceof String)
|
|
3732
|
+
) {
|
|
3733
|
+
normalized[key] = JSON.stringify(value);
|
|
3734
|
+
} else {
|
|
3735
|
+
normalized[key] = value;
|
|
3736
|
+
}
|
|
3737
|
+
}
|
|
3738
|
+
|
|
3739
|
+
return normalized;
|
|
3740
|
+
}
|