Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate the possibility of using REST API in project-based components #3615

Open
jsakalos opened this issue Oct 25, 2021 · 0 comments
Open
Labels
feature request forum Issues from forum

Comments

@jsakalos
Copy link

Using REST would mean that we need to effectively disable CrudManger that combines all changes into one or several requests but we would use REST way of doing it. For example, update operation in REST must be done on per-event basis:

PUT /rest/api/event/21
PUT /rest/api/event/22
PUT /rest/api/event/23
PUT /rest/api/event/24

to update 4 events with ids 21, 22, 21, 24. Data for events are in the body of requests. Similarly for DELETE

DELETE /rest/api/event/21
DELETE /rest/api/event/22
DELETE /rest/api/event/23
DELETE /rest/api/event/24

to delete events with ids 21, 22, 23 and 24.

Forum post

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


    {
        "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



    {
        "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)
@jsakalos jsakalos added feature request forum Issues from forum labels Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request forum Issues from forum
Projects
None yet
Development

No branches or pull requests

1 participant