Add v2 returned letters endpoints#4905
Conversation
This endpoint returns the existing returned letters summaries for a service. This is the same data that is available in the service's dashboard, which is the number of returned letters for each report_date. For security purposes, this endpint is only accesible by a live API key.
This endpoint returns the same returned letters report displayed in a service's dashboard for a given report date.
Returned letter summaries are added periodically if at all, so it is more efficient to cache the data. TTL is set to 24hrs.
| result = [ | ||
| { | ||
| "notification_id": str(row["notification_id"]), | ||
| "reference": row["client_reference"], |
There was a problem hiding this comment.
This is different to what we send in the callback:
We should make a .serialize() method to guarantee the callback and report are using the same schema and then we only have to document it once
There was a problem hiding this comment.
The callback data is pre processed here
So both the report and the callback data present "reference" to the end user instead of "client_reference".
I explored the .serialize() option initially but the data is collated from a few other tables as well so it is not a perfect fit.
I am thinking of a follow up PR to tie the callback and endpoints data together.
There was a problem hiding this comment.
The user receives a field calledreference in both cases. The problem is that in one case the data is coming from the client_reference column in the database and in the other it’s coming from the reference column in the database. The former is the reference the user provides us, the latter is our internal reference.
There was a problem hiding this comment.
It looks like both fetch_returned_letters and fetch_returned_letter_callback_data_dao return the client_reference from the database:
However this shows that the current architecture is not very clear and I will look at refactoring what we have by implementing something similar to a .serialize() that will be used by the admin, callback and GET endpoint.
It will have to go on the back burner for now because of other priorities.
fa867b9 to
f8bf10f
Compare
Returned letter summaries are added periodically if at all, it is more efficient to cache the data. TTL is set to 24hrs
f8bf10f to
32837eb
Compare
No description provided.