Add Activepieces integration for workflow automation
- Add Activepieces fork with SmoothSchedule custom piece - Create integrations app with Activepieces service layer - Add embed token endpoint for iframe integration - Create Automations page with embedded workflow builder - Add sidebar visibility fix for embed mode - Add list inactive customers endpoint to Public API - Include SmoothSchedule triggers: event created/updated/cancelled - Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { createAction } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_me = createAction({
|
||||
name: 'get_me',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Account Details',
|
||||
description: 'Returns account information of the authenticated user via API token.',
|
||||
props: {},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/accounts/me/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const bulk_delete_clients = createAction({
|
||||
name: 'bulk_delete_clients',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Bulk Delete Clients',
|
||||
description: 'Delete multiple clients in a single call.',
|
||||
props: {
|
||||
ids: Property.Array({
|
||||
displayName: 'IDs',
|
||||
description: 'List of client IDs to delete.',
|
||||
required: true,
|
||||
properties: {
|
||||
id: Property.Number({ displayName: 'ID', required: true }),
|
||||
}
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const theIds = context.propsValue.ids;
|
||||
const body = (theIds as Array<{ id: number }>).map(client => client.id);
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.DELETE,
|
||||
url: `${API_BASE_URL}/v1/accounts/clients/`,
|
||||
body,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const create_client_property = createAction({
|
||||
name: 'create_client_property',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Create Client Custom Property',
|
||||
description: 'Create a new custom attribute for clients.',
|
||||
props: {
|
||||
label: Property.ShortText({
|
||||
displayName: 'label',
|
||||
description: 'Label of the new custom property.',
|
||||
required: true
|
||||
}),
|
||||
type: Property.ShortText({
|
||||
displayName: 'type',
|
||||
description: 'Property type (str, int, float or bool).',
|
||||
required: true
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const body = context.propsValue;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.POST,
|
||||
url: `${API_BASE_URL}/v1/planner/client-properties/`,
|
||||
body,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,54 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const create_clients = createAction({
|
||||
name: 'create_clients',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Create Clients',
|
||||
description: 'Create one or multiple new clients in the account.',
|
||||
props: {
|
||||
clients: Property.Array({
|
||||
displayName: 'Clients',
|
||||
description: 'Array of client objects to create.',
|
||||
required: true,
|
||||
properties: {
|
||||
key: Property.ShortText({ displayName: 'key', description: 'External identifier or unique key for the client.', required: false }),
|
||||
title: Property.ShortText({ displayName: 'title', description: 'Name or title of the client.', required: true }),
|
||||
address: Property.ShortText({ displayName: 'address', description: 'Client address.', required: false }),
|
||||
latitude: Property.Number({ displayName: 'latitude', description: 'Geographic latitude.', required: false }),
|
||||
longitude: Property.Number({ displayName: 'longitude', description: 'Geographic longitude.', required: false }),
|
||||
load: Property.Number({ displayName: 'load', description: 'Load associated (unit 1).', required: false }),
|
||||
load_2: Property.Number({ displayName: 'load_2', description: 'Load associated (unit 2).', required: false }),
|
||||
load_3: Property.Number({ displayName: 'load_3', description: 'Load associated (unit 3).', required: false }),
|
||||
window_start: Property.ShortText({ displayName: 'window_start', description: 'Preferred time window start (HH:MM:SS).', required: false }),
|
||||
window_end: Property.ShortText({ displayName: 'window_end', description: 'Preferred time window end.', required: false }),
|
||||
window_start_2: Property.ShortText({ displayName: 'window_start_2', description: 'Second time window start.', required: false }),
|
||||
window_end_2: Property.ShortText({ displayName: 'window_end_2', description: 'Second time window end.', required: false }),
|
||||
duration: Property.ShortText({ displayName: 'duration', description: 'Estimated visit duration (HH:MM:SS).', required: false }),
|
||||
contact_name: Property.ShortText({ displayName: 'contact_name', description: 'Client contact name.', required: false }),
|
||||
contact_phone: Property.ShortText({ displayName: 'contact_phone', description: 'Client contact phone.', required: false }),
|
||||
contact_email: Property.ShortText({ displayName: 'contact_email', description: 'Client contact email.', required: false }),
|
||||
notes: Property.ShortText({ displayName: 'notes', description: 'Additional notes about the client.', required: false }),
|
||||
priority_level: Property.Number({ displayName: 'priority_level', description: 'Client priority level.', required: false }),
|
||||
}
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const body = context.propsValue.clients;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.POST,
|
||||
url: `${API_BASE_URL}/v1/accounts/clients/`,
|
||||
body,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_clients = createAction({
|
||||
name: 'get_clients',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Clients',
|
||||
description: 'Retrieves the list of clients associated with the account. Can filter by client key.',
|
||||
props: {
|
||||
key: Property.ShortText({
|
||||
displayName: 'Client Key',
|
||||
description: 'Unique client key to filter results.',
|
||||
required: true
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
let queryString = '';
|
||||
if (context.propsValue.key) {
|
||||
queryString += (queryString ? '&' : '?') + 'key=' + context.propsValue.key;
|
||||
}
|
||||
const url = `${API_BASE_URL}/v1/accounts/clients/${queryString}`;
|
||||
console.log(url);
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { createAction } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_fleets = createAction({
|
||||
name: 'get_fleets',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Fleets',
|
||||
description: 'Retrieve the list of fleets available in the account.',
|
||||
props: {},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/fleets/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { createAction } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_observations = createAction({
|
||||
name: 'get_observations',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Observations',
|
||||
description: 'Retrieve the list of observations available in the account.',
|
||||
props: {},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/routes/observations/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { createAction } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_sellers = createAction({
|
||||
name: 'get_sellers',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Sellers',
|
||||
description: 'Retrieve the list of sellers available in the account.',
|
||||
props: {},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/sellers/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { createAction } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_skills = createAction({
|
||||
name: 'get_skills',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Skills',
|
||||
description: 'Retrieve the list of skills available in the account.',
|
||||
props: {},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/routes/skills/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { createAction } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_tags = createAction({
|
||||
name: 'get_tags',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Tags',
|
||||
description: 'Retrieve the list of tags available in the account.',
|
||||
props: {},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/routes/tags/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { createAction } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_zones = createAction({
|
||||
name: 'get_zones',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Zones',
|
||||
description: 'Retrieve the list of zones available in the account.',
|
||||
props: {},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/zones/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const create_plan = createAction({
|
||||
name: 'create_plan',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Create an empty plan',
|
||||
description: 'Create an empty plan (execution) without routes (reserve a planning day).',
|
||||
props: {
|
||||
name: Property.ShortText({ displayName: 'name', description: 'Plan name.', required: true }),
|
||||
start_date: Property.ShortText({ displayName: 'start_date', description: 'Start date (YYYY-MM-DD).', required: true }),
|
||||
end_date: Property.ShortText({ displayName: 'end_date', description: 'End date (YYYY-MM-DD).', required: true }),
|
||||
},
|
||||
async run(context) {
|
||||
const body = context.propsValue;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.POST,
|
||||
url: `${API_BASE_URL}/v1/plans/create-plan/`,
|
||||
body,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_plan_vehicles = createAction({
|
||||
name: 'get_plan_vehicles',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get vehicles with routes on date',
|
||||
description: 'Returns the vehicles that have planned routes on the indicated date.',
|
||||
props: {
|
||||
planned_date: Property.ShortText({ displayName: 'planned_date', description: 'Planned date (YYYY-MM-DD).', required: true }),
|
||||
},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/plans/${context.propsValue.planned_date}/vehicles/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_plans = createAction({
|
||||
name: 'get_plans',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Plans',
|
||||
description: 'Retrieve the list of saved routing plans (executions).',
|
||||
props: {date: Property.ShortText({ displayName: 'date', description: 'Planned date (YYYY-MM-DD).', required: true })},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/plans/${context.propsValue.date}/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,42 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
|
||||
export const create_route = createAction({
|
||||
name: 'create_route',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Create Route',
|
||||
description: 'Create a new route manually by assigning vehicle, driver and date.',
|
||||
props: {
|
||||
vehicle: Property.Number({ displayName: 'vehicle', description: 'Vehicle ID for the route.', required: true }),
|
||||
driver: Property.Number({ displayName: 'driver', description: 'Driver ID for the route.', required: true }),
|
||||
planned_date: Property.ShortText({ displayName: 'planned_date', description: 'Planned route date (YYYY-MM-DD).', required: true }),
|
||||
estimated_time_start: Property.ShortText({ displayName: 'estimated_time_start', description: 'Estimated start time (HH:MM:SS).', required: true }),
|
||||
estimated_time_end: Property.ShortText({ displayName: 'estimated_time_end', description: 'Estimated end time (HH:MM:SS).', required: true }),
|
||||
location_start_address: Property.ShortText({ displayName: 'location_start_address', description: 'Route start address.', required: true }),
|
||||
location_start_latitude: Property.ShortText({ displayName: 'location_start_latitude', description: 'Route start latitude.', required: true }),
|
||||
location_start_longitude: Property.ShortText({ displayName: 'location_start_longitude', description: 'Route start longitude.', required: true }),
|
||||
location_end_address: Property.ShortText({ displayName: 'location_end_address', description: 'Route end address.', required: true }),
|
||||
location_end_latitude: Property.ShortText({ displayName: 'location_end_latitude', description: 'Route end latitude.', required: true }),
|
||||
location_end_longitude: Property.ShortText({ displayName: 'location_end_longitude', description: 'Route end longitude.', required: true }),
|
||||
plan: Property.ShortText({ displayName: 'plan', description: 'Plan (execution) ID to associate the route (UUID).', required: true }),
|
||||
},
|
||||
async run(context) {
|
||||
const body = context.propsValue;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.POST,
|
||||
url: `${API_BASE_URL}/v1/routes/routes/`,
|
||||
body,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const delete_route = createAction({
|
||||
name: 'delete_route',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Delete Route',
|
||||
description: 'Delete a route by its ID.',
|
||||
props: {
|
||||
route_id: Property.ShortText({
|
||||
displayName: 'route_id',
|
||||
description: 'Route ID to delete (UUID).',
|
||||
required: true
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/routes/routes/${context.propsValue.route_id}/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.DELETE,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_route = createAction({
|
||||
name: 'get_route',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Route',
|
||||
description: 'Retrieve details of a specific route.',
|
||||
props: {
|
||||
route_id: Property.ShortText({
|
||||
displayName: 'route_id',
|
||||
description: 'Route ID (UUID).',
|
||||
required: true
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/routes/routes/${context.propsValue.route_id}/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_routes = createAction({
|
||||
name: 'get_routes',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Routes',
|
||||
description: 'Retrieve the list of existing routes.',
|
||||
props: {planned_date: Property.ShortText({ displayName: 'planned_date', description: 'Visit planned date (YYYY-MM-DD).', required: true })},
|
||||
async run(context) {
|
||||
const body = context.propsValue;
|
||||
const url = `${API_BASE_URL}/v1/routes/routes/?planned_date=${body.planned_date}`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url: url,
|
||||
body,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const create_users = createAction({
|
||||
name: 'create_users',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Create User',
|
||||
description: 'Create new user/driver in the account.',
|
||||
props: {
|
||||
username: Property.ShortText({ displayName: 'username', description: 'Nombre de usuario (login).', required: true }),
|
||||
name: Property.ShortText({ displayName: 'name', description: 'Nombre completo del usuario.', required: false }),
|
||||
phone: Property.ShortText({ displayName: 'phone', description: 'Número de teléfono.', required: false }),
|
||||
email: Property.ShortText({ displayName: 'email', description: 'Correo electrónico.', required: false }),
|
||||
is_admin: Property.Checkbox({ displayName: 'is_admin', description: 'Whether the user is an administrator.', required: false, defaultValue: false }),
|
||||
password: Property.ShortText({ displayName: 'password', description: 'User password.', required: true }),
|
||||
is_driver: Property.Checkbox({ displayName: 'is_driver', description: 'Whether the user is a driver.', required: true, defaultValue: false }),
|
||||
is_router_jr: Property.Checkbox({ displayName: 'is_router_jr', description: 'Whether the user is a router junior.', required: false, defaultValue: false }),
|
||||
is_router: Property.Checkbox({ displayName: 'is_router', description: 'Whether the user is a router.', required: false, defaultValue: false }),
|
||||
is_monitor: Property.Checkbox({ displayName: 'is_monitor', description: 'Whether the user is a monitor.', required: false, defaultValue: false }),
|
||||
is_coordinator: Property.Checkbox({ displayName: 'is_coordinator', description: 'Whether the user is a coordinator.', required: false, defaultValue: false }),
|
||||
},
|
||||
async run(context) {
|
||||
const body = context.propsValue;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.POST,
|
||||
url: `${API_BASE_URL}/v1/accounts/drivers/`,
|
||||
body,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { createAction } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_drivers = createAction({
|
||||
name: 'get_drivers',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Drivers',
|
||||
description: 'Retrieve the list of drivers registered in the account.',
|
||||
props: {},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/accounts/drivers/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_user = createAction({
|
||||
name: 'get_user',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get User',
|
||||
description: 'Retrieve information of a specific user by ID.',
|
||||
props: {
|
||||
user_id: Property.Number({
|
||||
displayName: 'user_id',
|
||||
description: 'User ID.',
|
||||
required: true
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/accounts/drivers/${context.propsValue.user_id}/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const update_user = createAction({
|
||||
name: 'update_user',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Update User',
|
||||
description: 'Update information of an existing user.',
|
||||
props: {
|
||||
user_id: Property.Number({ displayName: 'user_id', description: 'User ID to update.', required: true }),
|
||||
username: Property.ShortText({ displayName: 'username', description: 'Username (login).', required: true }),
|
||||
name: Property.ShortText({ displayName: 'name', description: 'Full name of the user.', required: true }),
|
||||
phone: Property.ShortText({ displayName: 'phone', description: 'User phone number.', required: false }),
|
||||
email: Property.ShortText({ displayName: 'email', description: 'User email address.', required: false }),
|
||||
is_admin: Property.Checkbox({ displayName: 'is_admin', description: 'Whether the user is an administrator.', required: false, defaultValue: false }),
|
||||
password: Property.ShortText({ displayName: 'password', description: 'User password.', required: false }),
|
||||
is_driver: Property.Checkbox({ displayName: 'is_driver', description: 'Whether the user is a driver.', required: false, defaultValue: false }),
|
||||
is_router_jr: Property.Checkbox({ displayName: 'is_router_jr', description: 'Whether the user is a router junior.', required: false, defaultValue: false }),
|
||||
is_router: Property.Checkbox({ displayName: 'is_router', description: 'Whether the user is a router.', required: false, defaultValue: false }),
|
||||
is_monitor: Property.Checkbox({ displayName: 'is_monitor', description: 'Whether the user is a monitor.', required: false, defaultValue: false }),
|
||||
is_coordinator: Property.Checkbox({ displayName: 'is_coordinator', description: 'Whether the user is a coordinator.', required: false, defaultValue: false }),
|
||||
},
|
||||
async run(context) {
|
||||
const { user_id, ...body } = context.propsValue;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.PUT,
|
||||
url: `${API_BASE_URL}/v1/accounts/drivers/${user_id}/`,
|
||||
body,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,55 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const create_vehicle = createAction({
|
||||
name: 'create_vehicle',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Create Vehicle',
|
||||
description: 'Register a new vehicle in the account.',
|
||||
props: {
|
||||
name: Property.ShortText({ displayName: 'name', description: 'The name of the vehicle.', required: true }),
|
||||
capacity: Property.Number({ displayName: 'capacity', description: 'The maximum capacity of the vehicle.', required: true }),
|
||||
default_driver: Property.ShortText({ displayName: 'default_driver', description: 'The assigned driver ID or null if not assigned.', required: false }),
|
||||
location_start_address: Property.ShortText({ displayName: 'location_start_address', description: 'The starting address of the vehicle.', required: true }),
|
||||
location_start_latitude: Property.Number({ displayName: 'location_start_latitude', description: 'The latitude of the starting location.', required: true }),
|
||||
location_start_longitude: Property.Number({ displayName: 'location_start_longitude', description: 'The longitude of the starting location.', required: true }),
|
||||
location_end_address: Property.ShortText({ displayName: 'location_end_address', description: 'The ending address of the vehicle.', required: true }),
|
||||
location_end_latitude: Property.Number({ displayName: 'location_end_latitude', description: 'The latitude of the ending location.', required: true }),
|
||||
location_end_longitude: Property.Number({ displayName: 'location_end_longitude', description: 'The longitude of the ending location.', required: true }),
|
||||
skills: Property.Json({ displayName: 'skills', description: 'a list of skill IDs (JSON format [1, 2]).', required: false }),
|
||||
capacity2: Property.ShortText({ displayName: 'capacity2', description: 'Secondary vehicle capacity.', required: false }),
|
||||
capacity3: Property.ShortText({ displayName: 'capacity3', description: 'Third vehicle capacity.', required: false }),
|
||||
cost: Property.ShortText({ displayName: 'cost', description: 'Operational cost of the vehicle.', required: false }),
|
||||
shift_start: Property.ShortText({ displayName: 'shift_start', description: 'Start time of the vehicle shift.', required: false }),
|
||||
shift_end: Property.ShortText({ displayName: 'shift_end', description: 'End time of the vehicle shift.', required: false }),
|
||||
reference_id: Property.ShortText({ displayName: 'reference_id', description: 'External reference ID of the vehicle.', required: false }),
|
||||
license_plate: Property.ShortText({ displayName: 'license_plate', description: 'License plate or registration of the vehicle.', required: false }),
|
||||
min_load: Property.Number({ displayName: 'min_load', description: 'Minimum load (unit 1) required to dispatch.', required: false }),
|
||||
min_load_2: Property.Number({ displayName: 'min_load_2', description: 'Minimum load (unit 2) required.', required: false }),
|
||||
min_load_3: Property.Number({ displayName: 'min_load_3', description: 'Minimum load (unit 3) required.', required: false }),
|
||||
max_visit: Property.Number({ displayName: 'max_visit', description: 'Maximum number of visits that the vehicle can perform.', required: false }),
|
||||
max_time: Property.Number({ displayName: 'max_time', description: 'Maximum duration of route (in seconds).', required: false }),
|
||||
rest_time_start: Property.ShortText({ displayName: 'rest_time_start', description: 'Start time of rest.', required: false }),
|
||||
rest_time_end: Property.ShortText({ displayName: 'rest_time_end', description: 'End time of rest.', required: false }),
|
||||
rest_time_duration: Property.ShortText({ displayName: 'rest_time_duration', description: 'Duration of rest.', required: false }),
|
||||
|
||||
},
|
||||
async run(context) {
|
||||
const body = context.propsValue;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.POST,
|
||||
url: `${API_BASE_URL}/v1/routes/vehicles/`,
|
||||
body,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const delete_vehicle = createAction({
|
||||
name: 'delete_vehicle',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Delete Vehicle',
|
||||
description: 'Delete a vehicle by its ID.',
|
||||
props: {
|
||||
vehicle_id: Property.Number({
|
||||
displayName: 'vehicle_id',
|
||||
description: 'Vehicle ID to delete.',
|
||||
required: true
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/routes/vehicles/${context.propsValue.vehicle_id}/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.DELETE,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_vehicle = createAction({
|
||||
name: 'get_vehicle',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Vehicle',
|
||||
description: 'Retrieve information of a specific vehicle.',
|
||||
props: {
|
||||
vehicle_id: Property.Number({
|
||||
displayName: 'vehicle_id',
|
||||
description: 'Vehicle ID.',
|
||||
required: true
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/routes/vehicles/${context.propsValue.vehicle_id}/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { createAction } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_vehicles = createAction({
|
||||
name: 'get_vehicles',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Vehicles',
|
||||
description: 'Retrieve the list of vehicles registered in the account.',
|
||||
props: {},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/routes/vehicles/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const add_visit_items = createAction({
|
||||
name: 'add_visit_items',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Add Visit Items',
|
||||
description: 'Add items to an existing visit.',
|
||||
props: {
|
||||
visit_id: Property.Number({ displayName: 'visit_id', description: 'ID of the visit to add items to.', required: true }),
|
||||
items: Property.Array({
|
||||
displayName: 'items',
|
||||
description: 'Array of items to add to the visit.',
|
||||
required: true,
|
||||
properties: {
|
||||
title: Property.ShortText({ displayName: 'title', description: 'Name or description of the item.', required: true }),
|
||||
load: Property.Number({ displayName: 'load', description: 'Unit of load that the item occupies.', required: false }),
|
||||
load_2: Property.Number({ displayName: 'load_2', description: 'Second load unit of the item.', required: false }),
|
||||
load_3: Property.Number({ displayName: 'load_3', description: 'Third load unit of the item.', required: false }),
|
||||
reference: Property.ShortText({ displayName: 'reference', description: 'Internal reference of the item.', required: false }),
|
||||
notes: Property.ShortText({ displayName: 'notes', description: 'Additional notes about the item.', required: false }),
|
||||
quantity_planned: Property.Number({ displayName: 'quantity_planned', description: 'Planned quantity of the item.', required: false }),
|
||||
quantity_delivered: Property.Number({ displayName: 'quantity_delivered', description: 'Delivered quantity of the item (if applicable).', required: false }),
|
||||
}
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const { visit_id, ...rest } = context.propsValue;
|
||||
const body = rest.items;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.POST,
|
||||
url: `${API_BASE_URL}/v1/routes/visits/${visit_id}/items/`,
|
||||
body,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const create_visits = createAction({
|
||||
name: 'create_visits',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Create Visits',
|
||||
description: 'Create visits. Multiple visits can be created in a single request.',
|
||||
props: {
|
||||
visits: Property.Array({
|
||||
displayName: 'visits',
|
||||
description: 'Array of visit objects to create.',
|
||||
required: true,
|
||||
properties: {
|
||||
title: Property.ShortText({ displayName: 'title', description: "String to identify the delivery. Usually company or person's name.", required: true }),
|
||||
address: Property.ShortText({ displayName: 'address', description: 'Address text. Best practice is to use Googlemaps format.', required: true }),
|
||||
planned_date: Property.ShortText({ displayName: 'planned_date', description: 'Date when the visit will be delivered. (YYYY-MM-DD)', required: true }),
|
||||
latitude: Property.Number({ displayName: 'latitude', description: "Visit's latitude location.", required: false }),
|
||||
longitude: Property.Number({ displayName: 'longitude', description: "Visit's longitude location.", required: false }),
|
||||
load: Property.Number({ displayName: 'load', description: 'Space of the truck that visit uses.', required: true, defaultValue: 1 }),
|
||||
load_2: Property.Number({ displayName: 'load_2', description: 'Space of the truck that visit uses.', required: false }),
|
||||
load_3: Property.Number({ displayName: 'load_3', description: 'Space of the truck that visit uses.', required: false }),
|
||||
window_start: Property.ShortText({ displayName: 'window_start', description: 'Initial Hour when the visit can be visit (HH:MM:SS).', required: false }),
|
||||
window_end: Property.ShortText({ displayName: 'window_end', description: 'Final Hour when the visit can be visit (HH:MM:SS).', required: false }),
|
||||
window_start_2: Property.ShortText({ displayName: 'window_start_2', description: 'Initial Hour when the visit can be visit (HH:MM:SS).', required: false }),
|
||||
window_end_2: Property.ShortText({ displayName: 'window_end_2', description: 'Final Hour when the visit can be visit (HH:MM:SS).', required: false }),
|
||||
duration: Property.ShortText({ displayName: 'duration', description: 'Time spent in the delivery (HH:mm:ss).', required: false }),
|
||||
order: Property.Number({ displayName: 'order', description: 'Visit order when the visit already belongs to a delivery route.', required: false }),
|
||||
skills_required: Property.Json({ displayName: 'skills_required', description: 'A list of skills or capabilities required (JSON format [1, 2]).', required: false }),
|
||||
skills_optional: Property.Json({ displayName: 'skills_optional', description: 'A list of skills or capabilities optionals (JSON format [1, 2]).', required: false }),
|
||||
tags: Property.Json({ displayName: 'tags', description: 'A list of tags (JSON format [1, 2]).', required: false }),
|
||||
contact_name: Property.ShortText({ displayName: 'contact_name', description: 'Name of who will receive the delivery.', required: false }),
|
||||
contact_phone: Property.ShortText({ displayName: 'contact_phone', description: 'Phone of who will receive the delivery.', required: false }),
|
||||
contact_email: Property.ShortText({ displayName: 'contact_email', description: 'E-mail of who will receive the delivery.', required: false }),
|
||||
reference: Property.ShortText({ displayName: 'reference', description: 'Reference or internal identifier of the company. Example: Invoice or order number.', required: false }),
|
||||
notes: Property.ShortText({ displayName: 'notes', description: 'Information to help the driver.', required: false }),
|
||||
priority_level: Property.Number({ displayName: 'priority_level', description: 'If the visit is more important than others. It goes from 1 to 5.', required: false }),
|
||||
visit_type: Property.ShortText({ displayName: 'visit_type', description: 'Visit type associated with the visit.', required: false }),
|
||||
fleet: Property.Number({ displayName: 'fleet', description: 'Fleet ID.', required: false }),
|
||||
}
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const body = context.propsValue.visits;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.POST,
|
||||
url: `${API_BASE_URL}/v1/routes/visits/`,
|
||||
body,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const delete_visit = createAction({
|
||||
name: 'delete_visit',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Delete Visit',
|
||||
description: 'Delete a visit by its ID.',
|
||||
props: {
|
||||
visit_id: Property.Number({
|
||||
displayName: 'visit_id',
|
||||
description: 'ID of the visit to delete.',
|
||||
required: true
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/routes/visits/${context.propsValue.visit_id}/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.DELETE,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_visit_detail = createAction({
|
||||
name: 'get_visit_detail',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Visit Detail',
|
||||
description: 'Get detailed information about a specific visit.',
|
||||
props: {
|
||||
visit_id: Property.Number({
|
||||
displayName: 'visit_id',
|
||||
description: 'ID of the visit to get details for.',
|
||||
required: true
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/plans/visits/${context.propsValue.visit_id}/detail/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_visit = createAction({
|
||||
name: 'get_visit',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Visit',
|
||||
description: 'Retrieve details of a specific visit by ID.',
|
||||
props: {
|
||||
visit_id: Property.Number({
|
||||
displayName: 'visit_id',
|
||||
description: 'Visit ID.',
|
||||
required: true
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const url = `${API_BASE_URL}/v1/routes/visits/${context.propsValue.visit_id}/`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const get_visits = createAction({
|
||||
name: 'get_visits',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Get Visits',
|
||||
description: 'Retrieve all registered visits. Can be filtered by planned visit date.',
|
||||
props: {
|
||||
planned_date: Property.ShortText({
|
||||
displayName: 'planned_date',
|
||||
description: 'Filter visits by planned date (YYYY-MM-DD format).',
|
||||
required: true
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
let queryString = '';
|
||||
if (context.propsValue.planned_date) {
|
||||
queryString += (queryString ? '&' : '?') + 'planned_date=' + context.propsValue.planned_date;
|
||||
}
|
||||
const url = `${API_BASE_URL}/v1/routes/visits/${queryString}`;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.GET,
|
||||
url,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const update_visit_partial = createAction({
|
||||
name: 'update_visit_partial',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Update Visit (Partial)',
|
||||
description: 'Partially update fields of an existing visit.',
|
||||
props: {
|
||||
visit_id: Property.Number({ displayName: 'visit_id', description: 'ID of the visit to update.', required: true }),
|
||||
title: Property.ShortText({ displayName: 'title', description: 'Visit title (if you want to change it).', required: false }),
|
||||
address: Property.ShortText({ displayName: 'address', description: 'Visit address (if you want to change it).', required: false }),
|
||||
load: Property.Number({ displayName: 'load', description: 'Visit load (main unit).', required: false }),
|
||||
load_2: Property.Number({ displayName: 'load_2', description: 'Visit load (unit 2).', required: false }),
|
||||
load_3: Property.Number({ displayName: 'load_3', description: 'Visit load (unit 3).', required: false }),
|
||||
duration: Property.ShortText({ displayName: 'duration', description: 'Visit duration (HH:MM:SS).', required: false }),
|
||||
contact_name: Property.ShortText({ displayName: 'contact_name', description: 'Visit contact name.', required: false }),
|
||||
contact_phone: Property.ShortText({ displayName: 'contact_phone', description: 'Visit contact phone.', required: false }),
|
||||
notes: Property.ShortText({ displayName: 'notes', description: 'Visit notes.', required: false }),
|
||||
planned_date: Property.ShortText({ displayName: 'planned_date', description: 'Visit planned date (YYYY-MM-DD).', required: false }),
|
||||
},
|
||||
async run(context) {
|
||||
const { visit_id, ...body } = context.propsValue;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.PATCH,
|
||||
url: `${API_BASE_URL}/v1/routes/visits/${visit_id}/`,
|
||||
body,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,42 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { simplirouteAuth } from '../../../index';
|
||||
import { API_BASE_URL, commonHeaders } from '../../common/constants';
|
||||
|
||||
export const update_visit = createAction({
|
||||
name: 'update_visit',
|
||||
auth: simplirouteAuth,
|
||||
displayName: 'Update Visit (Complete)',
|
||||
description: 'Completely update an existing visit with all fields.',
|
||||
props: {
|
||||
visit_id: Property.Number({ displayName: 'visit_id', description: 'ID of the visit to update.', required: true }),
|
||||
title: Property.ShortText({ displayName: 'title', description: 'Visit title.', required: true }),
|
||||
address: Property.ShortText({ displayName: 'address', description: 'Visit address.', required: true }),
|
||||
latitude: Property.Number({ displayName: 'latitude', description: 'Visit latitude.', required: false }),
|
||||
longitude: Property.Number({ displayName: 'longitude', description: 'Visit longitude.', required: false }),
|
||||
load: Property.Number({ displayName: 'load', description: 'Visit load (main unit).', required: false }),
|
||||
load_2: Property.Number({ displayName: 'load_2', description: 'Visit load (unit 2).', required: false }),
|
||||
load_3: Property.Number({ displayName: 'load_3', description: 'Visit load (unit 3).', required: false }),
|
||||
duration: Property.ShortText({ displayName: 'duration', description: 'Visit duration (HH:MM:SS).', required: false }),
|
||||
contact_name: Property.ShortText({ displayName: 'contact_name', description: 'Visit contact name.', required: false }),
|
||||
contact_phone: Property.ShortText({ displayName: 'contact_phone', description: 'Visit contact phone.', required: false }),
|
||||
notes: Property.ShortText({ displayName: 'notes', description: 'Visit notes.', required: false }),
|
||||
planned_date: Property.ShortText({ displayName: 'planned_date', description: 'Visit planned date (YYYY-MM-DD).', required: true }),
|
||||
},
|
||||
async run(context) {
|
||||
const { visit_id, ...body } = context.propsValue;
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.PUT,
|
||||
url: `${API_BASE_URL}/v1/routes/visits/${visit_id}/`,
|
||||
body,
|
||||
headers: {
|
||||
...commonHeaders,
|
||||
'Authorization': `Token ${context.auth.secret_text}`
|
||||
}
|
||||
});
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.body
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
export const API_BASE_URL = 'https://api.simpliroute.com';
|
||||
|
||||
export const commonHeaders = {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
};
|
||||
Reference in New Issue
Block a user