@movalib/movalib-commons 1.43.0 → 1.45.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/src/helpers/ApiHelper.d.ts +4 -9
- package/dist/src/services/VehicleService.d.ts +1 -1
- package/dist/src/services/VehicleService.js +2 -1
- package/dist/src/services/VehicleService.types.d.ts +3 -0
- package/package.json +1 -1
- package/src/helpers/ApiHelper.ts +9 -1
- package/src/services/VehicleService.ts +2 -1
- package/src/services/VehicleService.types.ts +4 -0
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { APIMethod, MovaAppType } from "./Enums";
|
|
2
2
|
export declare const API_BASE_URL: string;
|
|
3
|
-
type
|
|
4
|
-
success:
|
|
5
|
-
data
|
|
3
|
+
export type APIResponse<T> = {
|
|
4
|
+
success: boolean;
|
|
5
|
+
data?: T;
|
|
6
|
+
error?: string;
|
|
6
7
|
};
|
|
7
|
-
type APIError = {
|
|
8
|
-
success: false;
|
|
9
|
-
error: string;
|
|
10
|
-
};
|
|
11
|
-
export type APIResponse<T> = APISuccess<T> | APIError;
|
|
12
8
|
export type APIRequest = {
|
|
13
9
|
url: string;
|
|
14
10
|
method: APIMethod;
|
|
@@ -22,4 +18,3 @@ export type APIRequest = {
|
|
|
22
18
|
* @returns
|
|
23
19
|
*/
|
|
24
20
|
export declare const request: (options: APIRequest) => Promise<APIResponse<any>>;
|
|
25
|
-
export {};
|
|
@@ -3,5 +3,5 @@ import { MovaAppType } from "../helpers/Enums";
|
|
|
3
3
|
import { EditVehicleParams } from "./VehicleService.types";
|
|
4
4
|
export default class VehicleService {
|
|
5
5
|
static getVehicleDescription(appType: MovaAppType, plate: string): Promise<APIResponse<string>>;
|
|
6
|
-
static editVehicle({ vehicleId, ...payload }: EditVehicleParams): Promise<APIResponse<string>>;
|
|
6
|
+
static editVehicle({ vehicleId, appType, ...payload }: EditVehicleParams): Promise<APIResponse<string>>;
|
|
7
7
|
}
|
|
@@ -24,10 +24,11 @@ var VehicleService = /** @class */ (function () {
|
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
VehicleService.editVehicle = function (_a) {
|
|
27
|
-
var vehicleId = _a.vehicleId, payload = __rest(_a, ["vehicleId"]);
|
|
27
|
+
var vehicleId = _a.vehicleId, appType = _a.appType, payload = __rest(_a, ["vehicleId", "appType"]);
|
|
28
28
|
return (0, ApiHelper_1.request)({
|
|
29
29
|
url: "".concat(ApiHelper_1.API_BASE_URL, "/vehicle/").concat(vehicleId),
|
|
30
30
|
method: Enums_1.APIMethod.PATCH,
|
|
31
|
+
appType: appType !== null && appType !== void 0 ? appType : Enums_1.MovaAppType.GARAGE,
|
|
31
32
|
body: JSON.stringify(payload)
|
|
32
33
|
});
|
|
33
34
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MovaAppType } from "../helpers/Enums";
|
|
1
2
|
export type EditVehicleParams = {
|
|
2
3
|
/** Identifiant unique du véhicule */
|
|
3
4
|
vehicleId: number;
|
|
@@ -10,4 +11,6 @@ export type EditVehicleParams = {
|
|
|
10
11
|
tireHeight?: string;
|
|
11
12
|
tireDiameter?: string;
|
|
12
13
|
tireSpeedIndex?: string;
|
|
14
|
+
/** Si besoin, on peut préciser si la requête viens de Movalib PRO ou CLIENT */
|
|
15
|
+
appType?: MovaAppType;
|
|
13
16
|
};
|
package/package.json
CHANGED
package/src/helpers/ApiHelper.ts
CHANGED
|
@@ -13,8 +13,16 @@ type APIError = {
|
|
|
13
13
|
success: false;
|
|
14
14
|
error: string;
|
|
15
15
|
};
|
|
16
|
+
// This inference type is not ready yet, we have to be sure
|
|
17
|
+
// that we handle all the backend return cases before changing this
|
|
18
|
+
// export type APIResponse<T> = APISuccess<T> | APIError;
|
|
16
19
|
|
|
17
|
-
export type APIResponse<T> =
|
|
20
|
+
export type APIResponse<T> = {
|
|
21
|
+
success: boolean,
|
|
22
|
+
data?: T,
|
|
23
|
+
error?: string
|
|
24
|
+
|
|
25
|
+
}
|
|
18
26
|
|
|
19
27
|
export type APIRequest = {
|
|
20
28
|
url: string,
|
|
@@ -13,10 +13,11 @@ export default class VehicleService {
|
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
static editVehicle({vehicleId,
|
|
16
|
+
static editVehicle({vehicleId, appType,...payload}: EditVehicleParams): Promise<APIResponse<string>> {
|
|
17
17
|
return request({
|
|
18
18
|
url: `${API_BASE_URL}/vehicle/${vehicleId}`,
|
|
19
19
|
method: APIMethod.PATCH,
|
|
20
|
+
appType: appType ?? MovaAppType.GARAGE,
|
|
20
21
|
body: JSON.stringify(payload)
|
|
21
22
|
});
|
|
22
23
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {MovaAppType} from "../helpers/Enums";
|
|
2
|
+
|
|
1
3
|
export type EditVehicleParams = {
|
|
2
4
|
/** Identifiant unique du véhicule */
|
|
3
5
|
vehicleId: number;
|
|
@@ -13,4 +15,6 @@ export type EditVehicleParams = {
|
|
|
13
15
|
tireDiameter?: string;
|
|
14
16
|
tireSpeedIndex?: string;
|
|
15
17
|
|
|
18
|
+
/** Si besoin, on peut préciser si la requête viens de Movalib PRO ou CLIENT */
|
|
19
|
+
appType?: MovaAppType;
|
|
16
20
|
}
|