@bzbs/react-api-client 0.2.3 → 1.0.1
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/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +38 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -21
package/dist/index.mjs
CHANGED
|
@@ -75,43 +75,30 @@ var BaseService = class {
|
|
|
75
75
|
if (response.status === 204) {
|
|
76
76
|
return { model: {}, response, type: "success" };
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if ("Data" in response.data) {
|
|
90
|
-
return { model: data.Data, response, type: "success" };
|
|
91
|
-
} else if ("data" in response.data) {
|
|
92
|
-
return { model: data.data, response, type: "success" };
|
|
93
|
-
} else {
|
|
94
|
-
return { model: {}, response, type: "success" };
|
|
95
|
-
}
|
|
96
|
-
} else {
|
|
97
|
-
const error = {
|
|
98
|
-
type: "server-error",
|
|
78
|
+
const data = response.data;
|
|
79
|
+
const isSuccess = (data == null ? void 0 : data.Success) === true || (data == null ? void 0 : data.success) === true;
|
|
80
|
+
if (isSuccess) {
|
|
81
|
+
const model = "Data" in data ? data.Data : "data" in data ? data.data : {};
|
|
82
|
+
return { model, response, type: "success" };
|
|
83
|
+
}
|
|
84
|
+
if ("Success" in data || "success" in data) {
|
|
85
|
+
const error = {
|
|
86
|
+
type: "server-error",
|
|
87
|
+
error: {
|
|
88
|
+
requestId: data.RequestId || "",
|
|
99
89
|
error: {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
};
|
|
111
|
-
return this.normalizeError(error);
|
|
112
|
-
}
|
|
90
|
+
id: data.Code || data.code || response.status,
|
|
91
|
+
message: data.Message || data.message || response.statusText,
|
|
92
|
+
code: data.Code || data.code || response.status,
|
|
93
|
+
type: "buzzebees"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
statusCode: data.Code || response.status,
|
|
97
|
+
response
|
|
98
|
+
};
|
|
99
|
+
return this.normalizeError(error);
|
|
113
100
|
}
|
|
114
|
-
return { model:
|
|
101
|
+
return { model: data, response, type: "success" };
|
|
115
102
|
}
|
|
116
103
|
request(method, path, data, requestOptions) {
|
|
117
104
|
return __async(this, null, function* () {
|
|
@@ -157,7 +144,9 @@ var BaseService = class {
|
|
|
157
144
|
});
|
|
158
145
|
}
|
|
159
146
|
joinUrl(baseUrl, path) {
|
|
160
|
-
|
|
147
|
+
const sanitizedBase = baseUrl.replace(/\/+$/, "");
|
|
148
|
+
const sanitizedPath = path.replace(/^\/+/, "");
|
|
149
|
+
return `${sanitizedBase}/${sanitizedPath}`;
|
|
161
150
|
}
|
|
162
151
|
getHeaders(customHeaders) {
|
|
163
152
|
return __spreadValues({
|
|
@@ -1156,7 +1145,7 @@ var HistoryApi = class extends BaseService {
|
|
|
1156
1145
|
*/
|
|
1157
1146
|
redeemHistories(params, requestOptions) {
|
|
1158
1147
|
return __async(this, null, function* () {
|
|
1159
|
-
|
|
1148
|
+
const response = yield this.get(
|
|
1160
1149
|
"redeem",
|
|
1161
1150
|
__spreadValues({
|
|
1162
1151
|
byConfig: params.byConfig,
|
|
@@ -1169,6 +1158,18 @@ var HistoryApi = class extends BaseService {
|
|
|
1169
1158
|
}, params.options),
|
|
1170
1159
|
requestOptions
|
|
1171
1160
|
);
|
|
1161
|
+
if (response.type === "success") {
|
|
1162
|
+
const purchases = response.model.map((item) => {
|
|
1163
|
+
var _a, _b;
|
|
1164
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
1165
|
+
ParcelNo: (_b = (_a = item.ParcelNo) != null ? _a : item.PacelNo) != null ? _b : void 0
|
|
1166
|
+
});
|
|
1167
|
+
});
|
|
1168
|
+
return __spreadProps(__spreadValues({}, response), {
|
|
1169
|
+
model: purchases
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
return response;
|
|
1172
1173
|
});
|
|
1173
1174
|
}
|
|
1174
1175
|
/**
|