Coverage for functions \ flipdare \ generated \ model \ issue \ payment_issue_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 datetime import datetime 

23from google.cloud.firestore_v1.transforms import Sentinel 

24from flipdare.core.firestore_field import FirestoreField 

25from flipdare.util.time_util import FirestoreTime 

26from typing import Any, TypedDict, cast, Unpack 

27from enum import StrEnum 

28from pydantic import Field, ConfigDict, TypeAdapter 

29from flipdare.firestore.core.app_base_model import AppBaseModel 

30from flipdare.generated.shared.model.issue.payment_issue_type import PaymentIssueType 

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

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

33from flipdare.generated.shared.model.model_obj_type import ModelObjType 

34from flipdare.generated.model.issue.resolution_comment_model import ( 

35 ResolutionCommentModel, 

36 ResolutionCommentDict, 

37) 

38 

39 

40class PaymentIssueKeys(StrEnum): 

41 ID = "id" 

42 CREATED_AT = "created_at" 

43 UPDATED_AT = "updated_at" 

44 SLUG_CODE = "slug_code" 

45 FROM_UID = "from_uid" 

46 DESCRIPTION = "description" 

47 ISSUE_TYPE = "issue_type" 

48 PROGRESS = "progress" 

49 DISPUTED_PROGRESS = "disputed_progress" 

50 TO_UID = "to_uid" 

51 OBJ_ID = "obj_id" 

52 OBJ_TYPE = "obj_type" 

53 RESOLUTION = "resolution" 

54 COMMENT_COUNT = "comment_count" 

55 VERSION = "version" 

56 PROCESSED = "processed" 

57 ERROR_COUNT = "error_count" 

58 

59 

60# !! IMPORTANT !! 

61# !! 

62# !! this should only be used in the database to query. 

63# !! 

64class PaymentIssueInternalKeys(StrEnum): 

65 CREATED_AT = "created_at" 

66 UPDATED_AT = "updated_at" 

67 VERSION = "VERSION" 

68 PROCESSED = "INT_P" 

69 ERROR_COUNT = "INT_E" 

70 

71 

72class PaymentIssueModel(AppBaseModel): 

73 """Represents a payment-related issue or report in the system, which can be associated with various objects such as transactions or users.""" 

74 

75 model_config = ConfigDict(populate_by_name=True, arbitrary_types_allowed=True) 

76 

77 id: str | None = Field(None, alias="id") 

78 created_at: FirestoreField = Field( 

79 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp()) 

80 ) 

81 updated_at: FirestoreField = Field( 

82 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp()) 

83 ) 

84 slug_code: str 

85 from_uid: str 

86 description: str 

87 issue_type: PaymentIssueType | None = None 

88 progress: IssueProgress 

89 disputed_progress: DisputedProgress | None = None 

90 to_uid: str | None = None 

91 obj_id: str | None = None 

92 obj_type: ModelObjType | None = None 

93 resolution: ResolutionCommentModel | None = None 

94 comment_count: int = Field(default=0) 

95 # Version (base internal field) 

96 version: int = Field(default=1, alias="VERSION") 

97 # Processed (base internal field) 

98 processed: bool = Field(default=False, alias="INT_P") 

99 # Error Count (base internal field) 

100 error_count: int = Field(default=0, alias="INT_E") 

101 

102 @classmethod 

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

104 """ 

105 Uses Unpack to give you autocomplete and static warnings 

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

107 

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

109 """ 

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

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

112 if k in cls.__pydantic_fields__: 

113 field_info = cls.__pydantic_fields__[k] 

114 validated_value = cast( 

115 "Any", 

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

117 ) 

118 # Use alias if defined, otherwise use field name 

119 output_key = field_info.alias or k 

120 result[output_key] = validated_value 

121 return result 

122 

123 # ---- Convenience factories ----------------------------------------- 

124 

125 @classmethod 

126 def create_image( 

127 cls, 

128 issue_type: PaymentIssueType, 

129 progress: IssueProgress | None = None, 

130 **kwargs: Any, 

131 ) -> PaymentIssueModel: 

132 actual_progress = progress if progress is not None else issue_type.default_progress 

133 return cls( 

134 id=None, 

135 issue_type=issue_type, 

136 progress=actual_progress, 

137 **kwargs, 

138 ) 

139 

140 

141PAYMENTISSUE_FIELD_NAMES: list[str] = list(PaymentIssueModel.model_fields.keys()) 

142 

143 

144class PaymentIssueDict(TypedDict, total=False): 

145 id: str | None 

146 created_at: Sentinel | datetime | str 

147 updated_at: Sentinel | datetime | str 

148 slug_code: str 

149 from_uid: str 

150 description: str 

151 issue_type: PaymentIssueType | None 

152 progress: IssueProgress 

153 disputed_progress: DisputedProgress | None 

154 to_uid: str | None 

155 obj_id: str | None 

156 obj_type: ModelObjType | None 

157 resolution: ResolutionCommentDict | None 

158 comment_count: int | None 

159 VERSION: int | None 

160 INT_P: bool | None 

161 INT_E: int | None