Dear Bryntum team,
I am experimenting with the Scheduler Pro trial. My project needs to access a specific remote REST API service for events, resources and other data.
The REST API has its own structure, naming, request and response format. For instance, there is no 'success' entry, the data part is named 'records', the fields returned have names as set in the DB (not the default startDate/endDate, etc). See below for a brief description of the API.
So differences exist in many places from the structure of the requests/responses and naming to the way parameters/values are passed in both ways and so on. I assume that I have to use CrudManager with a lot of customization, so please point me to an example that is the most complete and relevant to my case. Any other advice would be welcome.
UPDATE: I was able to load data by customizing eventStore and resourceStore. The problem now is how to implement insert, update, delete given the specificities of the REST API (below).
Thanks in advance
Andreas Sakellariou
Description of the API
The same mechanism is used for any DB table. Filtering and other capabilities do exist but are not described below.
Let us assume that we have to schedule room usage by employees. To load all records from the db table 'events' the endpoint would be
GET /records/events
and the response (notice the array):
{
"records":[
{
"ID": 1,
"StartDT": "2018-03-05T20:12:56Z", // start of event
"FinishDT": "2018-03-05T20:12:56Z", // end of event
"EmployeeID": 121, //foreign key -Employees table
"RoomID": 1, // resource id
"EmployeeName: "Smith John",
.....
(other fields of various data types}
},
{
"ID": 2,
"StartDT": "2018-04-05T20:12:56Z", // start of event
"FinishDT": "2018-04-05T20:12:56Z", // end of event
"EmployeeID": 122, //foreign key -Employees table
"RoomID": 2, // resource id
"EmployeeName: "Smith Helen",
.....
(other fields of various data types}
}
]
}
To insert a record:
POST /records/events
with params passed in the body
{
"StartDT": "2018-04-05T10:13:33Z", // start of event
"FinishDT": "2018-04-07T00:10:12Z", // end of event
"EmployeeID": 133, //foreign key -Employees table
"RoomID": 2, // resource id
......
}
ID is not passed since it is auto-incremented by the RDBMS. The response is the number of the new ID.
To read a specific record ie with ID=221 the request would be
GET /records/events/221
with response (a single Json object):
{
"ID": 221,
"StartDT": "2019-03-05T20:12:56Z", // start of event
"FinishDT": "2019-03-05T20:12:56Z", // end of event
"RoomID": 3, // resource id
"EmployeeID": 125, //foreign key -Employees table
"EmployeeName: "Allen Mark",
.....
(other fields of various data types}
}
To update a specific record ie with ID=221 the endpoint would be
PUT /records/events/221
and the field values that are to be updated passed in the body
{
"StartDT": "2019-03-05T20:12:56Z", // start of event
"FinishDT": "2019-03-05T22:15:56Z", // end of event
"RoomID": 3, // resource id
"EmployeeID": 144, //foreign key -Employees table
.....
(other fields that need to be updated}
}
The number of rows affected is returned as the response (ie 1)