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

Improve API (API 1.1) #421

Merged
merged 28 commits into from
Nov 29, 2024
Merged

Improve API (API 1.1) #421

merged 28 commits into from
Nov 29, 2024

Conversation

krestenlaust
Copy link
Member

@krestenlaust krestenlaust commented Apr 7, 2024

#420 aims to document the API. This PR addresses inconsistencies found during that documentation effort. Both in implementation and in the actual API.

It increments the API versioning to 1.1

The other endpoints use 'Invalid ID' to signify either missing or
invalid. This endpoint used to use 'Invalid Username' to signify that the
member does not exist, while the other's would've used 'Member not
found' for that.
krestenlaust added a commit that referenced this pull request Apr 8, 2024
There's an inconsistency in whether to call a member a user. Generally,
users are the ones with admin access, while members are the customers.
Even though it's a bool, I believe it's more appropriate to keep the
naming consistent with non-bool return types. Also, it still returns an
object.
I won't rename the actual endpoint because of backwards compatibility.
@krestenlaust
Copy link
Member Author

QR-endpoint apparently uses Stregdollars as opposed to Stregøre. I feel like streamlining this is too big a change.
The QR-endpoint also takes a member parameter, which will probably be renamed to username to streamline with other Member API-methods. (member will probably still be supported)

@krestenlaust
Copy link
Member Author


Changed response text on error to this format

More meaningful response in Active Products-endpoint, now returns {"1":
{"name": "Beer", "price": 600}}, instead of {"1": ["Beer", 600]}
@krestenlaust
Copy link
Member Author

Changed response format for Active Products-endpoint:
{"1": {"name": "Test ØL", "price": 100}, "2": {"name": "Kold Kaffe", "price": 200}, "3": {"name": "Fadøl", "price": 1500}, "13": {"name": "Fake ØL", "price": 300}, "32": {"name": "Kold Kaffe", "price": 200}, "34": {"name": "Fnugfald", "price": 0}}

Instead of {"1": ["Test ØL", 100], ...}

@krestenlaust
Copy link
Member Author

Changed format for Category_mapping endpoint output:
{"1": [], "2": [], "3": [], "13": [], "32": [[6, "kaffe"]], "33": [], "34": []} -> {"1": [], "2": [], "3": [], "13": [], "32": [{"category_id": 6, "category_name": "kaffe"}], "33": [], "34": []}

Much more verbose, but it's more like the other endpoints. Considering changing it to not return products which don't have any mapped categories

@krestenlaust
Copy link
Member Author

I've decided to leave the sales API as is

@krestenlaust krestenlaust marked this pull request as ready for review October 24, 2024 13:48
Copy link
Member

@Mast3rwaf1z Mast3rwaf1z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few small changes, but looks nice 👍

stregsystem/urls.py Outdated Show resolved Hide resolved
stregsystem/views.py Show resolved Hide resolved
stregsystem/views.py Show resolved Hide resolved
stregsystem/forms.py Outdated Show resolved Hide resolved
@krestenlaust krestenlaust marked this pull request as draft November 27, 2024 23:44
Copy link

codecov bot commented Nov 28, 2024

Codecov Report

Attention: Patch coverage is 29.16667% with 34 lines in your changes missing coverage. Please review.

Project coverage is 80.63%. Comparing base (124ba7f) to head (3042946).
Report is 5 commits behind head on next.

Files with missing lines Patch % Lines
stregsystem/views.py 25.00% 30 Missing ⚠️
stregsystem/utils.py 42.85% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next     #421      +/-   ##
==========================================
- Coverage   80.82%   80.63%   -0.20%     
==========================================
  Files          40       40              
  Lines        3760     3774      +14     
  Branches      476      480       +4     
==========================================
+ Hits         3039     3043       +4     
- Misses        665      675      +10     
  Partials       56       56              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@krestenlaust krestenlaust marked this pull request as ready for review November 28, 2024 14:35
Copy link
Member

@Mast3rwaf1z Mast3rwaf1z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

krestenlaust added a commit that referenced this pull request Nov 28, 2024
krestenlaust added a commit that referenced this pull request Nov 28, 2024
* Add initial OpenAPI spec

* Add endpoint categories

* Update info and add version

* Define API endpoint

* Finish Get Member Info-endpoint

* Finish Get Member Balance-endpoint

* Correct descriptions and add missing descriptions

* Update schemas to include member_id and username

* Finish Get Member ID-endpoint

* Bump version to fit version in #421

* Rename operation IDs to URL names

* Finish Get Member Active-endpoint

* Finish Get Member Sales-endpoint

* Rename product_price schema

* Finish Get Payment QR-Endpoint

* Add NamedProducts-Endpoint

* Add response for missing param, refactor res-value

* Rename stregdollar to stregoere

This was done to make it more clear, what the value actually is

* Refactor named_products schemas

* Add Active Products-endpoint

* Draft category mapping-Endpoint

* Finish Dump Category Mapping-endpoint

* Progress related to documenting Sale-API

* Expand Sale-API response

* Add Ballmer-peak measures

* Fix invalid response format

* Fix wrong keywords

* Reduce 200-example

* Make api/member-endpoint valid

* Make multiple api/member/*-endpoints valid

* fixup! Make multiple api/member/*-endpoints valid

* Make endpoints requiring room_id valid

* Make api/sale-endpoint valid

* Make 'api/member/payment/qr'-endpoint valid

* Remove old individual responses

* Make '/api/member/get_id'-endpoint valid

* Change description to be more intuitive

* Add request body to 'api/sale'-endpoint

* Made request-example coherent with response-example

* Add description to 'api/sale'-endpoint

* Add local endpoint as server

* Rename file to stregsystem.yaml

* Rename parameters to unique IDs

* Convert examples as schemas into examples

* Rename operationIds to fit changes in #421
@krestenlaust krestenlaust removed the request for review from AshesOfEther November 29, 2024 21:25
@krestenlaust krestenlaust merged commit a02bfdb into next Nov 29, 2024
3 checks passed
@krestenlaust krestenlaust deleted the improve-api branch November 29, 2024 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants