@bzbs/react-api-client 0.2.2 → 0.2.3
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 +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +47 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -71,6 +71,48 @@ var BaseService = class {
|
|
|
71
71
|
details: error
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
+
normalizeResponse(response) {
|
|
75
|
+
if (response.status === 204) {
|
|
76
|
+
return { model: {}, response, type: "success" };
|
|
77
|
+
}
|
|
78
|
+
if ("Success" in response.data || "success" in response.data) {
|
|
79
|
+
const data = response.data;
|
|
80
|
+
if (data.Success) {
|
|
81
|
+
if ("Data" in response.data) {
|
|
82
|
+
return { model: data.Data, response, type: "success" };
|
|
83
|
+
} else if ("data" in response.data) {
|
|
84
|
+
return { model: data.data, response, type: "success" };
|
|
85
|
+
} else {
|
|
86
|
+
return { model: {}, response, type: "success" };
|
|
87
|
+
}
|
|
88
|
+
} else if (data.success) {
|
|
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",
|
|
99
|
+
error: {
|
|
100
|
+
requestId: response.data.RequestId || "",
|
|
101
|
+
error: {
|
|
102
|
+
id: response.data.Code || response.status,
|
|
103
|
+
message: response.data.Message || response.statusText,
|
|
104
|
+
code: response.data.Code || response.status,
|
|
105
|
+
type: "buzzebees"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
statusCode: response.data.Code || response.status,
|
|
109
|
+
response
|
|
110
|
+
};
|
|
111
|
+
return this.normalizeError(error);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return { model: response.data, response, type: "success" };
|
|
115
|
+
}
|
|
74
116
|
request(method, path, data, requestOptions) {
|
|
75
117
|
return __async(this, null, function* () {
|
|
76
118
|
var _a;
|
|
@@ -82,41 +124,13 @@ var BaseService = class {
|
|
|
82
124
|
data
|
|
83
125
|
};
|
|
84
126
|
const response = yield this.client.request(__spreadValues({ method, url }, config));
|
|
85
|
-
|
|
86
|
-
return { model: "", response, type: "success" };
|
|
87
|
-
}
|
|
88
|
-
if ("Success" in response.data) {
|
|
89
|
-
const data2 = response.data;
|
|
90
|
-
if (data2.Success) {
|
|
91
|
-
if ("Data" in response.data) {
|
|
92
|
-
return { model: data2.Data, response, type: "success" };
|
|
93
|
-
} else {
|
|
94
|
-
return { model: "", response, type: "success" };
|
|
95
|
-
}
|
|
96
|
-
} else {
|
|
97
|
-
const error = {
|
|
98
|
-
type: "server-error",
|
|
99
|
-
error: {
|
|
100
|
-
requestId: response.data.RequestId || "",
|
|
101
|
-
error: {
|
|
102
|
-
id: response.data.Code || 500,
|
|
103
|
-
message: response.data.Message || "An unexpected error occurred.",
|
|
104
|
-
code: response.data.Code || 500,
|
|
105
|
-
type: "buzzebees"
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
statusCode: response.data.Code || 500,
|
|
109
|
-
response
|
|
110
|
-
};
|
|
111
|
-
return this.normalizeError(error);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return { model: response.data, response, type: "success" };
|
|
127
|
+
return this.normalizeResponse(response);
|
|
115
128
|
} catch (error) {
|
|
116
129
|
return this.normalizeError(error);
|
|
117
130
|
}
|
|
118
131
|
});
|
|
119
132
|
}
|
|
133
|
+
/* if blob type we not include header in requestOptions */
|
|
120
134
|
get(path, params, requestOptions) {
|
|
121
135
|
return __async(this, null, function* () {
|
|
122
136
|
return this.request("get", path, void 0, __spreadProps(__spreadValues({}, requestOptions), { params }));
|
|
@@ -2264,7 +2278,9 @@ var BzbsService = class {
|
|
|
2264
2278
|
this.couponApi = new CouponApi(this.client, this.baseUrl);
|
|
2265
2279
|
this.dashboardApi = new DashboardApi(this.client, this.baseUrl);
|
|
2266
2280
|
this.historyApi = new HistoryApi(this.client, this.baseUrl);
|
|
2267
|
-
|
|
2281
|
+
if (this.baseLineUrl) {
|
|
2282
|
+
this.lineApi = new LineApi(this.client, this.baseLineUrl);
|
|
2283
|
+
}
|
|
2268
2284
|
this.notificationApi = new NotificationApi(this.client, this.baseUrl);
|
|
2269
2285
|
this.placeApi = new PlaceApi(this.client, this.baseUrl);
|
|
2270
2286
|
this.pointLogApi = new PointLogApi(this.client, this.baseUrl);
|