twitter-openapi-python-generated 0.0.30__py3-none-any.whl → 0.0.32__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 (72) hide show
  1. twitter_openapi_python_generated/__init__.py +28 -4
  2. twitter_openapi_python_generated/api/default_api.py +335 -0
  3. twitter_openapi_python_generated/api/tweet_api.py +1356 -84
  4. twitter_openapi_python_generated/api_client.py +1 -1
  5. twitter_openapi_python_generated/configuration.py +1 -1
  6. twitter_openapi_python_generated/models/__init__.py +27 -3
  7. twitter_openapi_python_generated/models/about_community_result.py +95 -0
  8. twitter_openapi_python_generated/models/{timeline_v2.py → about_community_results.py} +12 -12
  9. twitter_openapi_python_generated/models/about_community_tweet_data.py +92 -0
  10. twitter_openapi_python_generated/models/analysis_results.py +94 -0
  11. twitter_openapi_python_generated/models/birdwatch_pivot.py +3 -1
  12. twitter_openapi_python_generated/models/community_about_timeline_response.py +102 -0
  13. twitter_openapi_python_generated/models/community_media_timeline_response.py +102 -0
  14. twitter_openapi_python_generated/models/community_tweets_timeline_response.py +102 -0
  15. twitter_openapi_python_generated/models/content_item_type.py +2 -0
  16. twitter_openapi_python_generated/models/grok_image_annotation.py +90 -0
  17. twitter_openapi_python_generated/models/grok_share_attachment.py +3 -1
  18. twitter_openapi_python_generated/models/grok_share_attachment_item.py +10 -2
  19. twitter_openapi_python_generated/models/home_timeline_response_data.py +2 -2
  20. twitter_openapi_python_generated/models/instruction_type.py +2 -0
  21. twitter_openapi_python_generated/models/instruction_union.py +46 -8
  22. twitter_openapi_python_generated/models/item_content_union.py +27 -8
  23. twitter_openapi_python_generated/models/list_tweets_timeline_data.py +2 -2
  24. twitter_openapi_python_generated/models/list_tweets_timeline_list.py +3 -3
  25. twitter_openapi_python_generated/models/media_community_result.py +95 -0
  26. twitter_openapi_python_generated/models/media_community_results.py +92 -0
  27. twitter_openapi_python_generated/models/media_community_tweet_data.py +92 -0
  28. twitter_openapi_python_generated/models/media_result.py +8 -2
  29. twitter_openapi_python_generated/models/module_item.py +2 -2
  30. twitter_openapi_python_generated/models/notification_template.py +93 -0
  31. twitter_openapi_python_generated/models/notifications_result.py +105 -0
  32. twitter_openapi_python_generated/models/notifications_timeline_data.py +92 -0
  33. twitter_openapi_python_generated/models/notifications_timeline_response.py +102 -0
  34. twitter_openapi_python_generated/models/notifications_user_results.py +92 -0
  35. twitter_openapi_python_generated/models/notifications_viewer_v2.py +92 -0
  36. twitter_openapi_python_generated/models/post_create_bookmark_request.py +5 -1
  37. twitter_openapi_python_generated/models/post_create_retweet_request.py +5 -1
  38. twitter_openapi_python_generated/models/post_create_tweet_request.py +6 -2
  39. twitter_openapi_python_generated/models/post_create_tweet_request_features.py +19 -5
  40. twitter_openapi_python_generated/models/post_delete_bookmark_request.py +5 -1
  41. twitter_openapi_python_generated/models/post_delete_retweet_request.py +5 -1
  42. twitter_openapi_python_generated/models/post_delete_tweet_request.py +5 -1
  43. twitter_openapi_python_generated/models/post_favorite_tweet_request.py +5 -1
  44. twitter_openapi_python_generated/models/post_unfavorite_tweet_request.py +5 -1
  45. twitter_openapi_python_generated/models/ranked_community_result.py +95 -0
  46. twitter_openapi_python_generated/models/ranked_community_results.py +92 -0
  47. twitter_openapi_python_generated/models/ranked_community_tweet_data.py +92 -0
  48. twitter_openapi_python_generated/models/rich_message.py +90 -0
  49. twitter_openapi_python_generated/models/search_timeline_data.py +2 -2
  50. twitter_openapi_python_generated/models/timeline_add_entry.py +2 -2
  51. twitter_openapi_python_generated/models/timeline_clear_entries_unread_state.py +89 -0
  52. twitter_openapi_python_generated/models/timeline_general_context.py +5 -3
  53. twitter_openapi_python_generated/models/timeline_mark_entries_unread_greater_than_sort_index.py +102 -0
  54. twitter_openapi_python_generated/models/timeline_notification.py +116 -0
  55. twitter_openapi_python_generated/models/{list_tweets_timeline.py → timeline_result.py} +8 -6
  56. twitter_openapi_python_generated/models/timeline_timeline_module.py +1 -1
  57. twitter_openapi_python_generated/models/timeline_trend.py +3 -3
  58. twitter_openapi_python_generated/models/timeline_user.py +2 -2
  59. twitter_openapi_python_generated/models/tweet.py +1 -1
  60. twitter_openapi_python_generated/models/tweet_favoriters_response_data.py +3 -3
  61. twitter_openapi_python_generated/models/tweet_retweeters_response_data.py +3 -3
  62. twitter_openapi_python_generated/models/type_name.py +3 -0
  63. twitter_openapi_python_generated/models/user.py +2 -2
  64. twitter_openapi_python_generated/models/user_tweets_result_v1.py +95 -0
  65. twitter_openapi_python_generated/models/{user_tweets_result.py → user_tweets_result_v2.py} +7 -7
  66. twitter_openapi_python_generated/models/user_tweets_user.py +3 -3
  67. {twitter_openapi_python_generated-0.0.30.dist-info → twitter_openapi_python_generated-0.0.32.dist-info}/METADATA +12 -2
  68. {twitter_openapi_python_generated-0.0.30.dist-info → twitter_openapi_python_generated-0.0.32.dist-info}/RECORD +72 -48
  69. {twitter_openapi_python_generated-0.0.30.dist-info → twitter_openapi_python_generated-0.0.32.dist-info}/WHEEL +1 -1
  70. {twitter_openapi_python_generated-0.0.30.dist-info → twitter_openapi_python_generated-0.0.32.dist-info/licenses}/LICENSE +0 -0
  71. {twitter_openapi_python_generated-0.0.30.dist-info → twitter_openapi_python_generated-0.0.32.dist-info/licenses}/LICENSE.AGPL +0 -0
  72. {twitter_openapi_python_generated-0.0.30.dist-info → twitter_openapi_python_generated-0.0.32.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,92 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Twitter OpenAPI
5
+
6
+ Twitter OpenAPI(Swagger) specification
7
+
8
+ The version of the OpenAPI document: 0.0.1
9
+ Contact: yuki@yuki0311.com
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
22
+ from typing import Any, ClassVar, Dict, List
23
+ from twitter_openapi_python_generated.models.ranked_community_result import RankedCommunityResult
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class RankedCommunityResults(BaseModel):
28
+ """
29
+ RankedCommunityResults
30
+ """ # noqa: E501
31
+ result: RankedCommunityResult
32
+ __properties: ClassVar[List[str]] = ["result"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of RankedCommunityResults from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([
66
+ ])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ # override the default output from pydantic by calling `to_dict()` of result
74
+ if self.result:
75
+ _dict['result'] = self.result.to_dict()
76
+ return _dict
77
+
78
+ @classmethod
79
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
80
+ """Create an instance of RankedCommunityResults from a dict"""
81
+ if obj is None:
82
+ return None
83
+
84
+ if not isinstance(obj, dict):
85
+ return cls.model_validate(obj)
86
+
87
+ _obj = cls.model_validate({
88
+ "result": RankedCommunityResult.from_dict(obj["result"]) if obj.get("result") is not None else None
89
+ })
90
+ return _obj
91
+
92
+
@@ -0,0 +1,92 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Twitter OpenAPI
5
+
6
+ Twitter OpenAPI(Swagger) specification
7
+
8
+ The version of the OpenAPI document: 0.0.1
9
+ Contact: yuki@yuki0311.com
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
22
+ from typing import Any, ClassVar, Dict, List
23
+ from twitter_openapi_python_generated.models.ranked_community_results import RankedCommunityResults
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class RankedCommunityTweetData(BaseModel):
28
+ """
29
+ RankedCommunityTweetData
30
+ """ # noqa: E501
31
+ community_results: RankedCommunityResults = Field(alias="communityResults")
32
+ __properties: ClassVar[List[str]] = ["communityResults"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of RankedCommunityTweetData from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([
66
+ ])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ # override the default output from pydantic by calling `to_dict()` of community_results
74
+ if self.community_results:
75
+ _dict['communityResults'] = self.community_results.to_dict()
76
+ return _dict
77
+
78
+ @classmethod
79
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
80
+ """Create an instance of RankedCommunityTweetData from a dict"""
81
+ if obj is None:
82
+ return None
83
+
84
+ if not isinstance(obj, dict):
85
+ return cls.model_validate(obj)
86
+
87
+ _obj = cls.model_validate({
88
+ "communityResults": RankedCommunityResults.from_dict(obj["communityResults"]) if obj.get("communityResults") is not None else None
89
+ })
90
+ return _obj
91
+
92
+
@@ -0,0 +1,90 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Twitter OpenAPI
5
+
6
+ Twitter OpenAPI(Swagger) specification
7
+
8
+ The version of the OpenAPI document: 0.0.1
9
+ Contact: yuki@yuki0311.com
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, StrictBool, StrictStr
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class RichMessage(BaseModel):
27
+ """
28
+ RichMessage
29
+ """ # noqa: E501
30
+ rtl: Optional[StrictBool] = None
31
+ text: Optional[StrictStr] = None
32
+ __properties: ClassVar[List[str]] = ["rtl", "text"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of RichMessage from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([
66
+ ])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ return _dict
74
+
75
+ @classmethod
76
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
77
+ """Create an instance of RichMessage from a dict"""
78
+ if obj is None:
79
+ return None
80
+
81
+ if not isinstance(obj, dict):
82
+ return cls.model_validate(obj)
83
+
84
+ _obj = cls.model_validate({
85
+ "rtl": obj.get("rtl"),
86
+ "text": obj.get("text")
87
+ })
88
+ return _obj
89
+
90
+
@@ -19,7 +19,7 @@ import re # noqa: F401
19
19
  import json
20
20
 
21
21
  from pydantic import BaseModel, ConfigDict
22
- from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Any, ClassVar, Dict, List
23
23
  from twitter_openapi_python_generated.models.search_by_raw_query import SearchByRawQuery
24
24
  from typing import Optional, Set
25
25
  from typing_extensions import Self
@@ -28,7 +28,7 @@ class SearchTimelineData(BaseModel):
28
28
  """
29
29
  SearchTimelineData
30
30
  """ # noqa: E501
31
- search_by_raw_query: Optional[SearchByRawQuery] = None
31
+ search_by_raw_query: SearchByRawQuery
32
32
  __properties: ClassVar[List[str]] = ["search_by_raw_query"]
33
33
 
34
34
  model_config = ConfigDict(
@@ -37,8 +37,8 @@ class TimelineAddEntry(BaseModel):
37
37
  @field_validator('entry_id')
38
38
  def entry_id_validate_regular_expression(cls, value):
39
39
  """Validates the regular expression"""
40
- if not re.match(r"^(([a-z]+|[0-9]+|[0-9a-f]+)(-|$))+", value):
41
- raise ValueError(r"must validate the regular expression /^(([a-z]+|[0-9]+|[0-9a-f]+)(-|$))+/")
40
+ if not re.match(r"^(([a-zA-Z]+|[0-9]+|[0-9a-f]+)(-|$))+", value):
41
+ raise ValueError(r"must validate the regular expression /^(([a-zA-Z]+|[0-9]+|[0-9a-f]+)(-|$))+/")
42
42
  return value
43
43
 
44
44
  @field_validator('sort_index')
@@ -0,0 +1,89 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Twitter OpenAPI
5
+
6
+ Twitter OpenAPI(Swagger) specification
7
+
8
+ The version of the OpenAPI document: 0.0.1
9
+ Contact: yuki@yuki0311.com
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
22
+ from typing import Any, ClassVar, Dict, List
23
+ from twitter_openapi_python_generated.models.instruction_type import InstructionType
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class TimelineClearEntriesUnreadState(BaseModel):
28
+ """
29
+ TimelineClearEntriesUnreadState
30
+ """ # noqa: E501
31
+ type: InstructionType
32
+ __properties: ClassVar[List[str]] = ["type"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of TimelineClearEntriesUnreadState from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([
66
+ ])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ return _dict
74
+
75
+ @classmethod
76
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
77
+ """Create an instance of TimelineClearEntriesUnreadState from a dict"""
78
+ if obj is None:
79
+ return None
80
+
81
+ if not isinstance(obj, dict):
82
+ return cls.model_validate(obj)
83
+
84
+ _obj = cls.model_validate({
85
+ "type": obj.get("type")
86
+ })
87
+ return _obj
88
+
89
+
@@ -29,11 +29,12 @@ class TimelineGeneralContext(BaseModel):
29
29
  """
30
30
  TimelineGeneralContext
31
31
  """ # noqa: E501
32
+ context_image_urls: Optional[List[StrictStr]] = Field(default=None, alias="contextImageUrls")
32
33
  context_type: Optional[StrictStr] = Field(default=None, alias="contextType")
33
34
  landing_url: Optional[SocialContextLandingUrl] = Field(default=None, alias="landingUrl")
34
35
  text: Optional[StrictStr] = None
35
36
  type: Optional[SocialContextUnionType] = None
36
- __properties: ClassVar[List[str]] = ["contextType", "landingUrl", "text", "type"]
37
+ __properties: ClassVar[List[str]] = ["contextImageUrls", "contextType", "landingUrl", "text", "type"]
37
38
 
38
39
  @field_validator('context_type')
39
40
  def context_type_validate_enum(cls, value):
@@ -41,8 +42,8 @@ class TimelineGeneralContext(BaseModel):
41
42
  if value is None:
42
43
  return value
43
44
 
44
- if value not in set(['Follow', 'Pin', 'Like', 'Location', 'Sparkle', 'Conversation', 'List', 'Community']):
45
- raise ValueError("must be one of enum values ('Follow', 'Pin', 'Like', 'Location', 'Sparkle', 'Conversation', 'List', 'Community')")
45
+ if value not in set(['Follow', 'Pin', 'Like', 'Location', 'Sparkle', 'Conversation', 'List', 'Community', 'Facepile']):
46
+ raise ValueError("must be one of enum values ('Follow', 'Pin', 'Like', 'Location', 'Sparkle', 'Conversation', 'List', 'Community', 'Facepile')")
46
47
  return value
47
48
 
48
49
  model_config = ConfigDict(
@@ -99,6 +100,7 @@ class TimelineGeneralContext(BaseModel):
99
100
  return cls.model_validate(obj)
100
101
 
101
102
  _obj = cls.model_validate({
103
+ "contextImageUrls": obj.get("contextImageUrls"),
102
104
  "contextType": obj.get("contextType"),
103
105
  "landingUrl": SocialContextLandingUrl.from_dict(obj["landingUrl"]) if obj.get("landingUrl") is not None else None,
104
106
  "text": obj.get("text"),
@@ -0,0 +1,102 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Twitter OpenAPI
5
+
6
+ Twitter OpenAPI(Swagger) specification
7
+
8
+ The version of the OpenAPI document: 0.0.1
9
+ Contact: yuki@yuki0311.com
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, field_validator
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing_extensions import Annotated
24
+ from twitter_openapi_python_generated.models.instruction_type import InstructionType
25
+ from typing import Optional, Set
26
+ from typing_extensions import Self
27
+
28
+ class TimelineMarkEntriesUnreadGreaterThanSortIndex(BaseModel):
29
+ """
30
+ TimelineMarkEntriesUnreadGreaterThanSortIndex
31
+ """ # noqa: E501
32
+ sort_index: Optional[Annotated[str, Field(strict=True)]] = None
33
+ type: InstructionType
34
+ __properties: ClassVar[List[str]] = ["sort_index", "type"]
35
+
36
+ @field_validator('sort_index')
37
+ def sort_index_validate_regular_expression(cls, value):
38
+ """Validates the regular expression"""
39
+ if value is None:
40
+ return value
41
+
42
+ if not re.match(r"[0-9]+$", value):
43
+ raise ValueError(r"must validate the regular expression /[0-9]+$/")
44
+ return value
45
+
46
+ model_config = ConfigDict(
47
+ populate_by_name=True,
48
+ validate_assignment=True,
49
+ protected_namespaces=(),
50
+ )
51
+
52
+
53
+ def to_str(self) -> str:
54
+ """Returns the string representation of the model using alias"""
55
+ return pprint.pformat(self.model_dump(by_alias=True))
56
+
57
+ def to_json(self) -> str:
58
+ """Returns the JSON representation of the model using alias"""
59
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
60
+ return json.dumps(self.to_dict())
61
+
62
+ @classmethod
63
+ def from_json(cls, json_str: str) -> Optional[Self]:
64
+ """Create an instance of TimelineMarkEntriesUnreadGreaterThanSortIndex from a JSON string"""
65
+ return cls.from_dict(json.loads(json_str))
66
+
67
+ def to_dict(self) -> Dict[str, Any]:
68
+ """Return the dictionary representation of the model using alias.
69
+
70
+ This has the following differences from calling pydantic's
71
+ `self.model_dump(by_alias=True)`:
72
+
73
+ * `None` is only added to the output dict for nullable fields that
74
+ were set at model initialization. Other fields with value `None`
75
+ are ignored.
76
+ """
77
+ excluded_fields: Set[str] = set([
78
+ ])
79
+
80
+ _dict = self.model_dump(
81
+ by_alias=True,
82
+ exclude=excluded_fields,
83
+ exclude_none=True,
84
+ )
85
+ return _dict
86
+
87
+ @classmethod
88
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
89
+ """Create an instance of TimelineMarkEntriesUnreadGreaterThanSortIndex from a dict"""
90
+ if obj is None:
91
+ return None
92
+
93
+ if not isinstance(obj, dict):
94
+ return cls.model_validate(obj)
95
+
96
+ _obj = cls.model_validate({
97
+ "sort_index": obj.get("sort_index"),
98
+ "type": obj.get("type")
99
+ })
100
+ return _obj
101
+
102
+
@@ -0,0 +1,116 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Twitter OpenAPI
5
+
6
+ Twitter OpenAPI(Swagger) specification
7
+
8
+ The version of the OpenAPI document: 0.0.1
9
+ Contact: yuki@yuki0311.com
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, StrictStr
22
+ from typing import Any, ClassVar, Dict, List
23
+ from twitter_openapi_python_generated.models.content_item_type import ContentItemType
24
+ from twitter_openapi_python_generated.models.notification_template import NotificationTemplate
25
+ from twitter_openapi_python_generated.models.rich_message import RichMessage
26
+ from twitter_openapi_python_generated.models.social_context_landing_url import SocialContextLandingUrl
27
+ from twitter_openapi_python_generated.models.type_name import TypeName
28
+ from typing import Optional, Set
29
+ from typing_extensions import Self
30
+
31
+ class TimelineNotification(BaseModel):
32
+ """
33
+ TimelineNotification
34
+ """ # noqa: E501
35
+ typename: TypeName = Field(alias="__typename")
36
+ id: StrictStr
37
+ item_type: ContentItemType = Field(alias="itemType")
38
+ notification_icon: StrictStr
39
+ notification_url: SocialContextLandingUrl
40
+ rich_message: RichMessage
41
+ template: NotificationTemplate
42
+ timestamp_ms: StrictStr
43
+ __properties: ClassVar[List[str]] = ["__typename", "id", "itemType", "notification_icon", "notification_url", "rich_message", "template", "timestamp_ms"]
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 TimelineNotification 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 notification_url
85
+ if self.notification_url:
86
+ _dict['notification_url'] = self.notification_url.to_dict()
87
+ # override the default output from pydantic by calling `to_dict()` of rich_message
88
+ if self.rich_message:
89
+ _dict['rich_message'] = self.rich_message.to_dict()
90
+ # override the default output from pydantic by calling `to_dict()` of template
91
+ if self.template:
92
+ _dict['template'] = self.template.to_dict()
93
+ return _dict
94
+
95
+ @classmethod
96
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
97
+ """Create an instance of TimelineNotification from a dict"""
98
+ if obj is None:
99
+ return None
100
+
101
+ if not isinstance(obj, dict):
102
+ return cls.model_validate(obj)
103
+
104
+ _obj = cls.model_validate({
105
+ "__typename": obj.get("__typename"),
106
+ "id": obj.get("id"),
107
+ "itemType": obj.get("itemType"),
108
+ "notification_icon": obj.get("notification_icon"),
109
+ "notification_url": SocialContextLandingUrl.from_dict(obj["notification_url"]) if obj.get("notification_url") is not None else None,
110
+ "rich_message": RichMessage.from_dict(obj["rich_message"]) if obj.get("rich_message") is not None else None,
111
+ "template": NotificationTemplate.from_dict(obj["template"]) if obj.get("template") is not None else None,
112
+ "timestamp_ms": obj.get("timestamp_ms")
113
+ })
114
+ return _obj
115
+
116
+