Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions components/optimoroute/actions/create-order/create-order.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import optimoroute from "../../optimoroute.app.mjs";

export default {
key: "optimoroute-create-order",
name: "Create Order",
description: "Create a new order. [See the documentation](https://optimoroute.com/api/#create-order)",
type: "action",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
optimoroute,
type: {
type: "string",
label: "Type",
description: "The type of order to create",
options: [
{
label: "Delivery",
value: "D",
},
{
label: "Pickup",
value: "P",
},
{
label: "Task",
value: "T",
},
],
},
date: {
type: "string",
label: "Date",
description: "YYYY-MM-DD format, for example `2013-12-20`",
},
address: {
type: "string",
label: "Address",
description: "The full address including the country, for example `393 Hanover St, Boston, MA 02113, US`",
},
orderNo: {
type: "string",
label: "Order Number",
description: "A user specified order identifier, also displayed in the web application",
},
priority: {
type: "string",
label: "Priority",
description: "The priority of the order",
options: [
{
label: "Low",
value: "L",
},
{
label: "Medium",
value: "M",
},
{
label: "High",
value: "H",
},
{
label: "Critical",
value: "C",
},
],
},
email: {
type: "string",
label: "Email",
description: "The customer email",
optional: true,
},
phone: {
type: "string",
label: "Phone",
description: "The customer phone number",
optional: true,
},
notes: {
type: "string",
label: "Notes",
description: "A note that will accompany the driver's instructions",
optional: true,
},
},
async run({ $ }) {
const response = await this.optimoroute.createOrder({
$,
data: {
operation: "CREATE",
type: this.type,
date: this.date,
location: {
address: this.address,
},
orderNo: this.orderNo,
priority: this.priority,
email: this.email,
phone: this.phone,
notes: this.notes,
},
});
$.export("$summary", `Successfully created order with ID: ${response.id}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import optimoroute from "../../optimoroute.app.mjs";

export default {
key: "optimoroute-get-mobile-events",
name: "Get Mobile Events",
description: "Get mobile events from Optimoroute. [See the documentation](https://optimoroute.com/api/#get-mobile-events)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
optimoroute,
afterTag: {
propDefinition: [
optimoroute,
"afterTag",
],
},
},
async run({ $ }) {
const response = await this.optimoroute.getMobileEvents({
$,
params: {
after_tag: this.afterTag,
},
});
$.export("$summary", `Mobile events found: ${response?.events?.length}`);
return response;
},
};
67 changes: 67 additions & 0 deletions components/optimoroute/actions/get-routes/get-routes.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import optimoroute from "../../optimoroute.app.mjs";

export default {
key: "optimoroute-get-routes",
name: "Get Routes",
description: "Get routes from Optimoroute. [See the documentation](https://optimoroute.com/api/#get-routes)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
optimoroute,
date: {
type: "string",
label: "Date",
description: "Queried date. YYYY-MM-DD format, for example `2013-12-20`",
},
driverExternalId: {
type: "string",
label: "Driver External ID",
description: "Optionally filter by drivers external identifier",
optional: true,
},
driverSerial: {
type: "string",
label: "Driver Serial",
description: "Optionally filter by Serial number of the Driver",
optional: true,
},
vehicleRegistration: {
type: "string",
label: "Vehicle Registration",
description: "Optionally filter by Vehicle registration",
optional: true,
},
includeRoutePolyline: {
type: "boolean",
label: "Include Route Polyline",
description: "Optional property to include route polyline in the output",
optional: true,
},
includeRouteStartEnd: {
type: "boolean",
label: "Include Route Start End",
description: "Optional property to include the route's start and end locations in the output",
optional: true,
},
},
async run({ $ }) {
const response = await this.optimoroute.getRoutes({
$,
params: {
date: this.date,
driverExternalId: this.driverExternalId,
driverSerial: this.driverSerial,
vehicleRegistration: this.vehicleRegistration,
includeRoutePolyline: this.includeRoutePolyline,
includeRouteStartEnd: this.includeRouteStartEnd,
},
});
$.export("$summary", `Routes found: ${response.routes.length}`);
return response;
},
};
61 changes: 61 additions & 0 deletions components/optimoroute/actions/search-orders/search-orders.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import optimoroute from "../../optimoroute.app.mjs";

export default {
key: "optimoroute-search-orders",
name: "Search Orders",
description: "Search for orders in Optimoroute. [See the documentation](https://optimoroute.com/api/#search-orders)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
optimoroute,
from: {
type: "string",
label: "From",
description: "From date. YYYY-MM-DD format, for example `2013-12-20`. The range can span at most 35 days, i.e. 5 weeks",
},
to: {
type: "string",
label: "To",
description: "To date. YYYY-MM-DD format, for example `2013-12-20`. The range can span at most 35 days, i.e. 5 weeks",
},
includeOrderData: {
type: "boolean",
label: "Include Order Data",
description: "Include order data in the response",
optional: true,
},
includeScheduleInformation: {
type: "boolean",
label: "Include Schedule Information",
description: "Include schedule information in the response",
optional: true,
},
afterTag: {
propDefinition: [
optimoroute,
"afterTag",
],
},
},
async run({ $ }) {
const response = await this.optimoroute.searchOrders({
$,
data: {
dateRange: {
from: this.from,
to: this.to,
},
includeOrderData: this.includeOrderData,
includeScheduleInformation: this.includeScheduleInformation,
after_tag: this.afterTag,
},
});
$.export("$summary", `Orders found: ${response?.orders?.length}`);
return response;
},
};
Loading
Loading