autoinspector 2.6.2 → 2.8.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/package.json +1 -1
- package/dist/resources/Autoinspector.js +1 -1
- package/dist/resources/Cellphone.d.ts +11 -0
- package/dist/resources/Cellphone.js +40 -0
- package/dist/resources/Helper.js +1 -0
- package/dist/resources/Image.js +1 -0
- package/dist/resources/Inspections.d.ts +1 -0
- package/dist/resources/Inspections.js +1 -0
- package/dist/resources/Products.d.ts +3 -1
- package/dist/resources/Products.js +10 -8
- package/dist/resources/Webhooks.d.ts +10 -1
- package/dist/resources/Webhooks.js +21 -0
- package/dist/types/cellphone.d.ts +10 -0
- package/dist/types/cellphone.js +2 -0
- package/dist/types/pagination.d.ts +1 -0
- package/dist/types/webhooks.d.ts +6 -2
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -53,7 +53,7 @@ class Autoinspector {
|
|
|
53
53
|
this.inspections = new Inspections_1.Inspections(httpClient);
|
|
54
54
|
this.images = new Image_1.Image(httpClient);
|
|
55
55
|
this.templates = new Template_1.Template(httpClient);
|
|
56
|
-
this.webhooks = new Webhooks_1.Webhooks();
|
|
56
|
+
this.webhooks = new Webhooks_1.Webhooks(httpClient);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
exports.Autoinspector = Autoinspector;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IUpdateResourceResponse } from '../types/api';
|
|
2
|
+
import { ICreateCellphoneInspection, ICellphone } from '../types/cellphone';
|
|
3
|
+
import { ICreateInspectionOutput } from '../types/inspection';
|
|
4
|
+
import { IProductMethods } from '../types/productMethods';
|
|
5
|
+
import { HTTPClient } from './HTTPClient';
|
|
6
|
+
export declare class Cellphone implements IProductMethods<ICreateCellphoneInspection, Partial<ICellphone>> {
|
|
7
|
+
private readonly httpClient;
|
|
8
|
+
constructor(httpClient: HTTPClient);
|
|
9
|
+
create(body: ICreateCellphoneInspection): Promise<ICreateInspectionOutput>;
|
|
10
|
+
update(productId: string, cellphone: Partial<ICellphone>): Promise<IUpdateResourceResponse>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Cellphone = void 0;
|
|
13
|
+
const idempotency_1 = require("../utils/idempotency");
|
|
14
|
+
class Cellphone {
|
|
15
|
+
constructor(httpClient) {
|
|
16
|
+
this.httpClient = httpClient;
|
|
17
|
+
}
|
|
18
|
+
create(body) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
return yield this.httpClient.makeRequest({
|
|
21
|
+
method: 'POST',
|
|
22
|
+
path: `/inspection/cellphone`,
|
|
23
|
+
headers: (0, idempotency_1.generateIdempotencyHeader)(),
|
|
24
|
+
body,
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
update(productId, cellphone) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return yield this.httpClient.makeRequest({
|
|
31
|
+
method: 'PUT',
|
|
32
|
+
path: `/inspection/cellphone/${productId}`,
|
|
33
|
+
body: {
|
|
34
|
+
cellphone,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.Cellphone = Cellphone;
|
package/dist/resources/Helper.js
CHANGED
|
@@ -15,6 +15,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.Helper = void 0;
|
|
18
|
+
//@ts-ignore
|
|
18
19
|
const form_data_1 = __importDefault(require("form-data"));
|
|
19
20
|
const fs_1 = require("fs");
|
|
20
21
|
class Helper {
|
package/dist/resources/Image.js
CHANGED
|
@@ -15,6 +15,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.Image = void 0;
|
|
18
|
+
//@ts-ignore
|
|
18
19
|
const form_data_1 = __importDefault(require("form-data"));
|
|
19
20
|
class Image {
|
|
20
21
|
constructor(httpClient) {
|
|
@@ -39,6 +39,7 @@ export declare class Inspections extends Products {
|
|
|
39
39
|
* @param {String} input.type - Represents the type of the inspection.
|
|
40
40
|
* @param {String} input.consumerIdentification - Identification value of target consumer
|
|
41
41
|
* @param {String} input.plate - Car License Plate parameter to filter inspections
|
|
42
|
+
* @param {String} input.templateId - ID del template de inspección
|
|
42
43
|
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
43
44
|
* data or an Error with the problem.
|
|
44
45
|
*/
|
|
@@ -60,6 +60,7 @@ class Inspections extends Products_1.Products {
|
|
|
60
60
|
* @param {String} input.type - Represents the type of the inspection.
|
|
61
61
|
* @param {String} input.consumerIdentification - Identification value of target consumer
|
|
62
62
|
* @param {String} input.plate - Car License Plate parameter to filter inspections
|
|
63
|
+
* @param {String} input.templateId - ID del template de inspección
|
|
63
64
|
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
64
65
|
* data or an Error with the problem.
|
|
65
66
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Bike } from './Bike';
|
|
2
2
|
import { Car } from './Car';
|
|
3
|
+
import { Cellphone } from './Cellphone';
|
|
3
4
|
import { Custom } from './Custom';
|
|
4
5
|
import { Goods } from './Goods';
|
|
5
6
|
import { HTTPClient } from './HTTPClient';
|
|
@@ -14,5 +15,6 @@ export declare class Products {
|
|
|
14
15
|
moto: Moto;
|
|
15
16
|
custom: Custom;
|
|
16
17
|
bike: Bike;
|
|
17
|
-
|
|
18
|
+
cellphone: Cellphone;
|
|
19
|
+
constructor(httpRef: HTTPClient);
|
|
18
20
|
}
|
|
@@ -3,20 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Products = void 0;
|
|
4
4
|
const Bike_1 = require("./Bike");
|
|
5
5
|
const Car_1 = require("./Car");
|
|
6
|
+
const Cellphone_1 = require("./Cellphone");
|
|
6
7
|
const Custom_1 = require("./Custom");
|
|
7
8
|
const Goods_1 = require("./Goods");
|
|
8
9
|
const Machinery_1 = require("./Machinery");
|
|
9
10
|
const Moto_1 = require("./Moto");
|
|
10
11
|
const People_1 = require("./People");
|
|
11
12
|
class Products {
|
|
12
|
-
constructor(
|
|
13
|
-
this.machinery = new Machinery_1.Machinery(
|
|
14
|
-
this.people = new People_1.People(
|
|
15
|
-
this.goods = new Goods_1.Goods(
|
|
16
|
-
this.car = new Car_1.Car(
|
|
17
|
-
this.moto = new Moto_1.Moto(
|
|
18
|
-
this.custom = new Custom_1.Custom(
|
|
19
|
-
this.bike = new Bike_1.Bike(
|
|
13
|
+
constructor(httpRef) {
|
|
14
|
+
this.machinery = new Machinery_1.Machinery(httpRef);
|
|
15
|
+
this.people = new People_1.People(httpRef);
|
|
16
|
+
this.goods = new Goods_1.Goods(httpRef);
|
|
17
|
+
this.car = new Car_1.Car(httpRef);
|
|
18
|
+
this.moto = new Moto_1.Moto(httpRef);
|
|
19
|
+
this.custom = new Custom_1.Custom(httpRef);
|
|
20
|
+
this.bike = new Bike_1.Bike(httpRef);
|
|
21
|
+
this.cellphone = new Cellphone_1.Cellphone(httpRef);
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
exports.Products = Products;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import { AutoinspectorWebhook } from '../types/webhooks';
|
|
1
|
+
import { AutoinspectorWebhook, IWebhookEvents } from '../types/webhooks';
|
|
2
|
+
import { HTTPClient } from './HTTPClient';
|
|
2
3
|
export declare class Webhooks {
|
|
4
|
+
private readonly httpClient;
|
|
5
|
+
constructor(httpClient: HTTPClient);
|
|
3
6
|
constructEvent(body: any, requestSignature: string, webhookSecret: string): AutoinspectorWebhook;
|
|
7
|
+
create(input: {
|
|
8
|
+
events: IWebhookEvents[];
|
|
9
|
+
endpoint: string;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
_id: string;
|
|
12
|
+
}>;
|
|
4
13
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.Webhooks = void 0;
|
|
4
13
|
const crypto_1 = require("crypto");
|
|
@@ -9,6 +18,9 @@ class InvalidRequestSignature extends Error {
|
|
|
9
18
|
}
|
|
10
19
|
}
|
|
11
20
|
class Webhooks {
|
|
21
|
+
constructor(httpClient) {
|
|
22
|
+
this.httpClient = httpClient;
|
|
23
|
+
}
|
|
12
24
|
constructEvent(body, requestSignature, webhookSecret) {
|
|
13
25
|
const realDigest = (0, crypto_1.createHmac)('sha256', webhookSecret).update(body).digest('hex');
|
|
14
26
|
if (requestSignature !== realDigest) {
|
|
@@ -16,5 +28,14 @@ class Webhooks {
|
|
|
16
28
|
}
|
|
17
29
|
return JSON.parse(body.toString('utf-8'));
|
|
18
30
|
}
|
|
31
|
+
create(input) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
return yield this.httpClient.makeRequest({
|
|
34
|
+
method: 'POST',
|
|
35
|
+
path: '/notification/webhook',
|
|
36
|
+
body: input,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
19
40
|
}
|
|
20
41
|
exports.Webhooks = Webhooks;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ICreateInspectionProducer, IInspectionCommonParamsV2 } from './inspection';
|
|
2
|
+
export interface ICellphone {
|
|
3
|
+
make: string;
|
|
4
|
+
model: string;
|
|
5
|
+
price: number;
|
|
6
|
+
serialNumber: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ICreateCellphoneInspection extends IInspectionCommonParamsV2<ICreateInspectionProducer> {
|
|
9
|
+
cellphone?: Partial<ICellphone>;
|
|
10
|
+
}
|
package/dist/types/webhooks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IConsumer } from './consumer';
|
|
2
2
|
import { IImageDamage, IInspectionInput, InspectionStatus, InspectionType, InspectionVeredict, IProduct, IValidation } from './inspection';
|
|
3
|
-
export declare type IWebhookEvents = 'inspection_started' | 'image_processed' | 'inspection_blocked' | 'inspection_completed' | 'inspection_reviewed';
|
|
3
|
+
export declare type IWebhookEvents = 'inspection_started' | 'image_processed' | 'inspection_blocked' | 'inspection_completed' | 'inspection_reviewed' | 'inspection_created';
|
|
4
4
|
export interface IWebhookProducer {
|
|
5
5
|
companyId: string;
|
|
6
6
|
userId?: string;
|
|
@@ -26,6 +26,10 @@ export interface IWebhookImage {
|
|
|
26
26
|
validations: IValidation[];
|
|
27
27
|
damages?: IImageDamage[];
|
|
28
28
|
}
|
|
29
|
+
export interface IWebhookInspectionCreated extends IWebhookEvent<{
|
|
30
|
+
status: InspectionStatus;
|
|
31
|
+
}, 'inspection_created'> {
|
|
32
|
+
}
|
|
29
33
|
export interface IWebhookInspectionStarted extends IWebhookEvent<{
|
|
30
34
|
status: InspectionStatus;
|
|
31
35
|
}, 'inspection_started'> {
|
|
@@ -69,4 +73,4 @@ export interface IWebhookInspectionCompleted extends IWebhookEvent<{
|
|
|
69
73
|
veredict: InspectionVeredict;
|
|
70
74
|
}, 'inspection_completed'> {
|
|
71
75
|
}
|
|
72
|
-
export declare type AutoinspectorWebhook = IWebhookInspectionStarted | IWebhookImageProcessed | IWebhookInspectionBlocked | IWebhookInspectionCompleted;
|
|
76
|
+
export declare type AutoinspectorWebhook = IWebhookInspectionStarted | IWebhookImageProcessed | IWebhookInspectionBlocked | IWebhookInspectionCompleted | IWebhookInspectionCreated;
|