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

Reorganize API endpoints and deprecate current endpoints #2079

Closed
Tracked by #2041
Chartman123 opened this issue Apr 17, 2024 · 7 comments · Fixed by #2222
Closed
Tracked by #2041

Reorganize API endpoints and deprecate current endpoints #2079

Chartman123 opened this issue Apr 17, 2024 · 7 comments · Fixed by #2222
Assignees
Labels
3. to review Waiting for reviews discussion Being discussed enhancement New feature or request php PHP related ticket technical debt Technical issue
Milestone

Comments

@Chartman123
Copy link
Collaborator

Chartman123 commented Apr 17, 2024

Based on the comment by @susnux, here's the proposal on how to reorganize our API endpoints:

Forms endpoints

What Current New
Get forms GET /forms ✅ GET /forms[?type=owned]
Get shared forms GET /shared_forms ✅ GET /forms?type=shared
New form POST /form ✅ POST /forms
Get form GET /form/:id: ✅ GET /forms/:form-id:
Get partial form GET /partial_form/:hash: ❓ GET /forms/0?hash=:form-hash:
Clone form POST /form/clone/:id: ✅ POST /forms?fromId=:form-id:
Update form PATCH /form/update ✅ PATCH /forms/:form-id:
Transfer ownership POST /form/transfer ✅ - (just use patch/update)
Delete form DELETE /form/:id: ✅ DELETE /forms/:form-id:
Link file to form POST /form/link/:fileformat: ✅ - (just use patch/update)
Unlink file POST /form/unlink ✅ - (just use patch/update)

Questions endpoints

What Current New
Get questions - ✅ GET /forms/:form-id:/questions
Get question - ✅ GET /forms/:form-id:/questions/:question-id:
New question POST /question ✅ POST /forms/:form-id:/questions
Update question PATCH /question ✅ PATCH /forms/:form-id:/questions/:question-id:
Reorder questions PUT /question/reorder ✅ PATCH /forms/:form-id:/questions
Clone question POST /question/clone/:id: ❓ POST /forms/:form-id:/questions/:question-id:/clone
Delete question DELETE /question/:id: ✅ DELETE /forms/:form-id:/questions/:question-id:

Options endpoints

What Current New
Get options - ✅ GET /forms/:form-id:/questions/:question-id:/options
Get option - ✅ GET /forms/:form-id:/questions/:question-id:/options/:option-id:
New option(s) POST /option ✅ POST /forms/:form-id:/questions/:question-id:/options
Update option PATCH /option/update ✅ PATCH /forms/:form-id:/questions/:question-id:/options/:option-id:
Reorder options - ✅ PATCH /forms/:form-id:/questions/:question-id:/options
Clone option - ❓ POST /forms/:form-id:/questions/:question-id:/options/:option-id:/clone
Delete option DELETE /option/:id: ✅ DELETE /forms/:form-id:/questions/:question-id:/options/:option-id:

Sharing endpoints

What Current New
Get user's shares - ✅ GET /shares
Get shares of a form - ✅ GET /forms/:form-id:/shares
Get share - ✅ GET /forms/:form-id:/shares/:share-id:
New share POST /share ✅ POST /forms/:form-id:/shares
Update share PATCH /share/update ✅ PATCH /forms/:form-id:/shares/:share-id:
Delete share DELETE /share/:id: ✅ DELETE /forms/:form-id:/shares/:id:

Submission endpoints

What Current New
Get submissions GET `/submissions/:formhash: ✅ GET /forms/:form-id:/submissions
Get submission - ✅ GET /forms/:form-id:/submissions/:submission-id:
Download submissions GET /submissions/export/:formhash:?:fileformat: ✅ GET /forms/:form-id:/submissions?fileFormat=:file-format:
Export submissions to cloud POST /submissions/export ✅ POST /forms/:form-id:/submissions/export
New submission POST /submission/insert ✅ POST /forms/:form-id:/submissions
Update submission - ✅ PATCH /forms/:form-id:/submissions/:id:
Delete submissions DELETE /submissions/:formid: ✅ DELETE /forms/:form-id:/submissions
Delete submission DELETE /submission/:id: ✅ DELETE /forms/:form-id:/submissions/:submission-id:
Upload files POST /uploadFiles/:form-id:/:question-id: ✅ POST /forms/:form-id:/submissions/files/:question-id:
@Chartman123 Chartman123 mentioned this issue Apr 17, 2024
5 tasks
@Chartman123 Chartman123 added enhancement New feature or request php PHP related ticket discussion Being discussed 1. to develop Accepted and waiting to be taken care of technical debt Technical issue labels Apr 17, 2024
@Chartman123 Chartman123 added this to the 4.3 milestone Apr 17, 2024
@susnux
Copy link
Collaborator

susnux commented Apr 20, 2024

❓ GET /forms/:id: -> Parameter: partial = true

I do not think we need this, either we have permissions on that form -> get all information, or we do not have (e.g. just shared for submit) -> get only partial

@susnux
Copy link
Collaborator

susnux commented Apr 20, 2024

✅ POST /forms/:id:/clone

Or maybe same as creating a new and POST /forms and content: { id: 1234567 }.
I searched for similar APIs, sometimes it is also something like POST /forms?fromId=1234.

@susnux
Copy link
Collaborator

susnux commented Apr 20, 2024

But more important: Do we want logical nesting?
E.g.:

  • POST /forms/{form-id}/questions vs POST /questions
  • DELETE /forms/{form-id}/questions/{question-id} vs POST /questions/{question-id}

I personally think it makes sense for forms, as we always need to query the form to check access to question / option etc.

But I am not sure about shares, because they are also bound to forms, like:

  • POST /forms/{form-id}/shares makes sense to create a new share for that form

But we also need /shares to fetch shares for the current user. EXCEPT if we include that in our /forms endpoint.

@Chartman123
Copy link
Collaborator Author

But I am not sure about shares, because they are also bound to forms, like:

* POST `/forms/{form-id}/shares` makes sense to create a new share for that form

But we also need /shares to fetch shares for the current user. EXCEPT if we include that in our /forms endpoint.

What about having both? /shares for querying the user's shares and /forms/{form-id}/shares to manage the shares of a form?

@susnux
Copy link
Collaborator

susnux commented Jun 22, 2024

What about having both? /shares for querying the user's shares and /forms/{form-id}/shares to manage the shares of a form?

Would work for me :)

@Chartman123
Copy link
Collaborator Author

I've updated the tables with the proposed new routes :)

@Chartman123 Chartman123 mentioned this issue Jun 22, 2024
40 tasks
@Chartman123 Chartman123 self-assigned this Jun 23, 2024
@Chartman123 Chartman123 added 2. developing Work in progress and removed 1. to develop Accepted and waiting to be taken care of labels Jun 23, 2024
@Chartman123
Copy link
Collaborator Author

Do we want to split our API requests and deliver only the forms when you query /forms and only get the /forms/:form-id:/questions when you do another query? We could deliver the URI for the questions in the forms response then... But this would of course be a bigger change then...

@Chartman123 Chartman123 added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews discussion Being discussed enhancement New feature or request php PHP related ticket technical debt Technical issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants