lunchmoney-python 2.9.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. lunchmoney/__init__.py +205 -0
  2. lunchmoney/api/__init__.py +16 -0
  3. lunchmoney/api/categories_api.py +1499 -0
  4. lunchmoney/api/manual_accounts_api.py +1479 -0
  5. lunchmoney/api/me_api.py +293 -0
  6. lunchmoney/api/plaid_accounts_api.py +909 -0
  7. lunchmoney/api/recurring_items_api.py +702 -0
  8. lunchmoney/api/summary_api.py +434 -0
  9. lunchmoney/api/tags_api.py +1465 -0
  10. lunchmoney/api/transactions_api.py +914 -0
  11. lunchmoney/api/transactions_bulk_api.py +1527 -0
  12. lunchmoney/api/transactions_files_api.py +891 -0
  13. lunchmoney/api/transactions_group_api.py +601 -0
  14. lunchmoney/api/transactions_split_api.py +616 -0
  15. lunchmoney/api_client.py +805 -0
  16. lunchmoney/api_response.py +21 -0
  17. lunchmoney/configuration.py +620 -0
  18. lunchmoney/exceptions.py +217 -0
  19. lunchmoney/models/__init__.py +84 -0
  20. lunchmoney/models/account_type_enum.py +46 -0
  21. lunchmoney/models/aligned_category_totals_object.py +108 -0
  22. lunchmoney/models/aligned_summary_category_object.py +110 -0
  23. lunchmoney/models/aligned_summary_response_object.py +104 -0
  24. lunchmoney/models/category_object.py +146 -0
  25. lunchmoney/models/child_category_object.py +141 -0
  26. lunchmoney/models/child_transaction_object.py +219 -0
  27. lunchmoney/models/create_category_request_object.py +137 -0
  28. lunchmoney/models/create_category_request_object_children_inner.py +159 -0
  29. lunchmoney/models/create_manual_account_request_object.py +138 -0
  30. lunchmoney/models/create_manual_account_request_object_balance.py +145 -0
  31. lunchmoney/models/create_new_transactions_request.py +103 -0
  32. lunchmoney/models/create_tag_request_object.py +112 -0
  33. lunchmoney/models/currency_enum.py +198 -0
  34. lunchmoney/models/delete_category_response_with_dependencies.py +94 -0
  35. lunchmoney/models/delete_category_response_with_dependencies_dependents.py +98 -0
  36. lunchmoney/models/delete_tag_response_with_dependencies.py +94 -0
  37. lunchmoney/models/delete_tag_response_with_dependencies_dependents.py +90 -0
  38. lunchmoney/models/delete_transactions_request.py +89 -0
  39. lunchmoney/models/error_response_object.py +98 -0
  40. lunchmoney/models/error_response_object_errors_inner.py +101 -0
  41. lunchmoney/models/get_all_categories200_response.py +96 -0
  42. lunchmoney/models/get_all_manual_accounts200_response.py +96 -0
  43. lunchmoney/models/get_all_plaid_accounts200_response.py +96 -0
  44. lunchmoney/models/get_all_recurring200_response.py +96 -0
  45. lunchmoney/models/get_all_tags200_response.py +96 -0
  46. lunchmoney/models/get_all_transactions200_response.py +100 -0
  47. lunchmoney/models/get_all_transactions_created_since_parameter.py +145 -0
  48. lunchmoney/models/get_budget_summary200_response.py +138 -0
  49. lunchmoney/models/get_transaction_attachment_url200_response.py +91 -0
  50. lunchmoney/models/group_transactions_request.py +122 -0
  51. lunchmoney/models/insert_transaction_object.py +164 -0
  52. lunchmoney/models/insert_transaction_object_amount.py +145 -0
  53. lunchmoney/models/insert_transactions_response_object.py +106 -0
  54. lunchmoney/models/manual_account_object.py +158 -0
  55. lunchmoney/models/non_aligned_category_totals_object.py +94 -0
  56. lunchmoney/models/non_aligned_summary_category_object.py +94 -0
  57. lunchmoney/models/non_aligned_summary_response_object.py +104 -0
  58. lunchmoney/models/plaid_account_object.py +168 -0
  59. lunchmoney/models/recurring_object.py +143 -0
  60. lunchmoney/models/recurring_object_matches.py +105 -0
  61. lunchmoney/models/recurring_object_matches_found_transactions_inner.py +91 -0
  62. lunchmoney/models/recurring_object_overrides.py +92 -0
  63. lunchmoney/models/recurring_object_transaction_criteria.py +149 -0
  64. lunchmoney/models/skipped_existing_external_id_object.py +108 -0
  65. lunchmoney/models/split_transaction_object.py +102 -0
  66. lunchmoney/models/split_transaction_object_amount.py +145 -0
  67. lunchmoney/models/split_transaction_request.py +97 -0
  68. lunchmoney/models/summary_category_occurrence_object.py +126 -0
  69. lunchmoney/models/summary_recurring_transaction_object.py +100 -0
  70. lunchmoney/models/summary_rollover_pool_adjustment_object.py +98 -0
  71. lunchmoney/models/summary_rollover_pool_object.py +98 -0
  72. lunchmoney/models/summary_totals_breakdown_object.py +98 -0
  73. lunchmoney/models/summary_totals_object.py +97 -0
  74. lunchmoney/models/tag_object.py +125 -0
  75. lunchmoney/models/transaction_attachment_object.py +106 -0
  76. lunchmoney/models/transaction_object.py +229 -0
  77. lunchmoney/models/update_category_request_object.py +156 -0
  78. lunchmoney/models/update_manual_account_request_object.py +156 -0
  79. lunchmoney/models/update_manual_account_request_object_balance.py +145 -0
  80. lunchmoney/models/update_tag_request_object.py +126 -0
  81. lunchmoney/models/update_transaction_object.py +228 -0
  82. lunchmoney/models/update_transaction_object_amount.py +145 -0
  83. lunchmoney/models/update_transactions200_response.py +96 -0
  84. lunchmoney/models/update_transactions_request.py +97 -0
  85. lunchmoney/models/update_transactions_request_transactions_inner.py +228 -0
  86. lunchmoney/models/user_object.py +106 -0
  87. lunchmoney/py.typed +0 -0
  88. lunchmoney/rest.py +259 -0
  89. lunchmoney_python-2.9.0.dist-info/METADATA +285 -0
  90. lunchmoney_python-2.9.0.dist-info/RECORD +92 -0
  91. lunchmoney_python-2.9.0.dist-info/WHEEL +5 -0
  92. lunchmoney_python-2.9.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,137 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Lunch Money API - v2
5
+
6
+ Welcome to the Lunch Money v2 API. A working version of this API is now available through these docs, or directly at: `https://api.lunchmoney.dev/v2` <span class=\"red-text\"><strong>This is in alpha launch of a major API update. It is still subject to change during this alpha review period and bugs may still exist. Users are strongly encouraged to use the mock service or to create a test budget with example data as the first step to interacting with the v2 API.</strong></span> See the [Getting Started Guide](https://alpha.lunchmoney.dev/v2/getting-started) for more information on using a test budget.<br<br> If you are new to the v2 API, you may wish to review the [v2 API Overview of Changes](https://alpha.lunchmoney.dev/v2/changelog). ### Static Mock Server You may also use these docs to explore the API using a static mock server endpoint.<p> This enables users to become familiar with the API without having to create an access token, and eliminates the possibility of modifying real data. <p> To access this endpoint select the second endpoint in the the \"Server\" dropdown to the right. When selected you should see \"Static Mock v2 Lunch Money API Server\".<br> When using this server, set your Bearer token to any string with 11 or more characters. ### Migrating from V1 The v2 API is NOT backwards compatible with the v1 API. Developers are encouraged to review the [Migration Guide](https://alpha.lunchmoney.dev/v2/migration-guide) to understand the changes and plan their migration. ### Acknowledgments If you have been providing feedback on the API during our iterative design process, **THANK YOU**. We are happy to provide the opportunity to finally interact with the working API that was built based on your feedback. ### Useful links: - [Getting Started](https://alpha.lunchmoney.dev/v2/getting-started) - [v2 API Changelog](https://alpha.lunchmoney.dev/v2/changelog) - [Migration Guide](https://alpha.lunchmoney.dev/v2/migration-guide) - [Rate Limits](https://alpha.lunchmoney.dev/v2/rate-limits) - [Current v1 Lunch Money API Documentation](https://lunchmoney.dev) - [Awesome Lunch Money Projects](https://github.com/lunch-money/awesome-lunchmoney?tab=readme-ov-file)
7
+
8
+ The version of the OpenAPI document: 2.8.4
9
+ Contact: devsupport@lunchmoney.app
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import pprint
18
+ import re # noqa: F401
19
+ import json
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing_extensions import Annotated
24
+ from lunchmoney.models.create_category_request_object_children_inner import CreateCategoryRequestObjectChildrenInner
25
+ from typing import Optional, Set
26
+ from typing_extensions import Self
27
+
28
+ class CreateCategoryRequestObject(BaseModel):
29
+ """
30
+ CreateCategoryRequestObject
31
+ """ # noqa: E501
32
+ name: Annotated[str, Field(min_length=1, strict=True, max_length=100)] = Field(description="The name of the new category. Must be between 1 and 100 characters. Must not match the name of any existing categories or category groups.")
33
+ description: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=200)]] = Field(default=None, description="The description of the category. Must not exceed 200 characters.")
34
+ is_income: Optional[StrictBool] = Field(default=False, description="If `true`, the transactions in this category will be treated as income. (See <a href=\"https://support.lunchmoney.app/setup/categories/category-properties\">Category Properties</a> for more details)")
35
+ exclude_from_budget: Optional[StrictBool] = Field(default=False, description="If `true`, the transactions in this category will be excluded from the budget. (See <a href=\"https://support.lunchmoney.app/setup/categories/category-properties\">Category Properties</a> for more details)")
36
+ exclude_from_totals: Optional[StrictBool] = Field(default=False, description="If `true`, the transactions in this category will be excluded from totals. (See <a href=\"https://support.lunchmoney.app/setup/categories/category-properties\">Category Properties</a> for more details)")
37
+ is_group: Optional[StrictBool] = Field(default=False, description="If `true`, the category is created as a category group.")
38
+ group_id: Optional[StrictInt] = Field(default=None, description="If set to the ID of an existing category group, this new category will be assigned to that group. Cannot be set if `is_group` is true.")
39
+ archived: Optional[StrictBool] = Field(default=False, description="If `true`, the category is archived and not displayed in relevant areas of the Lunch Money app.")
40
+ children: Optional[List[CreateCategoryRequestObjectChildrenInner]] = Field(default=None, description="The list of existing category objects, or existing category IDs or names of new categories to add to the new category group. This attribute should only be set if `is_group` is also set to true.<br> The categories or IDs specified must already exist and may not be category groups themselves. Categories that already belong to another category group will be moved. If strings are specified, they will be used as the names of new categories that will be added to the new category group. The request will fail if any names are the same as the name of an existing category.<br> It is permissible to provide both full category objects and IDs as well as strings for names in the same request.")
41
+ order: Optional[StrictInt] = Field(default=None, description="An index specifying the position in which the category is displayed on the categories page in the Lunch Money GUI. For categories within a category group the order is relative to the other categories within the group.<br>While this property can be set via the API it is generally set by the user in the Lunch Money GUI. API.")
42
+ collapsed: Optional[StrictBool] = Field(default=None, description="If `true`, the category is collapsed in the Lunch Money GUI.<br>While this property can be set via the API it is generally set by the user in the Lunch Money GUI.")
43
+ __properties: ClassVar[List[str]] = ["name", "description", "is_income", "exclude_from_budget", "exclude_from_totals", "is_group", "group_id", "archived", "children", "order", "collapsed"]
44
+
45
+ model_config = ConfigDict(
46
+ populate_by_name=True,
47
+ validate_assignment=True,
48
+ protected_namespaces=(),
49
+ )
50
+
51
+
52
+ def to_str(self) -> str:
53
+ """Returns the string representation of the model using alias"""
54
+ return pprint.pformat(self.model_dump(by_alias=True))
55
+
56
+ def to_json(self) -> str:
57
+ """Returns the JSON representation of the model using alias"""
58
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
59
+ return json.dumps(self.to_dict())
60
+
61
+ @classmethod
62
+ def from_json(cls, json_str: str) -> Optional[Self]:
63
+ """Create an instance of CreateCategoryRequestObject from a JSON string"""
64
+ return cls.from_dict(json.loads(json_str))
65
+
66
+ def to_dict(self) -> Dict[str, Any]:
67
+ """Return the dictionary representation of the model using alias.
68
+
69
+ This has the following differences from calling pydantic's
70
+ `self.model_dump(by_alias=True)`:
71
+
72
+ * `None` is only added to the output dict for nullable fields that
73
+ were set at model initialization. Other fields with value `None`
74
+ are ignored.
75
+ """
76
+ excluded_fields: Set[str] = set([
77
+ ])
78
+
79
+ _dict = self.model_dump(
80
+ by_alias=True,
81
+ exclude=excluded_fields,
82
+ exclude_none=True,
83
+ )
84
+ # override the default output from pydantic by calling `to_dict()` of each item in children (list)
85
+ _items = []
86
+ if self.children:
87
+ for _item_children in self.children:
88
+ if _item_children:
89
+ _items.append(_item_children.to_dict())
90
+ _dict['children'] = _items
91
+ # set to None if description (nullable) is None
92
+ # and model_fields_set contains the field
93
+ if self.description is None and "description" in self.model_fields_set:
94
+ _dict['description'] = None
95
+
96
+ # set to None if group_id (nullable) is None
97
+ # and model_fields_set contains the field
98
+ if self.group_id is None and "group_id" in self.model_fields_set:
99
+ _dict['group_id'] = None
100
+
101
+ # set to None if order (nullable) is None
102
+ # and model_fields_set contains the field
103
+ if self.order is None and "order" in self.model_fields_set:
104
+ _dict['order'] = None
105
+
106
+ # set to None if collapsed (nullable) is None
107
+ # and model_fields_set contains the field
108
+ if self.collapsed is None and "collapsed" in self.model_fields_set:
109
+ _dict['collapsed'] = None
110
+
111
+ return _dict
112
+
113
+ @classmethod
114
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
115
+ """Create an instance of CreateCategoryRequestObject from a dict"""
116
+ if obj is None:
117
+ return None
118
+
119
+ if not isinstance(obj, dict):
120
+ return cls.model_validate(obj)
121
+
122
+ _obj = cls.model_validate({
123
+ "name": obj.get("name"),
124
+ "description": obj.get("description"),
125
+ "is_income": obj.get("is_income") if obj.get("is_income") is not None else False,
126
+ "exclude_from_budget": obj.get("exclude_from_budget") if obj.get("exclude_from_budget") is not None else False,
127
+ "exclude_from_totals": obj.get("exclude_from_totals") if obj.get("exclude_from_totals") is not None else False,
128
+ "is_group": obj.get("is_group") if obj.get("is_group") is not None else False,
129
+ "group_id": obj.get("group_id"),
130
+ "archived": obj.get("archived") if obj.get("archived") is not None else False,
131
+ "children": [CreateCategoryRequestObjectChildrenInner.from_dict(_item) for _item in obj["children"]] if obj.get("children") is not None else None,
132
+ "order": obj.get("order"),
133
+ "collapsed": obj.get("collapsed")
134
+ })
135
+ return _obj
136
+
137
+
@@ -0,0 +1,159 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Lunch Money API - v2
5
+
6
+ Welcome to the Lunch Money v2 API. A working version of this API is now available through these docs, or directly at: `https://api.lunchmoney.dev/v2` <span class=\"red-text\"><strong>This is in alpha launch of a major API update. It is still subject to change during this alpha review period and bugs may still exist. Users are strongly encouraged to use the mock service or to create a test budget with example data as the first step to interacting with the v2 API.</strong></span> See the [Getting Started Guide](https://alpha.lunchmoney.dev/v2/getting-started) for more information on using a test budget.<br<br> If you are new to the v2 API, you may wish to review the [v2 API Overview of Changes](https://alpha.lunchmoney.dev/v2/changelog). ### Static Mock Server You may also use these docs to explore the API using a static mock server endpoint.<p> This enables users to become familiar with the API without having to create an access token, and eliminates the possibility of modifying real data. <p> To access this endpoint select the second endpoint in the the \"Server\" dropdown to the right. When selected you should see \"Static Mock v2 Lunch Money API Server\".<br> When using this server, set your Bearer token to any string with 11 or more characters. ### Migrating from V1 The v2 API is NOT backwards compatible with the v1 API. Developers are encouraged to review the [Migration Guide](https://alpha.lunchmoney.dev/v2/migration-guide) to understand the changes and plan their migration. ### Acknowledgments If you have been providing feedback on the API during our iterative design process, **THANK YOU**. We are happy to provide the opportunity to finally interact with the working API that was built based on your feedback. ### Useful links: - [Getting Started](https://alpha.lunchmoney.dev/v2/getting-started) - [v2 API Changelog](https://alpha.lunchmoney.dev/v2/changelog) - [Migration Guide](https://alpha.lunchmoney.dev/v2/migration-guide) - [Rate Limits](https://alpha.lunchmoney.dev/v2/rate-limits) - [Current v1 Lunch Money API Documentation](https://lunchmoney.dev) - [Awesome Lunch Money Projects](https://github.com/lunch-money/awesome-lunchmoney?tab=readme-ov-file)
7
+
8
+ The version of the OpenAPI document: 2.8.4
9
+ Contact: devsupport@lunchmoney.app
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import json
18
+ import pprint
19
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, ValidationError, field_validator
20
+ from typing import Any, List, Optional
21
+ from typing_extensions import Annotated
22
+ from lunchmoney.models.category_object import CategoryObject
23
+ from pydantic import StrictStr, Field
24
+ from typing import Union, List, Set, Optional, Dict
25
+ from typing_extensions import Literal, Self
26
+
27
+ CREATECATEGORYREQUESTOBJECTCHILDRENINNER_ONE_OF_SCHEMAS = ["CategoryObject", "int", "str"]
28
+
29
+ class CreateCategoryRequestObjectChildrenInner(BaseModel):
30
+ """
31
+ CreateCategoryRequestObjectChildrenInner
32
+ """
33
+ # data type: int
34
+ oneof_schema_1_validator: Optional[StrictInt] = Field(default=None, description="ID of an existing category.")
35
+ # data type: str
36
+ oneof_schema_2_validator: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(default=None, description="Name of a new child category to be created.")
37
+ # data type: CategoryObject
38
+ oneof_schema_3_validator: Optional[CategoryObject] = None
39
+ actual_instance: Optional[Union[CategoryObject, int, str]] = None
40
+ one_of_schemas: Set[str] = { "CategoryObject", "int", "str" }
41
+
42
+ model_config = ConfigDict(
43
+ validate_assignment=True,
44
+ protected_namespaces=(),
45
+ )
46
+
47
+
48
+ def __init__(self, *args, **kwargs) -> None:
49
+ if args:
50
+ if len(args) > 1:
51
+ raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
52
+ if kwargs:
53
+ raise ValueError("If a position argument is used, keyword arguments cannot be used.")
54
+ super().__init__(actual_instance=args[0])
55
+ else:
56
+ super().__init__(**kwargs)
57
+
58
+ @field_validator('actual_instance')
59
+ def actual_instance_must_validate_oneof(cls, v):
60
+ instance = CreateCategoryRequestObjectChildrenInner.model_construct()
61
+ error_messages = []
62
+ match = 0
63
+ # validate data type: int
64
+ try:
65
+ instance.oneof_schema_1_validator = v
66
+ match += 1
67
+ except (ValidationError, ValueError) as e:
68
+ error_messages.append(str(e))
69
+ # validate data type: str
70
+ try:
71
+ instance.oneof_schema_2_validator = v
72
+ match += 1
73
+ except (ValidationError, ValueError) as e:
74
+ error_messages.append(str(e))
75
+ # validate data type: CategoryObject
76
+ if not isinstance(v, CategoryObject):
77
+ error_messages.append(f"Error! Input type `{type(v)}` is not `CategoryObject`")
78
+ else:
79
+ match += 1
80
+ if match > 1:
81
+ # more than 1 match
82
+ raise ValueError("Multiple matches found when setting `actual_instance` in CreateCategoryRequestObjectChildrenInner with oneOf schemas: CategoryObject, int, str. Details: " + ", ".join(error_messages))
83
+ elif match == 0:
84
+ # no match
85
+ raise ValueError("No match found when setting `actual_instance` in CreateCategoryRequestObjectChildrenInner with oneOf schemas: CategoryObject, int, str. Details: " + ", ".join(error_messages))
86
+ else:
87
+ return v
88
+
89
+ @classmethod
90
+ def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
91
+ return cls.from_json(json.dumps(obj))
92
+
93
+ @classmethod
94
+ def from_json(cls, json_str: str) -> Self:
95
+ """Returns the object represented by the json string"""
96
+ instance = cls.model_construct()
97
+ error_messages = []
98
+ match = 0
99
+
100
+ # deserialize data into int
101
+ try:
102
+ # validation
103
+ instance.oneof_schema_1_validator = json.loads(json_str)
104
+ # assign value to actual_instance
105
+ instance.actual_instance = instance.oneof_schema_1_validator
106
+ match += 1
107
+ except (ValidationError, ValueError) as e:
108
+ error_messages.append(str(e))
109
+ # deserialize data into str
110
+ try:
111
+ # validation
112
+ instance.oneof_schema_2_validator = json.loads(json_str)
113
+ # assign value to actual_instance
114
+ instance.actual_instance = instance.oneof_schema_2_validator
115
+ match += 1
116
+ except (ValidationError, ValueError) as e:
117
+ error_messages.append(str(e))
118
+ # deserialize data into CategoryObject
119
+ try:
120
+ instance.actual_instance = CategoryObject.from_json(json_str)
121
+ match += 1
122
+ except (ValidationError, ValueError) as e:
123
+ error_messages.append(str(e))
124
+
125
+ if match > 1:
126
+ # more than 1 match
127
+ raise ValueError("Multiple matches found when deserializing the JSON string into CreateCategoryRequestObjectChildrenInner with oneOf schemas: CategoryObject, int, str. Details: " + ", ".join(error_messages))
128
+ elif match == 0:
129
+ # no match
130
+ raise ValueError("No match found when deserializing the JSON string into CreateCategoryRequestObjectChildrenInner with oneOf schemas: CategoryObject, int, str. Details: " + ", ".join(error_messages))
131
+ else:
132
+ return instance
133
+
134
+ def to_json(self) -> str:
135
+ """Returns the JSON representation of the actual instance"""
136
+ if self.actual_instance is None:
137
+ return "null"
138
+
139
+ if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
140
+ return self.actual_instance.to_json()
141
+ else:
142
+ return json.dumps(self.actual_instance)
143
+
144
+ def to_dict(self) -> Optional[Union[Dict[str, Any], CategoryObject, int, str]]:
145
+ """Returns the dict representation of the actual instance"""
146
+ if self.actual_instance is None:
147
+ return None
148
+
149
+ if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
150
+ return self.actual_instance.to_dict()
151
+ else:
152
+ # primitive type
153
+ return self.actual_instance
154
+
155
+ def to_str(self) -> str:
156
+ """Returns the string representation of the actual instance"""
157
+ return pprint.pformat(self.model_dump())
158
+
159
+
@@ -0,0 +1,138 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Lunch Money API - v2
5
+
6
+ Welcome to the Lunch Money v2 API. A working version of this API is now available through these docs, or directly at: `https://api.lunchmoney.dev/v2` <span class=\"red-text\"><strong>This is in alpha launch of a major API update. It is still subject to change during this alpha review period and bugs may still exist. Users are strongly encouraged to use the mock service or to create a test budget with example data as the first step to interacting with the v2 API.</strong></span> See the [Getting Started Guide](https://alpha.lunchmoney.dev/v2/getting-started) for more information on using a test budget.<br<br> If you are new to the v2 API, you may wish to review the [v2 API Overview of Changes](https://alpha.lunchmoney.dev/v2/changelog). ### Static Mock Server You may also use these docs to explore the API using a static mock server endpoint.<p> This enables users to become familiar with the API without having to create an access token, and eliminates the possibility of modifying real data. <p> To access this endpoint select the second endpoint in the the \"Server\" dropdown to the right. When selected you should see \"Static Mock v2 Lunch Money API Server\".<br> When using this server, set your Bearer token to any string with 11 or more characters. ### Migrating from V1 The v2 API is NOT backwards compatible with the v1 API. Developers are encouraged to review the [Migration Guide](https://alpha.lunchmoney.dev/v2/migration-guide) to understand the changes and plan their migration. ### Acknowledgments If you have been providing feedback on the API during our iterative design process, **THANK YOU**. We are happy to provide the opportunity to finally interact with the working API that was built based on your feedback. ### Useful links: - [Getting Started](https://alpha.lunchmoney.dev/v2/getting-started) - [v2 API Changelog](https://alpha.lunchmoney.dev/v2/changelog) - [Migration Guide](https://alpha.lunchmoney.dev/v2/migration-guide) - [Rate Limits](https://alpha.lunchmoney.dev/v2/rate-limits) - [Current v1 Lunch Money API Documentation](https://lunchmoney.dev) - [Awesome Lunch Money Projects](https://github.com/lunch-money/awesome-lunchmoney?tab=readme-ov-file)
7
+
8
+ The version of the OpenAPI document: 2.8.4
9
+ Contact: devsupport@lunchmoney.app
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import pprint
18
+ import re # noqa: F401
19
+ import json
20
+
21
+ from datetime import date
22
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
23
+ from typing import Any, ClassVar, Dict, List, Optional
24
+ from typing_extensions import Annotated
25
+ from lunchmoney.models.account_type_enum import AccountTypeEnum
26
+ from lunchmoney.models.create_manual_account_request_object_balance import CreateManualAccountRequestObjectBalance
27
+ from lunchmoney.models.currency_enum import CurrencyEnum
28
+ from typing import Optional, Set
29
+ from typing_extensions import Self
30
+
31
+ class CreateManualAccountRequestObject(BaseModel):
32
+ """
33
+ CreateManualAccountRequestObject
34
+ """ # noqa: E501
35
+ name: Annotated[str, Field(min_length=1, strict=True, max_length=45)] = Field(description="Name of the manual account")
36
+ type: AccountTypeEnum = Field(description="The type of manual account.")
37
+ subtype: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=100)]] = Field(default=None, description="An optional manual account subtype. Examples include<br> - retirement - checking - savings - prepaid credit card")
38
+ display_name: Optional[StrictStr] = Field(default=None, description="Display name of the manual account as set by user.<br> This must be unique for the budgeting account. If not set, it will be derived from the `institution_name` (if any) plus `name`.")
39
+ balance: CreateManualAccountRequestObjectBalance
40
+ balance_as_of: Optional[StrictStr] = Field(default=None, description="Date/time the balance of the manual account was last updated in ISO 8601 extended format")
41
+ closed_on: Optional[date] = Field(default=None, description="The date this manual account was closed in YYYY-MM-DD format.")
42
+ currency: Optional[CurrencyEnum] = Field(default=None, description="Three-letter lowercase currency code of the transaction in ISO 4217 format")
43
+ institution_name: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=50)]] = Field(default=None, description="Name of institution holding the manual account")
44
+ external_id: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=75)]] = Field(default=None, description="An optional user-defined ID for the manual account")
45
+ custom_metadata: Optional[Dict[str, Any]] = Field(default=None, description="An optional JSON object that includes additional data related to this account. This must be a valid JSON object and, when stringified, must not exceed 4096 characters.")
46
+ exclude_from_transactions: Optional[StrictBool] = Field(default=False, description="If `true`, transactions may not be assigned to this manual account.")
47
+ __properties: ClassVar[List[str]] = ["name", "type", "subtype", "display_name", "balance", "balance_as_of", "closed_on", "currency", "institution_name", "external_id", "custom_metadata", "exclude_from_transactions"]
48
+
49
+ model_config = ConfigDict(
50
+ populate_by_name=True,
51
+ validate_assignment=True,
52
+ protected_namespaces=(),
53
+ )
54
+
55
+
56
+ def to_str(self) -> str:
57
+ """Returns the string representation of the model using alias"""
58
+ return pprint.pformat(self.model_dump(by_alias=True))
59
+
60
+ def to_json(self) -> str:
61
+ """Returns the JSON representation of the model using alias"""
62
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
63
+ return json.dumps(self.to_dict())
64
+
65
+ @classmethod
66
+ def from_json(cls, json_str: str) -> Optional[Self]:
67
+ """Create an instance of CreateManualAccountRequestObject from a JSON string"""
68
+ return cls.from_dict(json.loads(json_str))
69
+
70
+ def to_dict(self) -> Dict[str, Any]:
71
+ """Return the dictionary representation of the model using alias.
72
+
73
+ This has the following differences from calling pydantic's
74
+ `self.model_dump(by_alias=True)`:
75
+
76
+ * `None` is only added to the output dict for nullable fields that
77
+ were set at model initialization. Other fields with value `None`
78
+ are ignored.
79
+ """
80
+ excluded_fields: Set[str] = set([
81
+ ])
82
+
83
+ _dict = self.model_dump(
84
+ by_alias=True,
85
+ exclude=excluded_fields,
86
+ exclude_none=True,
87
+ )
88
+ # override the default output from pydantic by calling `to_dict()` of balance
89
+ if self.balance:
90
+ _dict['balance'] = self.balance.to_dict()
91
+ # set to None if balance_as_of (nullable) is None
92
+ # and model_fields_set contains the field
93
+ if self.balance_as_of is None and "balance_as_of" in self.model_fields_set:
94
+ _dict['balance_as_of'] = None
95
+
96
+ # set to None if closed_on (nullable) is None
97
+ # and model_fields_set contains the field
98
+ if self.closed_on is None and "closed_on" in self.model_fields_set:
99
+ _dict['closed_on'] = None
100
+
101
+ # set to None if external_id (nullable) is None
102
+ # and model_fields_set contains the field
103
+ if self.external_id is None and "external_id" in self.model_fields_set:
104
+ _dict['external_id'] = None
105
+
106
+ # set to None if custom_metadata (nullable) is None
107
+ # and model_fields_set contains the field
108
+ if self.custom_metadata is None and "custom_metadata" in self.model_fields_set:
109
+ _dict['custom_metadata'] = None
110
+
111
+ return _dict
112
+
113
+ @classmethod
114
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
115
+ """Create an instance of CreateManualAccountRequestObject from a dict"""
116
+ if obj is None:
117
+ return None
118
+
119
+ if not isinstance(obj, dict):
120
+ return cls.model_validate(obj)
121
+
122
+ _obj = cls.model_validate({
123
+ "name": obj.get("name"),
124
+ "type": obj.get("type"),
125
+ "subtype": obj.get("subtype"),
126
+ "display_name": obj.get("display_name"),
127
+ "balance": CreateManualAccountRequestObjectBalance.from_dict(obj["balance"]) if obj.get("balance") is not None else None,
128
+ "balance_as_of": obj.get("balance_as_of"),
129
+ "closed_on": obj.get("closed_on"),
130
+ "currency": obj.get("currency"),
131
+ "institution_name": obj.get("institution_name"),
132
+ "external_id": obj.get("external_id"),
133
+ "custom_metadata": obj.get("custom_metadata"),
134
+ "exclude_from_transactions": obj.get("exclude_from_transactions") if obj.get("exclude_from_transactions") is not None else False
135
+ })
136
+ return _obj
137
+
138
+
@@ -0,0 +1,145 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Lunch Money API - v2
5
+
6
+ Welcome to the Lunch Money v2 API. A working version of this API is now available through these docs, or directly at: `https://api.lunchmoney.dev/v2` <span class=\"red-text\"><strong>This is in alpha launch of a major API update. It is still subject to change during this alpha review period and bugs may still exist. Users are strongly encouraged to use the mock service or to create a test budget with example data as the first step to interacting with the v2 API.</strong></span> See the [Getting Started Guide](https://alpha.lunchmoney.dev/v2/getting-started) for more information on using a test budget.<br<br> If you are new to the v2 API, you may wish to review the [v2 API Overview of Changes](https://alpha.lunchmoney.dev/v2/changelog). ### Static Mock Server You may also use these docs to explore the API using a static mock server endpoint.<p> This enables users to become familiar with the API without having to create an access token, and eliminates the possibility of modifying real data. <p> To access this endpoint select the second endpoint in the the \"Server\" dropdown to the right. When selected you should see \"Static Mock v2 Lunch Money API Server\".<br> When using this server, set your Bearer token to any string with 11 or more characters. ### Migrating from V1 The v2 API is NOT backwards compatible with the v1 API. Developers are encouraged to review the [Migration Guide](https://alpha.lunchmoney.dev/v2/migration-guide) to understand the changes and plan their migration. ### Acknowledgments If you have been providing feedback on the API during our iterative design process, **THANK YOU**. We are happy to provide the opportunity to finally interact with the working API that was built based on your feedback. ### Useful links: - [Getting Started](https://alpha.lunchmoney.dev/v2/getting-started) - [v2 API Changelog](https://alpha.lunchmoney.dev/v2/changelog) - [Migration Guide](https://alpha.lunchmoney.dev/v2/migration-guide) - [Rate Limits](https://alpha.lunchmoney.dev/v2/rate-limits) - [Current v1 Lunch Money API Documentation](https://lunchmoney.dev) - [Awesome Lunch Money Projects](https://github.com/lunch-money/awesome-lunchmoney?tab=readme-ov-file)
7
+
8
+ The version of the OpenAPI document: 2.8.4
9
+ Contact: devsupport@lunchmoney.app
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import json
18
+ import pprint
19
+ from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, ValidationError, field_validator
20
+ from typing import Any, List, Optional, Union
21
+ from typing_extensions import Annotated
22
+ from pydantic import StrictStr, Field
23
+ from typing import Union, List, Set, Optional, Dict
24
+ from typing_extensions import Literal, Self
25
+
26
+ CREATEMANUALACCOUNTREQUESTOBJECTBALANCE_ONE_OF_SCHEMAS = ["float", "str"]
27
+
28
+ class CreateManualAccountRequestObjectBalance(BaseModel):
29
+ """
30
+ Numeric value of the current balance, up to four decimal places, of the account as a number or string. Do not include any special characters aside from a decimal point.
31
+ """
32
+ # data type: float
33
+ oneof_schema_1_validator: Optional[Union[StrictFloat, StrictInt]] = None
34
+ # data type: str
35
+ oneof_schema_2_validator: Optional[Annotated[str, Field(strict=True)]] = None
36
+ actual_instance: Optional[Union[float, str]] = None
37
+ one_of_schemas: Set[str] = { "float", "str" }
38
+
39
+ model_config = ConfigDict(
40
+ validate_assignment=True,
41
+ protected_namespaces=(),
42
+ )
43
+
44
+
45
+ def __init__(self, *args, **kwargs) -> None:
46
+ if args:
47
+ if len(args) > 1:
48
+ raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
49
+ if kwargs:
50
+ raise ValueError("If a position argument is used, keyword arguments cannot be used.")
51
+ super().__init__(actual_instance=args[0])
52
+ else:
53
+ super().__init__(**kwargs)
54
+
55
+ @field_validator('actual_instance')
56
+ def actual_instance_must_validate_oneof(cls, v):
57
+ instance = CreateManualAccountRequestObjectBalance.model_construct()
58
+ error_messages = []
59
+ match = 0
60
+ # validate data type: float
61
+ try:
62
+ instance.oneof_schema_1_validator = v
63
+ match += 1
64
+ except (ValidationError, ValueError) as e:
65
+ error_messages.append(str(e))
66
+ # validate data type: str
67
+ try:
68
+ instance.oneof_schema_2_validator = v
69
+ match += 1
70
+ except (ValidationError, ValueError) as e:
71
+ error_messages.append(str(e))
72
+ if match > 1:
73
+ # more than 1 match
74
+ raise ValueError("Multiple matches found when setting `actual_instance` in CreateManualAccountRequestObjectBalance with oneOf schemas: float, str. Details: " + ", ".join(error_messages))
75
+ elif match == 0:
76
+ # no match
77
+ raise ValueError("No match found when setting `actual_instance` in CreateManualAccountRequestObjectBalance with oneOf schemas: float, str. Details: " + ", ".join(error_messages))
78
+ else:
79
+ return v
80
+
81
+ @classmethod
82
+ def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
83
+ return cls.from_json(json.dumps(obj))
84
+
85
+ @classmethod
86
+ def from_json(cls, json_str: str) -> Self:
87
+ """Returns the object represented by the json string"""
88
+ instance = cls.model_construct()
89
+ error_messages = []
90
+ match = 0
91
+
92
+ # deserialize data into float
93
+ try:
94
+ # validation
95
+ instance.oneof_schema_1_validator = json.loads(json_str)
96
+ # assign value to actual_instance
97
+ instance.actual_instance = instance.oneof_schema_1_validator
98
+ match += 1
99
+ except (ValidationError, ValueError) as e:
100
+ error_messages.append(str(e))
101
+ # deserialize data into str
102
+ try:
103
+ # validation
104
+ instance.oneof_schema_2_validator = json.loads(json_str)
105
+ # assign value to actual_instance
106
+ instance.actual_instance = instance.oneof_schema_2_validator
107
+ match += 1
108
+ except (ValidationError, ValueError) as e:
109
+ error_messages.append(str(e))
110
+
111
+ if match > 1:
112
+ # more than 1 match
113
+ raise ValueError("Multiple matches found when deserializing the JSON string into CreateManualAccountRequestObjectBalance with oneOf schemas: float, str. Details: " + ", ".join(error_messages))
114
+ elif match == 0:
115
+ # no match
116
+ raise ValueError("No match found when deserializing the JSON string into CreateManualAccountRequestObjectBalance with oneOf schemas: float, str. Details: " + ", ".join(error_messages))
117
+ else:
118
+ return instance
119
+
120
+ def to_json(self) -> str:
121
+ """Returns the JSON representation of the actual instance"""
122
+ if self.actual_instance is None:
123
+ return "null"
124
+
125
+ if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
126
+ return self.actual_instance.to_json()
127
+ else:
128
+ return json.dumps(self.actual_instance)
129
+
130
+ def to_dict(self) -> Optional[Union[Dict[str, Any], float, str]]:
131
+ """Returns the dict representation of the actual instance"""
132
+ if self.actual_instance is None:
133
+ return None
134
+
135
+ if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
136
+ return self.actual_instance.to_dict()
137
+ else:
138
+ # primitive type
139
+ return self.actual_instance
140
+
141
+ def to_str(self) -> str:
142
+ """Returns the string representation of the actual instance"""
143
+ return pprint.pformat(self.model_dump())
144
+
145
+