You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to implement an endpoint via Api Platform to retrieve results for a report that calculates gross sales for a date range given several criteria.
The results are represented by an array of sales gross indexed by year, month, and type of sale.
What is the best way to implement an endpoint to retrieve these results?
Here are the possible options I have thought of:
Create a GrossSalesReportData entity and mark it as an api resource. Disable collection operations. Only enable GET item operation and override its uriTemplate to something like /gross-sales-report-data. Add a dummy property/method to be marked as the identifier, the value wouldn't matter. The GrossSalesReportData would make full results accessible via a results property.
I don't like this option because it seems hacky.
Create a GrossSalesReportYearData entity and mark it as an api resource. Only enable GET item and collection operations. Mark year as the identifier. The GrossSalesReportYearData resource would make the results for the given year accessible via a monthData property.
I don't like this option because it seems pointless to have an IRI for this resource since the values will change based on the search criteria, which it could not be retrieved without.
Create the GrossSalesReportData resource mentioned in solution 1, but assign its identifier as a method that serializes all of the search criteria.
I don't like this option because depending on the report, the generated ID could get extremely long.
Just use a custom controller.
I don't like this because the docs discourage it. But.. it does seem like the easiest option.
I hope someone else has a better suggestion for me. Thanks for your time!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to implement an endpoint via Api Platform to retrieve results for a report that calculates gross sales for a date range given several criteria.
The results are represented by an array of sales gross indexed by year, month, and type of sale.
What is the best way to implement an endpoint to retrieve these results?
Here are the possible options I have thought of:
Create a
GrossSalesReportData
entity and mark it as an api resource. Disable collection operations. Only enable GET item operation and override itsuriTemplate
to something like/gross-sales-report-data
. Add a dummy property/method to be marked as the identifier, the value wouldn't matter. TheGrossSalesReportData
would make full results accessible via aresults
property.I don't like this option because it seems hacky.
Create a
GrossSalesReportYearData
entity and mark it as an api resource. Only enable GET item and collection operations. Markyear
as the identifier. TheGrossSalesReportYearData
resource would make the results for the given year accessible via amonthData
property.I don't like this option because it seems pointless to have an IRI for this resource since the values will change based on the search criteria, which it could not be retrieved without.
Create the
GrossSalesReportData
resource mentioned in solution 1, but assign its identifier as a method that serializes all of the search criteria.I don't like this option because depending on the report, the generated ID could get extremely long.
Just use a custom controller.
I don't like this because the docs discourage it. But.. it does seem like the easiest option.
I hope someone else has a better suggestion for me. Thanks for your time!
Beta Was this translation helpful? Give feedback.
All reactions