[PAY-3612] Add discovery endpoint for retrieving email data#10501
[PAY-3612] Add discovery endpoint for retrieving email data#10501faridsalau merged 5 commits intomainfrom
Conversation
|
raymondjacobson
left a comment
There was a problem hiding this comment.
I don't even know if we need a separate API endpoint for this - kind of a nice to have. The CSV comes from its own endpoint and you will probably want to re-use the same queries that you've written in this PR (and break them out into some src/queries/x.py file)
| decoded_id = decode_with_abort(id, ns) | ||
|
|
||
| db = get_db_read_replica() | ||
| with db.scoped_session() as session: |
There was a problem hiding this comment.
this is a really simple query and I think probably ok to be untested, but we typically do put queries inside src/queries as their own file so they can get their own tests, .e.g
|
|
||
|
|
||
| sales_download_parser = current_user_parser.copy() | ||
| sales_download_parser.add_argument( |
There was a problem hiding this comment.
added for backward compatibility sake while we transition to generating csv on FE
There was a problem hiding this comment.
probably good to keep this endpoint in general and just let our frontend be nifty. others may want this
| def format_sale_for_csv(result, seller_handle, seller_user_id, include_email=False): | ||
| """Format a sale result into a CSV-friendly dictionary format.""" | ||
| # Convert datetime to ISO format string | ||
| created_at = result.created_at.isoformat() if result.created_at else None |
There was a problem hiding this comment.
needed to convert for JSON serialization sakes. seems it was already an iso format though
|
|
||
|
|
||
| sales_download_parser = current_user_parser.copy() | ||
| sales_download_parser.add_argument( |
|
|
||
|
|
||
| sales_download_parser = current_user_parser.copy() | ||
| sales_download_parser.add_argument( |
There was a problem hiding this comment.
probably good to keep this endpoint in general and just let our frontend be nifty. others may want this
Description
This PR adds the necessary endpoint for accessing email data. This endpoints will be used to retrieve keys for decryption and to retrieve a complete list of emails that are associated with a specific userId
Sample response
{ "decryption_key": "ABC123XYZ456DefBase64EncodedKey==", "sales": [ { "title": "TEST", "link": "/reed/test", "purchased by": "name 40F0", "date": "2024-11-21T21:40:07.943031", "sale price": 2.0, "network fee": -0.2, "pay extra": 0.0, "total": 1.8, "country": null, "encrypted_email": "Base64EncodedEncryptedEmail1Content==" }, { "title": "BuyMePlease", "link": "/reed/buymeplease", "purchased by": "name E769", "date": "2024-11-21T21:40:02.697436", "sale price": 2.0, "network fee": -0.2, "pay extra": 0.0, "total": 1.8, "country": null, "encrypted_email": "Base64EncodedEncryptedEmail2Content==" } ] }How Has This Been Tested?
Locally via running
[/v1/users/<userId>/sales/download?json=true](http://audius-protocol-discovery-provider-1/v1/users/15YGgX/sales/download?json=true)I commented out the auth stuff in the endpoint to make testing easier locally
Sample queries for local encryption db population
Please describe the tests that you ran to verify your changes. Provide repro instructions & any configuration.