Skip to content

Commit a8c49b1

Browse files
authored
Endpoints (#6)
1 parent b47e121 commit a8c49b1

File tree

127 files changed

+2095
-538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+2095
-538
lines changed

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "dimescheduler",
33
"description": "The Dime.Scheduler SDK",
4-
"version": "0.2.0",
4+
"version": "0.3.0",
55
"main": "./dist/index.ts",
66
"types": "./dist/index.d.ts",
77
"module": "./dist/esm/index.js",
@@ -12,8 +12,8 @@
1212
"default": "./dist/index.js"
1313
},
1414
"./models": {
15-
"types": "./dist/lib/models/index.d.ts",
16-
"default": "./dist/lib/models/index.js"
15+
"types": "./dist/models/index.d.ts",
16+
"default": "./dist/models/index.js"
1717
}
1818
},
1919
"files": [

samples/pingpong/bun.lockb

0 Bytes
Binary file not shown.

samples/pingpong/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
},
1515
"dependencies": {
1616
"commander": "^12.0.0",
17-
"dimescheduler": "^0.1.0"
17+
"dimescheduler": "^0.3.0"
1818
}
1919
}
-24 Bytes
Binary file not shown.

samples/update-resource-location/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13-
"dimescheduler": "^0.0.1-alpha.35",
13+
"dimescheduler": "^0.3.0",
1414
"mapbox-gl": "^3.3.0",
1515
"react": "^18.2.0",
1616
"react-dom": "^18.2.0",

src/client.ts

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import ActionUriEndpoint from './endpoints/actionuri';
2+
import AppointmentEndpoint from './endpoints/appointment';
3+
import AssignmentEndpoint from './endpoints/assignment';
4+
import CalendarEndpoint from './endpoints/calendar';
5+
import CaptionEndpoint from './endpoints/caption';
6+
import CategoryEndpoint from './endpoints/category';
7+
import ConnectorEndpoint from './endpoints/connector';
8+
import ContainerEndpoint from './endpoints/container';
9+
import FilterGroupEndpoint from './endpoints/filtergroup';
10+
import FilterValueEndpoint from './endpoints/filtervalue';
11+
import ImportEndpoint, { ImportResponse } from './endpoints/import';
12+
import JobEndpoint from './endpoints/job';
13+
import MessageEndpoint from './endpoints/message';
14+
import NotificationEndpoint from './endpoints/notification';
15+
import PinEndpoint from './endpoints/pin';
16+
import ResourceEndpoint from './endpoints/resource';
17+
import ResourceTypeEndpoint from './endpoints/resourcetype';
18+
import TaskEndpoint from './endpoints/task';
19+
import TimeMarkerEndpoint from './endpoints/timemarker';
20+
import UserEndpoint from './endpoints/user';
21+
import Environment from './environment';
22+
import IImportModel from './models/base/iimportmodel';
23+
import { Severity } from './models/constants/severity';
24+
25+
class DimeSchedulerClient {
26+
private importEndpoint: ImportEndpoint;
27+
private messages: MessageEndpoint;
28+
actionUris: ActionUriEndpoint;
29+
appointments: AppointmentEndpoint;
30+
captions: CaptionEndpoint;
31+
categories: CategoryEndpoint;
32+
connectors: ConnectorEndpoint;
33+
containers: ContainerEndpoint;
34+
filterGroups: FilterGroupEndpoint;
35+
filterValues: FilterValueEndpoint;
36+
jobs: JobEndpoint;
37+
notifications: NotificationEndpoint;
38+
pins: PinEndpoint;
39+
resources: ResourceEndpoint;
40+
tasks: TaskEndpoint;
41+
timeMarkers: TimeMarkerEndpoint;
42+
users: UserEndpoint;
43+
assignments: AssignmentEndpoint;
44+
resourceTypes: ResourceTypeEndpoint;
45+
calendars: CalendarEndpoint;
46+
47+
constructor(apiKey: string, env: Environment = Environment.Production) {
48+
this.importEndpoint = new ImportEndpoint(env, apiKey);
49+
this.messages = new MessageEndpoint(env, apiKey);
50+
this.actionUris = new ActionUriEndpoint(env, apiKey);
51+
this.appointments = new AppointmentEndpoint(env, apiKey);
52+
this.assignments = new AssignmentEndpoint(env, apiKey);
53+
this.captions = new CaptionEndpoint(env, apiKey);
54+
this.categories = new CategoryEndpoint(env, apiKey);
55+
this.connectors = new ConnectorEndpoint(env, apiKey);
56+
this.containers = new ContainerEndpoint(env, apiKey);
57+
this.filterGroups = new FilterGroupEndpoint(env, apiKey);
58+
this.filterValues = new FilterValueEndpoint(env, apiKey);
59+
this.jobs = new JobEndpoint(env, apiKey);
60+
this.notifications = new NotificationEndpoint(env, apiKey);
61+
this.pins = new PinEndpoint(env, apiKey);
62+
this.resources = new ResourceEndpoint(env, apiKey);
63+
this.tasks = new TaskEndpoint(env, apiKey);
64+
this.timeMarkers = new TimeMarkerEndpoint(env, apiKey);
65+
this.users = new UserEndpoint(env, apiKey);
66+
this.resourceTypes = new ResourceTypeEndpoint(env, apiKey);
67+
this.calendars = new CalendarEndpoint(env, apiKey);
68+
}
69+
70+
import(importable: IImportModel | Array<IImportModel>, append: boolean = true): Promise<ImportResponse> {
71+
return this.importEndpoint.processAsync(importable, append);
72+
}
73+
74+
sendMessage(text: string, severity: Severity, user?: string): Promise<void> {
75+
return this.messages.processAsync(text, severity, user);
76+
}
77+
}
78+
79+
export default DimeSchedulerClient;

src/constants/action.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
enum Action {
2+
Create,
3+
Update,
4+
Delete
5+
}
6+
7+
export default Action;

src/constants/routes.ts

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
const Routes = {
3+
ActionUri: "actionuri",
4+
Appointment: "appointment",
5+
AppointmentCategory: "appointmentCategory",
6+
AppointmentContainer: "appointmentContainer",
7+
AppointmentContent: "appointmentContent",
8+
AppointmentImportance: "appointmentImportance",
9+
AppointmentLocked: "appointmentLocked",
10+
AppointmentPlanningQuantity: "appointmentPlanningQuantity",
11+
AppointmentTimeMarker: "appointmentTimeMarker",
12+
AppointmentUri: "appointmentUri",
13+
Assignment: "assignment",
14+
Calendars: "calendar",
15+
Caption: "caption",
16+
Category: "categories",
17+
Connector: "connector",
18+
Container: "container",
19+
FilterGroup: "filterGroup",
20+
FilterValue: "filterValue",
21+
Import: "import",
22+
Job: "job",
23+
Message: "message",
24+
Notification: "notification",
25+
Pin: "pin",
26+
Resource: "resource",
27+
ResourceCalendar: "resourcecalendar",
28+
ResourceCapacity: "resourceCapacity",
29+
ResourceFilterValue: "resourceFilterValue",
30+
ResourceGpsTracking: "resourceGpsTracking",
31+
ResourceType: "resourceType",
32+
ResourceUri: "resourceuri",
33+
Task: "task",
34+
TaskContainer: "taskContainer",
35+
TaskFilterValue: "taskFilterValue",
36+
TaskLocked: "taskLocked",
37+
TaskUri: "taskUri",
38+
TimeMarker: "timeMarker",
39+
User: "user"
40+
}
41+
42+
export default Routes;

src/endpoints/actionuri.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Action from "../constants/action";
2+
import Routes from "../constants/routes";
3+
import Environment from "../environment";
4+
import { ActionUri } from "../models";
5+
import Endpoint from "./endpoint";
6+
7+
class ActionUriEndpoint extends Endpoint {
8+
9+
constructor(env: Environment, apiKey: string) {
10+
super(env, apiKey);
11+
}
12+
13+
create = (item: ActionUri) => super.execute(Routes.ActionUri, Action.Create, item);
14+
update = (item: ActionUri) => super.execute(Routes.ActionUri, Action.Update, item);
15+
delete = (item: ActionUri) => super.execute(Routes.ActionUri, Action.Delete, item);
16+
}
17+
18+
export default ActionUriEndpoint;

src/endpoints/appointment.ts

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import Action from "../constants/action";
2+
import Routes from "../constants/routes";
3+
import Environment from "../environment";
4+
import { Appointment, AppointmentCategory, AppointmentContainer, AppointmentContent, AppointmentImportance, AppointmentLocked, AppointmentPlanningQuantity, AppointmentTimeMarker, AppointmentUri } from "../models";
5+
import Endpoint from "./endpoint";
6+
7+
class AppointmentEndpoint extends Endpoint {
8+
9+
constructor(env: Environment, apiKey: string) {
10+
super(env, apiKey);
11+
}
12+
13+
create = (item: Appointment) => super.execute(Routes.Appointment, Action.Create, item);
14+
update = (item: Appointment) => super.execute(Routes.Appointment, Action.Update, item);
15+
delete = (item: Appointment) => super.execute(Routes.Appointment, Action.Delete, item);
16+
17+
createContainer = (item: AppointmentContainer) => super.execute(Routes.AppointmentContainer, Action.Create, item);
18+
updateContainer = (item: AppointmentContainer) => super.execute(Routes.AppointmentContainer, Action.Update, item);
19+
deleteContainer = (item: AppointmentContainer) => super.execute(Routes.AppointmentContainer, Action.Delete, item);
20+
21+
setCategory = (item: AppointmentCategory) => super.execute(Routes.AppointmentCategory, Action.Create, item);
22+
setContent = (item: AppointmentContent) => super.execute(Routes.AppointmentContent, Action.Create, item);
23+
setImportance = (item: AppointmentImportance) => super.execute(Routes.AppointmentImportance, Action.Create, item);
24+
setLocked = (item: AppointmentLocked) => super.execute(Routes.AppointmentLocked, Action.Create, item);
25+
setPlanningQuantity = (item: AppointmentPlanningQuantity) => super.execute(Routes.AppointmentPlanningQuantity, Action.Create, item);
26+
27+
createTimeMarker = (item: AppointmentTimeMarker) => super.execute(Routes.AppointmentTimeMarker, Action.Create, item);
28+
updateTimeMarker = (item: AppointmentTimeMarker) => super.execute(Routes.AppointmentTimeMarker, Action.Update, item);
29+
deleteTimeMarker = (item: AppointmentTimeMarker) => super.execute(Routes.AppointmentTimeMarker, Action.Delete, item);
30+
31+
createUri = (item: AppointmentUri) => super.execute(Routes.AppointmentUri, Action.Create, item);
32+
updateUri = (item: AppointmentUri) => super.execute(Routes.AppointmentUri, Action.Update, item);
33+
deleteUri = (item: AppointmentUri) => super.execute(Routes.AppointmentUri, Action.Delete, item);
34+
}
35+
36+
export default AppointmentEndpoint;

src/endpoints/assignment.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Action from "../constants/action";
2+
import Routes from "../constants/routes";
3+
import Environment from "../environment";
4+
import { Assignment } from "../models";
5+
import Endpoint from "./endpoint";
6+
7+
class AssignmentEndpoint extends Endpoint {
8+
9+
constructor(env: Environment, apiKey: string) {
10+
super(env, apiKey);
11+
}
12+
13+
create = (item: Assignment) => super.execute(Routes.Assignment, Action.Create, item);
14+
update = (item: Assignment) => super.execute(Routes.Assignment, Action.Update, item);
15+
delete = (item: Assignment) => super.execute(Routes.Assignment, Action.Delete, item);
16+
}
17+
18+
export default AssignmentEndpoint;

src/endpoints/calendar.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Routes from "../constants/routes";
2+
import Environment from "../environment";
3+
import { Calendar } from "../models";
4+
import Endpoint from "./endpoint";
5+
6+
class CalendarEndpoint extends Endpoint {
7+
8+
constructor(env: Environment, apiKey: string) {
9+
super(env, apiKey);
10+
}
11+
12+
getAll = () => super.get<Calendar>(Routes.Calendars);
13+
}
14+
15+
export default CalendarEndpoint;

src/endpoints/caption.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Action from "../constants/action";
2+
import Routes from "../constants/routes";
3+
import Environment from "../environment";
4+
import { Caption } from "../models";
5+
import Endpoint from "./endpoint";
6+
7+
class CaptionEndpoint extends Endpoint {
8+
9+
constructor(env: Environment, apiKey: string) {
10+
super(env, apiKey);
11+
}
12+
13+
create = (item: Caption) => super.execute(Routes.Caption, Action.Create, item);
14+
update = (item: Caption) => super.execute(Routes.Caption, Action.Update, item);
15+
delete = (item: Caption) => super.execute(Routes.Caption, Action.Delete, item);
16+
}
17+
18+
export default CaptionEndpoint;

src/endpoints/category.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Action from "../constants/action";
2+
import Routes from "../constants/routes";
3+
import Environment from "../environment";
4+
import { Category } from "../models";
5+
import Endpoint from "./endpoint";
6+
7+
class CategoryEndpoint extends Endpoint {
8+
9+
constructor(env: Environment, apiKey: string) {
10+
super(env, apiKey);
11+
}
12+
13+
getAll = () => super.get<Category>(Routes.Category);
14+
create = (item: Category) => super.execute(Routes.Category, Action.Create, item);
15+
update = (item: Category) => super.execute(Routes.Category, Action.Update, item);
16+
delete = (item: Category) => super.execute(Routes.Category, Action.Delete, item);
17+
}
18+
19+
export default CategoryEndpoint;

src/endpoints/connector.ts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import axios from "axios";
2+
import Routes from "../constants/routes";
3+
import Environment from "../environment";
4+
import { Connector } from "../models";
5+
import Endpoint from "./endpoint";
6+
7+
class ConnectorEndpoint extends Endpoint {
8+
9+
constructor(env: Environment, apiKey: string) {
10+
super(env, apiKey);
11+
}
12+
13+
create = async (item: Connector) => {
14+
const body = JSON.stringify(item);
15+
16+
const url = this.uri + Routes.Connector;
17+
const headers = {
18+
'X-API-KEY': this.apiKey,
19+
'Content-Type': 'application/json',
20+
'Accept': 'application/json'
21+
};
22+
23+
const createResponse = await axios.post(url, body, { headers: headers });
24+
return createResponse.data?.content;
25+
}
26+
}
27+
28+
export default ConnectorEndpoint;

src/endpoints/container.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Action from "../constants/action";
2+
import Routes from "../constants/routes";
3+
import Environment from "../environment";
4+
import { Container } from "../models";
5+
import Endpoint from "./endpoint";
6+
7+
class ContainerEndpoint extends Endpoint {
8+
9+
constructor(env: Environment, apiKey: string) {
10+
super(env, apiKey);
11+
}
12+
13+
getAll = () => super.get<Container>(Routes.Container);
14+
create = (item: Container) => super.execute(Routes.Container, Action.Create, item);
15+
update = (item: Container) => super.execute(Routes.Container, Action.Update, item);
16+
delete = (item: Container) => super.execute(Routes.Container, Action.Delete, item);
17+
}
18+
19+
export default ContainerEndpoint;

0 commit comments

Comments
 (0)