Coverage for functions \ flipdare \ generated \ model \ internal \ evidence_model.py: 100%

0 statements  

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

1#!/usr/bin/env python 

2# 

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

4# 

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

6# confidential and copyrighted material. Unauthorised copying, 

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

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

9# 

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

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

12# 

13# NOTE: THIS FILE IS AUTO GENERATED. DO NOT EDIT. 

14# 

15# Generated by codegen_models.py 

16# 

17# Modify 'codegen_models.py' 

18# and re-run the script above to update. 

19# 

20# pragma: no cover 

21from __future__ import annotations 

22from typing import Any, TypedDict, cast, Unpack 

23from enum import StrEnum 

24from pydantic import ConfigDict, TypeAdapter 

25from flipdare.firestore.core.app_base_model import AppBaseModel 

26from flipdare.generated.shared.model.dare.ballot_result import BallotResult 

27from flipdare.generated.shared.model.issue.issue_progress import IssueProgress 

28from flipdare.generated.model.internal.evidence_communication_model import ( 

29 EvidenceCommunicationModel, 

30 EvidenceCommunicationDict, 

31) 

32from flipdare.generated.shared.model.issue.disputed_progress import DisputedProgress 

33 

34 

35class EvidenceKeys(StrEnum): 

36 RECEIPT_URL = "receipt_url" 

37 BALLOT_RESULT = "ballot_result" 

38 REFUND_POLICY = "refund_policy" 

39 TERMS_OF_SERVICE = "terms_of_service" 

40 SERVICE_DOCUMENTATION_URL = "service_documentation_url" 

41 ISSUE_ID = "issue_id" 

42 ISSUE_PROGRESS = "issue_progress" 

43 ISSUE_MESSAGES = "issue_messages" 

44 DISPUTE_ID = "dispute_id" 

45 DISPUTE_PROGRESS = "dispute_progress" 

46 DISPUTE_MESSAGES = "dispute_messages" 

47 CHAT_MESSAGES = "chat_messages" 

48 

49 

50class EvidenceModel(AppBaseModel): 

51 """Evidence related to a dispute in Stripe.""" 

52 

53 model_config = ConfigDict(populate_by_name=True) 

54 

55 # URL to the receipt for the transaction, which can be used as evidence in a dispute. 

56 receipt_url: str 

57 ballot_result: BallotResult 

58 refund_policy: str 

59 terms_of_service: str 

60 # Creator Agreement URL for the dare, which can be used as evidence in a dispute. 

61 service_documentation_url: str 

62 # The flipare issue id 

63 issue_id: str | None = None 

64 issue_progress: IssueProgress | None = None 

65 issue_messages: list[EvidenceCommunicationModel] | None = None 

66 # The flipare payment issue id 

67 dispute_id: str 

68 dispute_progress: DisputedProgress 

69 dispute_messages: list[EvidenceCommunicationModel] | None = None 

70 chat_messages: list[EvidenceCommunicationModel] | None = None 

71 

72 @classmethod 

73 def validate_partial(cls, **data: Unpack[EvidenceDict]) -> dict[str, Any]: 

74 """ 

75 Uses Unpack to give you autocomplete and static warnings 

76 if you pass an invalid key or type in your code. 

77 

78 Returns a dict with Firestore field names (aliases) for use with batch.update(). 

79 """ 

80 result: dict[str, Any] = {} 

81 for k, v in data.items(): 

82 if k in cls.__pydantic_fields__: 

83 field_info = cls.__pydantic_fields__[k] 

84 validated_value = cast( 

85 "Any", 

86 TypeAdapter(field_info.annotation).validate_python(v), 

87 ) 

88 # Use alias if defined, otherwise use field name 

89 output_key = field_info.alias or k 

90 result[output_key] = validated_value 

91 return result 

92 

93 

94EVIDENCE_FIELD_NAMES: list[str] = list(EvidenceModel.model_fields.keys()) 

95 

96 

97class EvidenceDict(TypedDict, total=False): 

98 receipt_url: str 

99 ballot_result: BallotResult 

100 refund_policy: str 

101 terms_of_service: str 

102 service_documentation_url: str 

103 issue_id: str | None 

104 issue_progress: IssueProgress | None 

105 issue_messages: list[EvidenceCommunicationDict] | None 

106 dispute_id: str 

107 dispute_progress: DisputedProgress 

108 dispute_messages: list[EvidenceCommunicationDict] | None 

109 chat_messages: list[EvidenceCommunicationDict] | None