@pipedream/samsara 0.0.1 → 0.1.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/actions/create-address/create-address.mjs +109 -0
- package/actions/create-contact/create-contact.mjs +54 -0
- package/actions/create-route/create-route.mjs +95 -0
- package/common/utils.mjs +33 -0
- package/package.json +4 -1
- package/samsara.app.mjs +158 -5
- package/sources/common/base.mjs +61 -0
- package/sources/new-document-submitted-instant/new-document-submitted-instant.mjs +27 -0
- package/sources/new-document-submitted-instant/test-event.mjs +224 -0
- package/sources/new-route-job-completion-instant/new-route-job-completion-instant.mjs +35 -0
- package/sources/new-route-job-completion-instant/test-event.mjs +217 -0
- package/sources/new-route-started-instant/new-route-started-instant.mjs +34 -0
- package/sources/new-route-started-instant/test-event.mjs +217 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import {
|
|
3
|
+
cleanObject,
|
|
4
|
+
parseObject,
|
|
5
|
+
} from "../../common/utils.mjs";
|
|
6
|
+
import samsara from "../../samsara.app.mjs";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
key: "samsara-create-address",
|
|
10
|
+
name: "Create Address",
|
|
11
|
+
description: "Adds a new address to the organization. The user must provide the necessary props such as formatted address, geofence, and name. [See the documentation](https://developers.samsara.com/reference/createaddress)",
|
|
12
|
+
version: "0.0.1",
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
samsara,
|
|
16
|
+
addressTypes: {
|
|
17
|
+
type: "string[]",
|
|
18
|
+
label: "Address Types",
|
|
19
|
+
description: "Reporting location type associated with the address (used for ELD reporting purposes).",
|
|
20
|
+
options: [
|
|
21
|
+
"yard",
|
|
22
|
+
"shortHaul",
|
|
23
|
+
"workforceSite",
|
|
24
|
+
"riskZone",
|
|
25
|
+
"industrialSite",
|
|
26
|
+
"alertsOnly",
|
|
27
|
+
],
|
|
28
|
+
optional: true,
|
|
29
|
+
},
|
|
30
|
+
contactIds: {
|
|
31
|
+
propDefinition: [
|
|
32
|
+
samsara,
|
|
33
|
+
"contactIds",
|
|
34
|
+
],
|
|
35
|
+
optional: true,
|
|
36
|
+
},
|
|
37
|
+
externalIds: {
|
|
38
|
+
propDefinition: [
|
|
39
|
+
samsara,
|
|
40
|
+
"externalIds",
|
|
41
|
+
],
|
|
42
|
+
optional: true,
|
|
43
|
+
},
|
|
44
|
+
formattedAddress: {
|
|
45
|
+
type: "string",
|
|
46
|
+
label: "Formatted Address",
|
|
47
|
+
description: "The full street address for this address/geofence, as it might be recognized by Google Maps.",
|
|
48
|
+
},
|
|
49
|
+
geofence: {
|
|
50
|
+
type: "object",
|
|
51
|
+
label: "Geofence",
|
|
52
|
+
description: "The geofence that defines this address and its bounds. This can either be a circle or a polygon, but not both. [See the documentation](https://developers.samsara.com/reference/createaddress)",
|
|
53
|
+
},
|
|
54
|
+
latitude: {
|
|
55
|
+
type: "string",
|
|
56
|
+
label: "Latitude",
|
|
57
|
+
description: "Latitude of the address. Will be geocoded from **Formatted Address** if not provided.",
|
|
58
|
+
optional: true,
|
|
59
|
+
},
|
|
60
|
+
longitude: {
|
|
61
|
+
type: "string",
|
|
62
|
+
label: "Longitude",
|
|
63
|
+
description: "Longitude of the address. Will be geocoded from **Formatted Address** if not provided.",
|
|
64
|
+
optional: true,
|
|
65
|
+
},
|
|
66
|
+
name: {
|
|
67
|
+
type: "string",
|
|
68
|
+
label: "Name",
|
|
69
|
+
description: "Name of the address.",
|
|
70
|
+
},
|
|
71
|
+
notes: {
|
|
72
|
+
type: "string",
|
|
73
|
+
label: "Notes",
|
|
74
|
+
description: "Notes about the address.",
|
|
75
|
+
},
|
|
76
|
+
tagIds: {
|
|
77
|
+
propDefinition: [
|
|
78
|
+
samsara,
|
|
79
|
+
"tagIds",
|
|
80
|
+
],
|
|
81
|
+
optional: true,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
async run({ $ }) {
|
|
85
|
+
try {
|
|
86
|
+
const response = await this.samsara.createAddress({
|
|
87
|
+
$,
|
|
88
|
+
data: cleanObject({
|
|
89
|
+
addressTypes: parseObject(this.addressTypes),
|
|
90
|
+
contactIds: parseObject(this.contactIds),
|
|
91
|
+
externalIds: parseObject(this.externalIds),
|
|
92
|
+
formattedAddress: this.formattedAddress,
|
|
93
|
+
geofence: parseObject(this.geofence),
|
|
94
|
+
latitude: this.latitude,
|
|
95
|
+
longitude: this.longitude,
|
|
96
|
+
name: this.name,
|
|
97
|
+
notes: this.notes,
|
|
98
|
+
tagIds: parseObject(this.tagIds),
|
|
99
|
+
}),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
$.export("$summary", `Successfully created address with name Id: ${response.data?.id}`);
|
|
103
|
+
return response;
|
|
104
|
+
|
|
105
|
+
} catch (error) {
|
|
106
|
+
throw new ConfigurationError(JSON.parse(error.message).message);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import samsara from "../../samsara.app.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "samsara-create-contact",
|
|
6
|
+
name: "Create Contact",
|
|
7
|
+
description: "Adds a new contact to the organization. [See the documentation](https://developers.samsara.com/reference/createcontact)",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
samsara,
|
|
12
|
+
firstName: {
|
|
13
|
+
type: "string",
|
|
14
|
+
label: "First Name",
|
|
15
|
+
description: "First name of the contact.",
|
|
16
|
+
optional: true,
|
|
17
|
+
},
|
|
18
|
+
lastName: {
|
|
19
|
+
type: "string",
|
|
20
|
+
label: "Last Name",
|
|
21
|
+
description: "Last name of the contact.",
|
|
22
|
+
optional: true,
|
|
23
|
+
},
|
|
24
|
+
email: {
|
|
25
|
+
type: "string",
|
|
26
|
+
label: "Email",
|
|
27
|
+
description: "Email address of the contact.",
|
|
28
|
+
optional: true,
|
|
29
|
+
},
|
|
30
|
+
phone: {
|
|
31
|
+
type: "string",
|
|
32
|
+
label: "Phone Number",
|
|
33
|
+
description: "Phone number of the contact.",
|
|
34
|
+
optional: true,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
async run({ $ }) {
|
|
38
|
+
if (!this.email && !this.phone) {
|
|
39
|
+
throw new ConfigurationError("Either Email or Phone Number must be provided.");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const response = await this.samsara.createContact({
|
|
43
|
+
$,
|
|
44
|
+
data: {
|
|
45
|
+
firstName: this.firstName,
|
|
46
|
+
lastName: this.lastName,
|
|
47
|
+
email: this.email,
|
|
48
|
+
phone: this.phone,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
$.export("$summary", `Successfully created contact ${this.firstName} ${this.lastName}`);
|
|
52
|
+
return response;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import { parseObject } from "../../common/utils.mjs";
|
|
3
|
+
import samsara from "../../samsara.app.mjs";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
key: "samsara-create-route",
|
|
7
|
+
name: "Create Route",
|
|
8
|
+
description: "Generates a new route to an existing address. As a prerequisite, the user must create an address using the 'create-address' action if the location is not already available in the address book. The user must provide the necessary props such as destination address.",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
type: "action",
|
|
11
|
+
props: {
|
|
12
|
+
samsara,
|
|
13
|
+
driverId: {
|
|
14
|
+
propDefinition: [
|
|
15
|
+
samsara,
|
|
16
|
+
"driverId",
|
|
17
|
+
],
|
|
18
|
+
optional: true,
|
|
19
|
+
},
|
|
20
|
+
externalIds: {
|
|
21
|
+
propDefinition: [
|
|
22
|
+
samsara,
|
|
23
|
+
"externalIds",
|
|
24
|
+
],
|
|
25
|
+
optional: true,
|
|
26
|
+
},
|
|
27
|
+
name: {
|
|
28
|
+
type: "string",
|
|
29
|
+
label: "Name",
|
|
30
|
+
description: "Name for the route",
|
|
31
|
+
},
|
|
32
|
+
notes: {
|
|
33
|
+
type: "string",
|
|
34
|
+
label: "Notes",
|
|
35
|
+
description: "Notes about the route.",
|
|
36
|
+
optional: true,
|
|
37
|
+
},
|
|
38
|
+
routeCompletionCondition: {
|
|
39
|
+
type: "string",
|
|
40
|
+
label: "Route Completion Condition",
|
|
41
|
+
description: "Defaults to 'arriveLastStop' which ends the route upon arriving at the final stop. The condition 'departLastStop' ends the route upon departing the last stop. If 'arriveLastStop' is set, then the departure time of the final stop should not be set.",
|
|
42
|
+
options: [
|
|
43
|
+
"arriveLastStop",
|
|
44
|
+
"departLastStop",
|
|
45
|
+
],
|
|
46
|
+
optional: true,
|
|
47
|
+
},
|
|
48
|
+
routeStartingCondition: {
|
|
49
|
+
type: "string",
|
|
50
|
+
label: "Route Starting Condition",
|
|
51
|
+
description: "Defaults to 'departFirstStop' which starts the route upon departing the first stop in the route. The condition 'arriveFirstStop' starts the route upon arriving at the first stop in the route. If 'departFirstStop' is set, the arrival time of the first stop should not be set.",
|
|
52
|
+
options: [
|
|
53
|
+
"departFirstStop",
|
|
54
|
+
"arriveFirstStop",
|
|
55
|
+
],
|
|
56
|
+
optional: true,
|
|
57
|
+
},
|
|
58
|
+
stops: {
|
|
59
|
+
type: "object",
|
|
60
|
+
label: "Stops",
|
|
61
|
+
description: "List of objects of stops along the route. For each stop, exactly one of addressId and singleUseLocation are required. Depending on the settings on your route, either a scheduledArrivalTime or scheduledDepartureTime must be specified for the first job. [See further information](https://developers.samsara.com/reference/createroute)",
|
|
62
|
+
},
|
|
63
|
+
vehicleId: {
|
|
64
|
+
propDefinition: [
|
|
65
|
+
samsara,
|
|
66
|
+
"vehicleId",
|
|
67
|
+
],
|
|
68
|
+
optional: true,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
async run({ $ }) {
|
|
72
|
+
try {
|
|
73
|
+
const response = await this.samsara.createRoute({
|
|
74
|
+
$,
|
|
75
|
+
data: {
|
|
76
|
+
driverId: this.driverId,
|
|
77
|
+
externalIds: parseObject(this.externalIds),
|
|
78
|
+
name: this.name,
|
|
79
|
+
notes: this.notes,
|
|
80
|
+
settings: {
|
|
81
|
+
routeCompletionCondition: this.routeCompletionCondition,
|
|
82
|
+
routeStartingCondition: this.routeStartingCondition,
|
|
83
|
+
},
|
|
84
|
+
stops: parseObject(this.stops),
|
|
85
|
+
vehicleId: this.vehicleId,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
$.export("$summary", `Successfully created a new route with Id: ${response.data?.id}`);
|
|
90
|
+
return response;
|
|
91
|
+
} catch ({ message }) {
|
|
92
|
+
throw new ConfigurationError(JSON.parse(message).message);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
};
|
package/common/utils.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const parseObject = (obj) => {
|
|
2
|
+
if (!obj) return undefined;
|
|
3
|
+
|
|
4
|
+
if (Array.isArray(obj)) {
|
|
5
|
+
return obj.map((item) => {
|
|
6
|
+
if (typeof item === "string") {
|
|
7
|
+
try {
|
|
8
|
+
return JSON.parse(item);
|
|
9
|
+
} catch (e) {
|
|
10
|
+
return item;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return item;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (typeof obj === "string") {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(obj);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return obj;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const cleanObject = (o) => {
|
|
27
|
+
for (let k in o || {}) {
|
|
28
|
+
if (typeof o[k] === "undefined") {
|
|
29
|
+
delete o[k];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return o;
|
|
33
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/samsara",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Pipedream Samsara Components",
|
|
5
5
|
"main": "samsara.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -11,5 +11,8 @@
|
|
|
11
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@pipedream/platform": "^2.0.0"
|
|
14
17
|
}
|
|
15
18
|
}
|
package/samsara.app.mjs
CHANGED
|
@@ -1,11 +1,164 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
|
|
1
3
|
export default {
|
|
2
4
|
type: "app",
|
|
3
5
|
app: "samsara",
|
|
4
|
-
propDefinitions: {
|
|
6
|
+
propDefinitions: {
|
|
7
|
+
contactIds: {
|
|
8
|
+
type: "string[]",
|
|
9
|
+
label: "Contact Ids",
|
|
10
|
+
description: "An array of Contact IDs associated with this Address.",
|
|
11
|
+
async options({ page }) {
|
|
12
|
+
const { data } = await this.listContacts({
|
|
13
|
+
params: {
|
|
14
|
+
page,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return data.map((contact) => ({
|
|
19
|
+
label: `${contact.firstName} ${contact.lastName}` || contact.email || contact.phone,
|
|
20
|
+
value: contact.id,
|
|
21
|
+
}));
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
driverId: {
|
|
25
|
+
type: "string",
|
|
26
|
+
label: "Driver Id",
|
|
27
|
+
description: "ID of the driver.",
|
|
28
|
+
async options({ page }) {
|
|
29
|
+
const { data } = await this.listDrivers({
|
|
30
|
+
params: {
|
|
31
|
+
page,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return data.map(({
|
|
36
|
+
id: value, name: label,
|
|
37
|
+
}) => ({
|
|
38
|
+
label,
|
|
39
|
+
value,
|
|
40
|
+
}));
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
tagIds: {
|
|
44
|
+
type: "string[]",
|
|
45
|
+
label: "Tag Ids",
|
|
46
|
+
description: "An array of IDs of tags to associate with this address.",
|
|
47
|
+
async options({ page }) {
|
|
48
|
+
const { data } = await this.listTags({
|
|
49
|
+
params: {
|
|
50
|
+
page,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return data.map(({
|
|
55
|
+
id: value, name: label,
|
|
56
|
+
}) => ({
|
|
57
|
+
label,
|
|
58
|
+
value,
|
|
59
|
+
}));
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
vehicleId: {
|
|
63
|
+
type: "string",
|
|
64
|
+
label: "Vehicle Id",
|
|
65
|
+
description: "ID of the vehicle.",
|
|
66
|
+
async options({ page }) {
|
|
67
|
+
const { data } = await this.listVehicles({
|
|
68
|
+
params: {
|
|
69
|
+
page,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return data.map(({
|
|
74
|
+
id: value, name: label,
|
|
75
|
+
}) => ({
|
|
76
|
+
label,
|
|
77
|
+
value,
|
|
78
|
+
}));
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
externalIds: {
|
|
82
|
+
type: "object",
|
|
83
|
+
label: "External Ids",
|
|
84
|
+
description: "The external IDs for the given object.",
|
|
85
|
+
},
|
|
86
|
+
},
|
|
5
87
|
methods: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
88
|
+
_baseUrl() {
|
|
89
|
+
return "https://api.samsara.com";
|
|
90
|
+
},
|
|
91
|
+
_headers() {
|
|
92
|
+
return {
|
|
93
|
+
Authorization: `Bearer ${this.$auth.api_token}`,
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
_makeRequest({
|
|
97
|
+
$ = this, path, ...opts
|
|
98
|
+
}) {
|
|
99
|
+
return axios($, {
|
|
100
|
+
url: this._baseUrl() + path,
|
|
101
|
+
headers: this._headers(),
|
|
102
|
+
...opts,
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
createContact(opts = {}) {
|
|
106
|
+
return this._makeRequest({
|
|
107
|
+
method: "POST",
|
|
108
|
+
path: "/contacts",
|
|
109
|
+
...opts,
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
listContacts(opts = {}) {
|
|
113
|
+
return this._makeRequest({
|
|
114
|
+
path: "/contacts",
|
|
115
|
+
...opts,
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
listDrivers(opts = {}) {
|
|
119
|
+
return this._makeRequest({
|
|
120
|
+
path: "/fleet/drivers",
|
|
121
|
+
...opts,
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
listTags(opts = {}) {
|
|
125
|
+
return this._makeRequest({
|
|
126
|
+
path: "/tags",
|
|
127
|
+
...opts,
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
listVehicles(opts = {}) {
|
|
131
|
+
return this._makeRequest({
|
|
132
|
+
path: "/fleet/vehicles",
|
|
133
|
+
...opts,
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
createAddress(opts = {}) {
|
|
137
|
+
return this._makeRequest({
|
|
138
|
+
method: "POST",
|
|
139
|
+
path: "/addresses",
|
|
140
|
+
...opts,
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
createRoute(opts = {}) {
|
|
144
|
+
return this._makeRequest({
|
|
145
|
+
method: "POST",
|
|
146
|
+
path: "/fleet/routes",
|
|
147
|
+
...opts,
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
createWebhook(opts = {}) {
|
|
151
|
+
return this._makeRequest({
|
|
152
|
+
method: "POST",
|
|
153
|
+
path: "/webhooks",
|
|
154
|
+
...opts,
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
deleteWebhook(webhookId) {
|
|
158
|
+
return this._makeRequest({
|
|
159
|
+
method: "DELETE",
|
|
160
|
+
path: `/webhooks/${webhookId}`,
|
|
161
|
+
});
|
|
9
162
|
},
|
|
10
163
|
},
|
|
11
|
-
};
|
|
164
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import samsara from "../../samsara.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
props: {
|
|
5
|
+
samsara,
|
|
6
|
+
db: "$.service.db",
|
|
7
|
+
http: {
|
|
8
|
+
type: "$.interface.http",
|
|
9
|
+
customResponse: true,
|
|
10
|
+
},
|
|
11
|
+
name: {
|
|
12
|
+
type: "string",
|
|
13
|
+
label: "Name",
|
|
14
|
+
description: "The name of the webhook. This will appear in both Samsara's cloud dashboard and the API. It can be set or updated through the Samsara Dashboard or through the API at any time.",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
methods: {
|
|
18
|
+
getWebhookProps() {
|
|
19
|
+
return {};
|
|
20
|
+
},
|
|
21
|
+
_setHookId(hookId) {
|
|
22
|
+
this.db.set("hookId", hookId);
|
|
23
|
+
},
|
|
24
|
+
_getHookId() {
|
|
25
|
+
return this.db.get("hookId");
|
|
26
|
+
},
|
|
27
|
+
checkEvent() {
|
|
28
|
+
return true;
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
hooks: {
|
|
32
|
+
async activate() {
|
|
33
|
+
const webhook = await this.samsara.createWebhook({
|
|
34
|
+
data: {
|
|
35
|
+
name: this.name,
|
|
36
|
+
url: this.http.endpoint,
|
|
37
|
+
eventTypes: this.getEventTypes(),
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
this._setHookId(webhook.id);
|
|
41
|
+
},
|
|
42
|
+
async deactivate() {
|
|
43
|
+
const hookId = this._getHookId();
|
|
44
|
+
return await this.samsara.deleteWebhook(hookId);
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
async run({ body }) {
|
|
48
|
+
this.http.respond({
|
|
49
|
+
status: 200,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (this.checkEvent(body)) {
|
|
53
|
+
this.$emit(body, {
|
|
54
|
+
id: body.eventId,
|
|
55
|
+
summary: this.getSummary(body),
|
|
56
|
+
ts: body.eventTime,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
},
|
|
61
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import common from "../common/base.mjs";
|
|
2
|
+
import sampleEmit from "./test-event.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "samsara-new-document-submitted-instant",
|
|
7
|
+
name: "New Document Submitted (Instant)",
|
|
8
|
+
description: "Emit new event when a document is submitted.",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
type: "source",
|
|
11
|
+
dedupe: "unique",
|
|
12
|
+
props: {
|
|
13
|
+
...common.props,
|
|
14
|
+
},
|
|
15
|
+
methods: {
|
|
16
|
+
...common.methods,
|
|
17
|
+
getEventTypes() {
|
|
18
|
+
return [
|
|
19
|
+
"DocumentSubmitted",
|
|
20
|
+
];
|
|
21
|
+
},
|
|
22
|
+
getSummary({ data }) {
|
|
23
|
+
return `New document with Id: ${data.document.id} successfully submitted!`;
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
sampleEmit,
|
|
27
|
+
};
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"eventId": "017db07f-6e95-470e-8cc0-a371f9deed2b",
|
|
3
|
+
"eventTime": "1970-01-20T06:39:05.683Z",
|
|
4
|
+
"eventType": "DocumentSubmitted",
|
|
5
|
+
"orgId": 20936,
|
|
6
|
+
"webhookId": "1411751028848270",
|
|
7
|
+
"data": {
|
|
8
|
+
"document": {
|
|
9
|
+
"conditionalFieldSections": [
|
|
10
|
+
{
|
|
11
|
+
"conditionalFieldFirstIndex": 5083143870897228000,
|
|
12
|
+
"conditionalFieldLastIndex": 2770896918544835600,
|
|
13
|
+
"triggeringFieldIndex": 8389989517472915000,
|
|
14
|
+
"triggeringFieldValue": "Optiona 1"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"conditionalFieldFirstIndex": 5083143870897228000,
|
|
18
|
+
"conditionalFieldLastIndex": 2770896918544835600,
|
|
19
|
+
"triggeringFieldIndex": 8389989517472915000,
|
|
20
|
+
"triggeringFieldValue": "Optiona 1"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"conditionalFieldFirstIndex": 5083143870897228000,
|
|
24
|
+
"conditionalFieldLastIndex": 2770896918544835600,
|
|
25
|
+
"triggeringFieldIndex": 8389989517472915000,
|
|
26
|
+
"triggeringFieldValue": "Optiona 1"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"createdAtTime": "1976-03-06T08:22:53Z",
|
|
30
|
+
"documentType": {
|
|
31
|
+
"id": "9814a1fa-f0c6-408b-bf85-51dc3bc71ac7",
|
|
32
|
+
"name": "Fleet Truck List"
|
|
33
|
+
},
|
|
34
|
+
"fields": [
|
|
35
|
+
{
|
|
36
|
+
"label": "Load weight",
|
|
37
|
+
"type": "photo",
|
|
38
|
+
"value": {
|
|
39
|
+
"barcodeValue": [
|
|
40
|
+
{
|
|
41
|
+
"barcodeType": "org.gs1.EAN-13",
|
|
42
|
+
"barcodeValue": "0853883003114"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"barcodeType": "org.gs1.EAN-13",
|
|
46
|
+
"barcodeValue": "0853883003114"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"barcodeType": "org.gs1.EAN-13",
|
|
50
|
+
"barcodeValue": "0853883003114"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"barcodeType": "org.gs1.EAN-13",
|
|
54
|
+
"barcodeValue": "0853883003114"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"dateTimeValue": {
|
|
58
|
+
"dateTime": "1984-10-23T07:14:29Z"
|
|
59
|
+
},
|
|
60
|
+
"multipleChoiceValue": [
|
|
61
|
+
{
|
|
62
|
+
"selected": false,
|
|
63
|
+
"value": "Yes"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"selected": false,
|
|
67
|
+
"value": "Yes"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"selected": false,
|
|
71
|
+
"value": "Yes"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"numberValue": 123.456,
|
|
75
|
+
"photoValue": [
|
|
76
|
+
{
|
|
77
|
+
"id": "f5271458-21f9-4a9f-a290-780c6d8840ff",
|
|
78
|
+
"url": "https://samsara-driver-media-upload.s3.us-west-2.amazonaws.com/123456"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"id": "f5271458-21f9-4a9f-a290-780c6d8840ff",
|
|
82
|
+
"url": "https://samsara-driver-media-upload.s3.us-west-2.amazonaws.com/123456"
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"scannedDocumentValue": [
|
|
86
|
+
{
|
|
87
|
+
"id": "f5271458-21f9-4a9f-a290-780c6d8840ff",
|
|
88
|
+
"url": "https://samsara-driver-media-upload.s3.us-west-2.amazonaws.com/123456"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"id": "f5271458-21f9-4a9f-a290-780c6d8840ff",
|
|
92
|
+
"url": "https://samsara-driver-media-upload.s3.us-west-2.amazonaws.com/123456"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"id": "f5271458-21f9-4a9f-a290-780c6d8840ff",
|
|
96
|
+
"url": "https://samsara-driver-media-upload.s3.us-west-2.amazonaws.com/123456"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"signatureValue": {
|
|
100
|
+
"id": "9814a1fa-f0c6-408b-bf85-51dc3bc71ac7",
|
|
101
|
+
"name": "John Smith",
|
|
102
|
+
"signedAtTime": "1996-01-30T06:14:20Z",
|
|
103
|
+
"url": "https://samsara-driver-media-upload.s3.us-west-2.amazonaws.com/123456"
|
|
104
|
+
},
|
|
105
|
+
"stringValue": "Red Truck"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"label": "Load weight",
|
|
110
|
+
"type": "photo",
|
|
111
|
+
"value": {
|
|
112
|
+
"barcodeValue": [
|
|
113
|
+
{
|
|
114
|
+
"barcodeType": "org.gs1.EAN-13",
|
|
115
|
+
"barcodeValue": "0853883003114"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"barcodeType": "org.gs1.EAN-13",
|
|
119
|
+
"barcodeValue": "0853883003114"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"barcodeType": "org.gs1.EAN-13",
|
|
123
|
+
"barcodeValue": "0853883003114"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"barcodeType": "org.gs1.EAN-13",
|
|
127
|
+
"barcodeValue": "0853883003114"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"dateTimeValue": {
|
|
131
|
+
"dateTime": "1984-10-23T07:14:29Z"
|
|
132
|
+
},
|
|
133
|
+
"multipleChoiceValue": [
|
|
134
|
+
{
|
|
135
|
+
"selected": false,
|
|
136
|
+
"value": "Yes"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"selected": false,
|
|
140
|
+
"value": "Yes"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"selected": false,
|
|
144
|
+
"value": "Yes"
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
"numberValue": 123.456,
|
|
148
|
+
"photoValue": [
|
|
149
|
+
{
|
|
150
|
+
"id": "f5271458-21f9-4a9f-a290-780c6d8840ff",
|
|
151
|
+
"url": "https://samsara-driver-media-upload.s3.us-west-2.amazonaws.com/123456"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"id": "f5271458-21f9-4a9f-a290-780c6d8840ff",
|
|
155
|
+
"url": "https://samsara-driver-media-upload.s3.us-west-2.amazonaws.com/123456"
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
"scannedDocumentValue": [
|
|
159
|
+
{
|
|
160
|
+
"id": "f5271458-21f9-4a9f-a290-780c6d8840ff",
|
|
161
|
+
"url": "https://samsara-driver-media-upload.s3.us-west-2.amazonaws.com/123456"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"id": "f5271458-21f9-4a9f-a290-780c6d8840ff",
|
|
165
|
+
"url": "https://samsara-driver-media-upload.s3.us-west-2.amazonaws.com/123456"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"id": "f5271458-21f9-4a9f-a290-780c6d8840ff",
|
|
169
|
+
"url": "https://samsara-driver-media-upload.s3.us-west-2.amazonaws.com/123456"
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
"signatureValue": {
|
|
173
|
+
"id": "9814a1fa-f0c6-408b-bf85-51dc3bc71ac7",
|
|
174
|
+
"name": "John Smith",
|
|
175
|
+
"signedAtTime": "1996-01-30T06:14:20Z",
|
|
176
|
+
"url": "https://samsara-driver-media-upload.s3.us-west-2.amazonaws.com/123456"
|
|
177
|
+
},
|
|
178
|
+
"stringValue": "Red Truck"
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"id": "9814a1fa-f0c6-408b-bf85-51dc3bc71ac7",
|
|
183
|
+
"name": "Dropoff Slip 123",
|
|
184
|
+
"notes": "Missing a crate",
|
|
185
|
+
"route": {
|
|
186
|
+
"externalIds": {
|
|
187
|
+
"myRouteId": "abc"
|
|
188
|
+
},
|
|
189
|
+
"id": "131313",
|
|
190
|
+
"name": "Pineapple delivery"
|
|
191
|
+
},
|
|
192
|
+
"routeStop": {
|
|
193
|
+
"externalIds": {
|
|
194
|
+
"siteId": "54"
|
|
195
|
+
},
|
|
196
|
+
"id": "494123",
|
|
197
|
+
"name": "Company Warehouse #1"
|
|
198
|
+
},
|
|
199
|
+
"state": "submitted",
|
|
200
|
+
"updatedAtTime": "2009-01-10T02:28:18Z"
|
|
201
|
+
},
|
|
202
|
+
"driver": {
|
|
203
|
+
"externalIds": {
|
|
204
|
+
"payrollId": "ABFS18600"
|
|
205
|
+
},
|
|
206
|
+
"id": "45646",
|
|
207
|
+
"name": "Driver Bob"
|
|
208
|
+
},
|
|
209
|
+
"vehicle": {
|
|
210
|
+
"assetType": "vehicle",
|
|
211
|
+
"externalIds": {
|
|
212
|
+
"maintenanceId": "250020"
|
|
213
|
+
},
|
|
214
|
+
"gateway": {
|
|
215
|
+
"model": "VG34",
|
|
216
|
+
"serial": "GFRV-43N-VGX"
|
|
217
|
+
},
|
|
218
|
+
"id": "494123",
|
|
219
|
+
"licensePlate": "6SAM123",
|
|
220
|
+
"name": "Fleet Truck #1",
|
|
221
|
+
"vin": "1GBJ6P1B2HV112765"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import common from "../common/base.mjs";
|
|
2
|
+
import sampleEmit from "./test-event.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "samsara-new-route-job-completion-instant",
|
|
7
|
+
name: "New Route Job Completion (Instant)",
|
|
8
|
+
description: "Emit new event when a job is completed on a Samsara route.",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
type: "source",
|
|
11
|
+
dedupe: "unique",
|
|
12
|
+
props: {
|
|
13
|
+
...common.props,
|
|
14
|
+
},
|
|
15
|
+
methods: {
|
|
16
|
+
...common.methods,
|
|
17
|
+
getEventTypes() {
|
|
18
|
+
return [
|
|
19
|
+
"RouteStopDeparture",
|
|
20
|
+
"RouteStopArrival",
|
|
21
|
+
];
|
|
22
|
+
},
|
|
23
|
+
getSummary({ data }) {
|
|
24
|
+
return `Route ${data.route.name} successfully completed.`;
|
|
25
|
+
},
|
|
26
|
+
checkEvent({ data }) {
|
|
27
|
+
const filteredStops = data.route.stops.filter((stop) => {
|
|
28
|
+
return stop.state != "departed";
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return !filteredStops.length;
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
sampleEmit,
|
|
35
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"eventId": "017db07f-6e95-470e-8cc0-a371f9deed2b",
|
|
3
|
+
"eventTime": "1970-01-20T06:39:05.683Z",
|
|
4
|
+
"eventType": "RouteStopArrival",
|
|
5
|
+
"orgId": 20936,
|
|
6
|
+
"webhookId": "1411751028848270",
|
|
7
|
+
"data": {
|
|
8
|
+
"driver": {
|
|
9
|
+
"externalIds": {
|
|
10
|
+
"payrollId": "ABFS18600"
|
|
11
|
+
},
|
|
12
|
+
"id": "45646",
|
|
13
|
+
"name": "Driver Bob"
|
|
14
|
+
},
|
|
15
|
+
"operation": "stop arrived",
|
|
16
|
+
"route": {
|
|
17
|
+
"actualRouteEndTime": "2019-06-13T19:08:25Z",
|
|
18
|
+
"actualRouteStartTime": "2019-06-13T19:08:25Z",
|
|
19
|
+
"externalIds": {
|
|
20
|
+
"myRouteId": "abc"
|
|
21
|
+
},
|
|
22
|
+
"id": "342341",
|
|
23
|
+
"name": "Bid 123",
|
|
24
|
+
"notes": "These are my notes",
|
|
25
|
+
"scheduledRouteEndTime": "2019-06-13T19:08:25Z",
|
|
26
|
+
"scheduledRouteStartTime": "2019-06-13T19:08:25Z",
|
|
27
|
+
"settings": {
|
|
28
|
+
"routeCompletionCondition": "arriveLastStop",
|
|
29
|
+
"routeStartingCondition": "departFirstStop"
|
|
30
|
+
},
|
|
31
|
+
"stops": [
|
|
32
|
+
{
|
|
33
|
+
"actualArrivalTime": "2006-01-02T15:04:05+07:00",
|
|
34
|
+
"actualDepartureTime": "2006-01-02T15:04:05+07:00",
|
|
35
|
+
"address": {
|
|
36
|
+
"externalIds": {
|
|
37
|
+
"siteId": "54"
|
|
38
|
+
},
|
|
39
|
+
"id": "494123",
|
|
40
|
+
"name": "Company Office #1"
|
|
41
|
+
},
|
|
42
|
+
"documents": [
|
|
43
|
+
{
|
|
44
|
+
"id": "494123",
|
|
45
|
+
"name": "Fuel Receipt Wichita"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": "494123",
|
|
49
|
+
"name": "Fuel Receipt Wichita"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"enRouteTime": "2006-01-02T15:04:05+07:00",
|
|
53
|
+
"eta": "2006-01-02T15:04:05+07:00",
|
|
54
|
+
"externalIds": {
|
|
55
|
+
"siteId": "54"
|
|
56
|
+
},
|
|
57
|
+
"id": "324231",
|
|
58
|
+
"liveSharingUrl": "https://cloud.samsara.com/fleet/viewer/job/fleet_viewer_token",
|
|
59
|
+
"locationLiveSharingLinks": [
|
|
60
|
+
{
|
|
61
|
+
"expiresAtTime": "2020-01-27T07:06:25Z",
|
|
62
|
+
"liveSharingUrl": "https://cloud.samsara.com/o/123456/fleet/viewer/address/gEAitEnnOwcv92cuPzcU",
|
|
63
|
+
"name": "Name"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"expiresAtTime": "2020-01-27T07:06:25Z",
|
|
67
|
+
"liveSharingUrl": "https://cloud.samsara.com/o/123456/fleet/viewer/address/gEAitEnnOwcv92cuPzcU",
|
|
68
|
+
"name": "Name"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"name": "Stop #1",
|
|
72
|
+
"notes": "These are my notes",
|
|
73
|
+
"scheduledArrivalTime": "2019-06-13T19:08:25Z",
|
|
74
|
+
"scheduledDepartureTime": "2019-06-13T19:08:25Z",
|
|
75
|
+
"singleUseLocation": {
|
|
76
|
+
"address": "1234 Main St, San Jose, CA",
|
|
77
|
+
"latitude": 123.456,
|
|
78
|
+
"longitude": 37.459
|
|
79
|
+
},
|
|
80
|
+
"skippedTime": "2006-01-02T15:04:05+07:00",
|
|
81
|
+
"state": "scheduled"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"actualArrivalTime": "2006-01-02T15:04:05+07:00",
|
|
85
|
+
"actualDepartureTime": "2006-01-02T15:04:05+07:00",
|
|
86
|
+
"address": {
|
|
87
|
+
"externalIds": {
|
|
88
|
+
"siteId": "54"
|
|
89
|
+
},
|
|
90
|
+
"id": "494123",
|
|
91
|
+
"name": "Company Office #1"
|
|
92
|
+
},
|
|
93
|
+
"documents": [
|
|
94
|
+
{
|
|
95
|
+
"id": "494123",
|
|
96
|
+
"name": "Fuel Receipt Wichita"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"id": "494123",
|
|
100
|
+
"name": "Fuel Receipt Wichita"
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"enRouteTime": "2006-01-02T15:04:05+07:00",
|
|
104
|
+
"eta": "2006-01-02T15:04:05+07:00",
|
|
105
|
+
"externalIds": {
|
|
106
|
+
"siteId": "54"
|
|
107
|
+
},
|
|
108
|
+
"id": "324231",
|
|
109
|
+
"liveSharingUrl": "https://cloud.samsara.com/fleet/viewer/job/fleet_viewer_token",
|
|
110
|
+
"locationLiveSharingLinks": [
|
|
111
|
+
{
|
|
112
|
+
"expiresAtTime": "2020-01-27T07:06:25Z",
|
|
113
|
+
"liveSharingUrl": "https://cloud.samsara.com/o/123456/fleet/viewer/address/gEAitEnnOwcv92cuPzcU",
|
|
114
|
+
"name": "Name"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"expiresAtTime": "2020-01-27T07:06:25Z",
|
|
118
|
+
"liveSharingUrl": "https://cloud.samsara.com/o/123456/fleet/viewer/address/gEAitEnnOwcv92cuPzcU",
|
|
119
|
+
"name": "Name"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"name": "Stop #1",
|
|
123
|
+
"notes": "These are my notes",
|
|
124
|
+
"scheduledArrivalTime": "2019-06-13T19:08:25Z",
|
|
125
|
+
"scheduledDepartureTime": "2019-06-13T19:08:25Z",
|
|
126
|
+
"singleUseLocation": {
|
|
127
|
+
"address": "1234 Main St, San Jose, CA",
|
|
128
|
+
"latitude": 123.456,
|
|
129
|
+
"longitude": 37.459
|
|
130
|
+
},
|
|
131
|
+
"skippedTime": "2006-01-02T15:04:05+07:00",
|
|
132
|
+
"state": "scheduled"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"actualArrivalTime": "2006-01-02T15:04:05+07:00",
|
|
136
|
+
"actualDepartureTime": "2006-01-02T15:04:05+07:00",
|
|
137
|
+
"address": {
|
|
138
|
+
"externalIds": {
|
|
139
|
+
"siteId": "54"
|
|
140
|
+
},
|
|
141
|
+
"id": "494123",
|
|
142
|
+
"name": "Company Office #1"
|
|
143
|
+
},
|
|
144
|
+
"documents": [
|
|
145
|
+
{
|
|
146
|
+
"id": "494123",
|
|
147
|
+
"name": "Fuel Receipt Wichita"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "494123",
|
|
151
|
+
"name": "Fuel Receipt Wichita"
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
"enRouteTime": "2006-01-02T15:04:05+07:00",
|
|
155
|
+
"eta": "2006-01-02T15:04:05+07:00",
|
|
156
|
+
"externalIds": {
|
|
157
|
+
"siteId": "54"
|
|
158
|
+
},
|
|
159
|
+
"id": "324231",
|
|
160
|
+
"liveSharingUrl": "https://cloud.samsara.com/fleet/viewer/job/fleet_viewer_token",
|
|
161
|
+
"locationLiveSharingLinks": [
|
|
162
|
+
{
|
|
163
|
+
"expiresAtTime": "2020-01-27T07:06:25Z",
|
|
164
|
+
"liveSharingUrl": "https://cloud.samsara.com/o/123456/fleet/viewer/address/gEAitEnnOwcv92cuPzcU",
|
|
165
|
+
"name": "Name"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"expiresAtTime": "2020-01-27T07:06:25Z",
|
|
169
|
+
"liveSharingUrl": "https://cloud.samsara.com/o/123456/fleet/viewer/address/gEAitEnnOwcv92cuPzcU",
|
|
170
|
+
"name": "Name"
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
"name": "Stop #1",
|
|
174
|
+
"notes": "These are my notes",
|
|
175
|
+
"scheduledArrivalTime": "2019-06-13T19:08:25Z",
|
|
176
|
+
"scheduledDepartureTime": "2019-06-13T19:08:25Z",
|
|
177
|
+
"singleUseLocation": {
|
|
178
|
+
"address": "1234 Main St, San Jose, CA",
|
|
179
|
+
"latitude": 123.456,
|
|
180
|
+
"longitude": 37.459
|
|
181
|
+
},
|
|
182
|
+
"skippedTime": "2006-01-02T15:04:05+07:00",
|
|
183
|
+
"state": "scheduled"
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
"routeStopDetails": {
|
|
188
|
+
"actualArrivalTime": "2006-01-02T15:04:05+07:00",
|
|
189
|
+
"actualDepartureTime": "2006-01-02T15:04:05+07:00",
|
|
190
|
+
"enRouteTime": "2006-01-02T15:04:05+07:00",
|
|
191
|
+
"eta": "2006-01-02T15:04:05+07:00",
|
|
192
|
+
"externalIds": {
|
|
193
|
+
"siteId": "54"
|
|
194
|
+
},
|
|
195
|
+
"id": "141414",
|
|
196
|
+
"liveSharingUrl": "https://cloud.samsara.com/fleet/viewer/job/fleet_viewer_token",
|
|
197
|
+
"skippedTime": "2006-01-02T15:04:05+07:00",
|
|
198
|
+
"state": "scheduled"
|
|
199
|
+
},
|
|
200
|
+
"time": "2020-01-27T07:06:25Z",
|
|
201
|
+
"type": "route tracking",
|
|
202
|
+
"vehicle": {
|
|
203
|
+
"assetType": "vehicle",
|
|
204
|
+
"externalIds": {
|
|
205
|
+
"maintenanceId": "250020"
|
|
206
|
+
},
|
|
207
|
+
"gateway": {
|
|
208
|
+
"model": "VG34",
|
|
209
|
+
"serial": "GFRV-43N-VGX"
|
|
210
|
+
},
|
|
211
|
+
"id": "494123",
|
|
212
|
+
"licensePlate": "6SAM123",
|
|
213
|
+
"name": "Fleet Truck #1",
|
|
214
|
+
"vin": "1GBJ6P1B2HV112765"
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import common from "../common/base.mjs";
|
|
2
|
+
import sampleEmit from "./test-event.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "samsara-new-route-started-instant",
|
|
7
|
+
name: "New Route Started (Instant)",
|
|
8
|
+
description: "Emit new event when a new route is stated.",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
type: "source",
|
|
11
|
+
dedupe: "unique",
|
|
12
|
+
props: {
|
|
13
|
+
...common.props,
|
|
14
|
+
},
|
|
15
|
+
methods: {
|
|
16
|
+
...common.methods,
|
|
17
|
+
getEventTypes() {
|
|
18
|
+
return [
|
|
19
|
+
"RouteStopDeparture",
|
|
20
|
+
];
|
|
21
|
+
},
|
|
22
|
+
getSummary({ data }) {
|
|
23
|
+
return `New route with Id: ${data.route.id} successfully started!`;
|
|
24
|
+
},
|
|
25
|
+
checkEvent({ data }) {
|
|
26
|
+
const filteredStops = data.route.stops.filter((stop) => {
|
|
27
|
+
return stop.state === "departed";
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return filteredStops.length === 1;
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
sampleEmit,
|
|
34
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"eventId": "017db07f-6e95-470e-8cc0-a371f9deed2b",
|
|
3
|
+
"eventTime": "1970-01-20T06:39:05.683Z",
|
|
4
|
+
"eventType": "RouteStopDeparture",
|
|
5
|
+
"orgId": 20936,
|
|
6
|
+
"webhookId": "1411751028848270",
|
|
7
|
+
"data": {
|
|
8
|
+
"driver": {
|
|
9
|
+
"externalIds": {
|
|
10
|
+
"payrollId": "ABFS18600"
|
|
11
|
+
},
|
|
12
|
+
"id": "45646",
|
|
13
|
+
"name": "Driver Bob"
|
|
14
|
+
},
|
|
15
|
+
"operation": "stop arrived",
|
|
16
|
+
"route": {
|
|
17
|
+
"actualRouteEndTime": "2019-06-13T19:08:25Z",
|
|
18
|
+
"actualRouteStartTime": "2019-06-13T19:08:25Z",
|
|
19
|
+
"externalIds": {
|
|
20
|
+
"myRouteId": "abc"
|
|
21
|
+
},
|
|
22
|
+
"id": "342341",
|
|
23
|
+
"name": "Bid 123",
|
|
24
|
+
"notes": "These are my notes",
|
|
25
|
+
"scheduledRouteEndTime": "2019-06-13T19:08:25Z",
|
|
26
|
+
"scheduledRouteStartTime": "2019-06-13T19:08:25Z",
|
|
27
|
+
"settings": {
|
|
28
|
+
"routeCompletionCondition": "arriveLastStop",
|
|
29
|
+
"routeStartingCondition": "departFirstStop"
|
|
30
|
+
},
|
|
31
|
+
"stops": [
|
|
32
|
+
{
|
|
33
|
+
"actualArrivalTime": "2006-01-02T15:04:05+07:00",
|
|
34
|
+
"actualDepartureTime": "2006-01-02T15:04:05+07:00",
|
|
35
|
+
"address": {
|
|
36
|
+
"externalIds": {
|
|
37
|
+
"siteId": "54"
|
|
38
|
+
},
|
|
39
|
+
"id": "494123",
|
|
40
|
+
"name": "Company Office #1"
|
|
41
|
+
},
|
|
42
|
+
"documents": [
|
|
43
|
+
{
|
|
44
|
+
"id": "494123",
|
|
45
|
+
"name": "Fuel Receipt Wichita"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": "494123",
|
|
49
|
+
"name": "Fuel Receipt Wichita"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"enRouteTime": "2006-01-02T15:04:05+07:00",
|
|
53
|
+
"eta": "2006-01-02T15:04:05+07:00",
|
|
54
|
+
"externalIds": {
|
|
55
|
+
"siteId": "54"
|
|
56
|
+
},
|
|
57
|
+
"id": "324231",
|
|
58
|
+
"liveSharingUrl": "https://cloud.samsara.com/fleet/viewer/job/fleet_viewer_token",
|
|
59
|
+
"locationLiveSharingLinks": [
|
|
60
|
+
{
|
|
61
|
+
"expiresAtTime": "2020-01-27T07:06:25Z",
|
|
62
|
+
"liveSharingUrl": "https://cloud.samsara.com/o/123456/fleet/viewer/address/gEAitEnnOwcv92cuPzcU",
|
|
63
|
+
"name": "Name"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"expiresAtTime": "2020-01-27T07:06:25Z",
|
|
67
|
+
"liveSharingUrl": "https://cloud.samsara.com/o/123456/fleet/viewer/address/gEAitEnnOwcv92cuPzcU",
|
|
68
|
+
"name": "Name"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"name": "Stop #1",
|
|
72
|
+
"notes": "These are my notes",
|
|
73
|
+
"scheduledArrivalTime": "2019-06-13T19:08:25Z",
|
|
74
|
+
"scheduledDepartureTime": "2019-06-13T19:08:25Z",
|
|
75
|
+
"singleUseLocation": {
|
|
76
|
+
"address": "1234 Main St, San Jose, CA",
|
|
77
|
+
"latitude": 123.456,
|
|
78
|
+
"longitude": 37.459
|
|
79
|
+
},
|
|
80
|
+
"skippedTime": "2006-01-02T15:04:05+07:00",
|
|
81
|
+
"state": "scheduled"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"actualArrivalTime": "2006-01-02T15:04:05+07:00",
|
|
85
|
+
"actualDepartureTime": "2006-01-02T15:04:05+07:00",
|
|
86
|
+
"address": {
|
|
87
|
+
"externalIds": {
|
|
88
|
+
"siteId": "54"
|
|
89
|
+
},
|
|
90
|
+
"id": "494123",
|
|
91
|
+
"name": "Company Office #1"
|
|
92
|
+
},
|
|
93
|
+
"documents": [
|
|
94
|
+
{
|
|
95
|
+
"id": "494123",
|
|
96
|
+
"name": "Fuel Receipt Wichita"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"id": "494123",
|
|
100
|
+
"name": "Fuel Receipt Wichita"
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"enRouteTime": "2006-01-02T15:04:05+07:00",
|
|
104
|
+
"eta": "2006-01-02T15:04:05+07:00",
|
|
105
|
+
"externalIds": {
|
|
106
|
+
"siteId": "54"
|
|
107
|
+
},
|
|
108
|
+
"id": "324231",
|
|
109
|
+
"liveSharingUrl": "https://cloud.samsara.com/fleet/viewer/job/fleet_viewer_token",
|
|
110
|
+
"locationLiveSharingLinks": [
|
|
111
|
+
{
|
|
112
|
+
"expiresAtTime": "2020-01-27T07:06:25Z",
|
|
113
|
+
"liveSharingUrl": "https://cloud.samsara.com/o/123456/fleet/viewer/address/gEAitEnnOwcv92cuPzcU",
|
|
114
|
+
"name": "Name"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"expiresAtTime": "2020-01-27T07:06:25Z",
|
|
118
|
+
"liveSharingUrl": "https://cloud.samsara.com/o/123456/fleet/viewer/address/gEAitEnnOwcv92cuPzcU",
|
|
119
|
+
"name": "Name"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"name": "Stop #1",
|
|
123
|
+
"notes": "These are my notes",
|
|
124
|
+
"scheduledArrivalTime": "2019-06-13T19:08:25Z",
|
|
125
|
+
"scheduledDepartureTime": "2019-06-13T19:08:25Z",
|
|
126
|
+
"singleUseLocation": {
|
|
127
|
+
"address": "1234 Main St, San Jose, CA",
|
|
128
|
+
"latitude": 123.456,
|
|
129
|
+
"longitude": 37.459
|
|
130
|
+
},
|
|
131
|
+
"skippedTime": "2006-01-02T15:04:05+07:00",
|
|
132
|
+
"state": "scheduled"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"actualArrivalTime": "2006-01-02T15:04:05+07:00",
|
|
136
|
+
"actualDepartureTime": "2006-01-02T15:04:05+07:00",
|
|
137
|
+
"address": {
|
|
138
|
+
"externalIds": {
|
|
139
|
+
"siteId": "54"
|
|
140
|
+
},
|
|
141
|
+
"id": "494123",
|
|
142
|
+
"name": "Company Office #1"
|
|
143
|
+
},
|
|
144
|
+
"documents": [
|
|
145
|
+
{
|
|
146
|
+
"id": "494123",
|
|
147
|
+
"name": "Fuel Receipt Wichita"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "494123",
|
|
151
|
+
"name": "Fuel Receipt Wichita"
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
"enRouteTime": "2006-01-02T15:04:05+07:00",
|
|
155
|
+
"eta": "2006-01-02T15:04:05+07:00",
|
|
156
|
+
"externalIds": {
|
|
157
|
+
"siteId": "54"
|
|
158
|
+
},
|
|
159
|
+
"id": "324231",
|
|
160
|
+
"liveSharingUrl": "https://cloud.samsara.com/fleet/viewer/job/fleet_viewer_token",
|
|
161
|
+
"locationLiveSharingLinks": [
|
|
162
|
+
{
|
|
163
|
+
"expiresAtTime": "2020-01-27T07:06:25Z",
|
|
164
|
+
"liveSharingUrl": "https://cloud.samsara.com/o/123456/fleet/viewer/address/gEAitEnnOwcv92cuPzcU",
|
|
165
|
+
"name": "Name"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"expiresAtTime": "2020-01-27T07:06:25Z",
|
|
169
|
+
"liveSharingUrl": "https://cloud.samsara.com/o/123456/fleet/viewer/address/gEAitEnnOwcv92cuPzcU",
|
|
170
|
+
"name": "Name"
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
"name": "Stop #1",
|
|
174
|
+
"notes": "These are my notes",
|
|
175
|
+
"scheduledArrivalTime": "2019-06-13T19:08:25Z",
|
|
176
|
+
"scheduledDepartureTime": "2019-06-13T19:08:25Z",
|
|
177
|
+
"singleUseLocation": {
|
|
178
|
+
"address": "1234 Main St, San Jose, CA",
|
|
179
|
+
"latitude": 123.456,
|
|
180
|
+
"longitude": 37.459
|
|
181
|
+
},
|
|
182
|
+
"skippedTime": "2006-01-02T15:04:05+07:00",
|
|
183
|
+
"state": "scheduled"
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
"routeStopDetails": {
|
|
188
|
+
"actualArrivalTime": "2006-01-02T15:04:05+07:00",
|
|
189
|
+
"actualDepartureTime": "2006-01-02T15:04:05+07:00",
|
|
190
|
+
"enRouteTime": "2006-01-02T15:04:05+07:00",
|
|
191
|
+
"eta": "2006-01-02T15:04:05+07:00",
|
|
192
|
+
"externalIds": {
|
|
193
|
+
"siteId": "54"
|
|
194
|
+
},
|
|
195
|
+
"id": "141414",
|
|
196
|
+
"liveSharingUrl": "https://cloud.samsara.com/fleet/viewer/job/fleet_viewer_token",
|
|
197
|
+
"skippedTime": "2006-01-02T15:04:05+07:00",
|
|
198
|
+
"state": "scheduled"
|
|
199
|
+
},
|
|
200
|
+
"time": "2020-01-27T07:06:25Z",
|
|
201
|
+
"type": "route tracking",
|
|
202
|
+
"vehicle": {
|
|
203
|
+
"assetType": "vehicle",
|
|
204
|
+
"externalIds": {
|
|
205
|
+
"maintenanceId": "250020"
|
|
206
|
+
},
|
|
207
|
+
"gateway": {
|
|
208
|
+
"model": "VG34",
|
|
209
|
+
"serial": "GFRV-43N-VGX"
|
|
210
|
+
},
|
|
211
|
+
"id": "494123",
|
|
212
|
+
"licensePlate": "6SAM123",
|
|
213
|
+
"name": "Fleet Truck #1",
|
|
214
|
+
"vin": "1GBJ6P1B2HV112765"
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|