autoinspector 2.6.1 → 2.7.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/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/Webhooks.d.ts +10 -1
- package/dist/resources/Webhooks.js +21 -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;
|
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) {
|
|
@@ -38,6 +38,7 @@ export declare class Inspections extends Products {
|
|
|
38
38
|
* @param {String} input.status - Represents the status that inspections retrieved should have.
|
|
39
39
|
* @param {String} input.type - Represents the type of the inspection.
|
|
40
40
|
* @param {String} input.consumerIdentification - Identification value of target consumer
|
|
41
|
+
* @param {String} input.plate - Car License Plate parameter to filter inspections
|
|
41
42
|
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
42
43
|
* data or an Error with the problem.
|
|
43
44
|
*/
|
|
@@ -59,6 +59,7 @@ class Inspections extends Products_1.Products {
|
|
|
59
59
|
* @param {String} input.status - Represents the status that inspections retrieved should have.
|
|
60
60
|
* @param {String} input.type - Represents the type of the inspection.
|
|
61
61
|
* @param {String} input.consumerIdentification - Identification value of target consumer
|
|
62
|
+
* @param {String} input.plate - Car License Plate parameter to filter inspections
|
|
62
63
|
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
63
64
|
* data or an Error with the problem.
|
|
64
65
|
*/
|
|
@@ -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;
|
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;
|