Coverage for functions \ flipdare \ util \ public \ public_url_factory.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-05-08 12:22 +1000

1#!/usr/bin/env python 

2# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved. 

3# 

4# This file is part of Flipdare's proprietary software and contains 

5# confidential and copyrighted material. Unauthorised copying, 

6# modification, distribution, or use of this file is strictly 

7# prohibited without prior written permission from Flipdare Pty Ltd. 

8# 

9# This software includes third-party components licensed under MIT, 

10# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details. 

11# 

12from __future__ import annotations 

13from flipdare.payments.payment_types import AppReceipt 

14from flipdare.util.firebase_util import FirebaseUtil 

15from flipdare.util.public.public_types import ( 

16 PublicContent, 

17 PublicContentType, 

18 PublicUrl, 

19 PublicStoragePath, 

20) 

21 

22__all__ = ["PublicUrlFactory"] 

23 

24 

25class PublicUrlFactory: 

26 @staticmethod 

27 def create_receipt_content(info: AppReceipt, pdf_bytes: bytes) -> PublicContent: 

28 return PublicContent( 

29 url=PublicUrl( 

30 file_name=f"receipt_{info.receipt_id}.pdf", 

31 content_type=PublicContentType.PDF, 

32 storage_path=PublicStoragePath.RECEIPTS, 

33 ), 

34 bytes_content=pdf_bytes, 

35 ) 

36 

37 @staticmethod 

38 def create_temp_email_url(gs_url: str) -> PublicUrl: 

39 parts = FirebaseUtil.gs_url_parts(gs_url) 

40 

41 return PublicUrl( 

42 file_name=parts.name, 

43 content_type=PublicContentType.guess(parts.name), 

44 storage_path=PublicStoragePath.EMAILS, 

45 )