diff --git a/line-openapi b/line-openapi index 4d9979bb3..571a258e0 160000 --- a/line-openapi +++ b/line-openapi @@ -1 +1 @@ -Subproject commit 4d9979bb3afa2798fa7dcc489f0fde023a8b25dd +Subproject commit 571a258e0443da9009266c8e119f14229c0b81b6 diff --git a/linebot/v3/messaging/__init__.py b/linebot/v3/messaging/__init__.py index cae8d98b1..d050ec198 100644 --- a/linebot/v3/messaging/__init__.py +++ b/linebot/v3/messaging/__init__.py @@ -38,6 +38,7 @@ from linebot.v3.messaging.models.action import Action from linebot.v3.messaging.models.age_demographic import AgeDemographic from linebot.v3.messaging.models.age_demographic_filter import AgeDemographicFilter +from linebot.v3.messaging.models.all_mention_target import AllMentionTarget from linebot.v3.messaging.models.alt_uri import AltUri from linebot.v3.messaging.models.app_type_demographic import AppTypeDemographic from linebot.v3.messaging.models.app_type_demographic_filter import AppTypeDemographicFilter @@ -61,6 +62,7 @@ from linebot.v3.messaging.models.datetime_picker_action import DatetimePickerAction from linebot.v3.messaging.models.demographic_filter import DemographicFilter from linebot.v3.messaging.models.emoji import Emoji +from linebot.v3.messaging.models.emoji_substitution_object import EmojiSubstitutionObject from linebot.v3.messaging.models.error_detail import ErrorDetail from linebot.v3.messaging.models.error_response import ErrorResponse from linebot.v3.messaging.models.filter import Filter @@ -120,6 +122,8 @@ from linebot.v3.messaging.models.members_ids_response import MembersIdsResponse from linebot.v3.messaging.models.membership import Membership from linebot.v3.messaging.models.membership_list_response import MembershipListResponse +from linebot.v3.messaging.models.mention_substitution_object import MentionSubstitutionObject +from linebot.v3.messaging.models.mention_target import MentionTarget from linebot.v3.messaging.models.message import Message from linebot.v3.messaging.models.message_action import MessageAction from linebot.v3.messaging.models.message_imagemap_action import MessageImagemapAction @@ -173,6 +177,7 @@ from linebot.v3.messaging.models.subscription import Subscription from linebot.v3.messaging.models.subscription_period_demographic import SubscriptionPeriodDemographic from linebot.v3.messaging.models.subscription_period_demographic_filter import SubscriptionPeriodDemographicFilter +from linebot.v3.messaging.models.substitution_object import SubstitutionObject from linebot.v3.messaging.models.template import Template from linebot.v3.messaging.models.template_image_aspect_ratio import TemplateImageAspectRatio from linebot.v3.messaging.models.template_image_size import TemplateImageSize @@ -180,9 +185,11 @@ from linebot.v3.messaging.models.test_webhook_endpoint_request import TestWebhookEndpointRequest from linebot.v3.messaging.models.test_webhook_endpoint_response import TestWebhookEndpointResponse from linebot.v3.messaging.models.text_message import TextMessage +from linebot.v3.messaging.models.text_message_v2 import TextMessageV2 from linebot.v3.messaging.models.uri_action import URIAction from linebot.v3.messaging.models.uri_imagemap_action import URIImagemapAction from linebot.v3.messaging.models.update_rich_menu_alias_request import UpdateRichMenuAliasRequest +from linebot.v3.messaging.models.user_mention_target import UserMentionTarget from linebot.v3.messaging.models.user_profile_response import UserProfileResponse from linebot.v3.messaging.models.validate_message_request import ValidateMessageRequest from linebot.v3.messaging.models.video_message import VideoMessage diff --git a/linebot/v3/messaging/models/__init__.py b/linebot/v3/messaging/models/__init__.py index 93ea4df70..63a262dae 100644 --- a/linebot/v3/messaging/models/__init__.py +++ b/linebot/v3/messaging/models/__init__.py @@ -17,6 +17,7 @@ from linebot.v3.messaging.models.action import Action from linebot.v3.messaging.models.age_demographic import AgeDemographic from linebot.v3.messaging.models.age_demographic_filter import AgeDemographicFilter +from linebot.v3.messaging.models.all_mention_target import AllMentionTarget from linebot.v3.messaging.models.alt_uri import AltUri from linebot.v3.messaging.models.app_type_demographic import AppTypeDemographic from linebot.v3.messaging.models.app_type_demographic_filter import AppTypeDemographicFilter @@ -40,6 +41,7 @@ from linebot.v3.messaging.models.datetime_picker_action import DatetimePickerAction from linebot.v3.messaging.models.demographic_filter import DemographicFilter from linebot.v3.messaging.models.emoji import Emoji +from linebot.v3.messaging.models.emoji_substitution_object import EmojiSubstitutionObject from linebot.v3.messaging.models.error_detail import ErrorDetail from linebot.v3.messaging.models.error_response import ErrorResponse from linebot.v3.messaging.models.filter import Filter @@ -99,6 +101,8 @@ from linebot.v3.messaging.models.members_ids_response import MembersIdsResponse from linebot.v3.messaging.models.membership import Membership from linebot.v3.messaging.models.membership_list_response import MembershipListResponse +from linebot.v3.messaging.models.mention_substitution_object import MentionSubstitutionObject +from linebot.v3.messaging.models.mention_target import MentionTarget from linebot.v3.messaging.models.message import Message from linebot.v3.messaging.models.message_action import MessageAction from linebot.v3.messaging.models.message_imagemap_action import MessageImagemapAction @@ -152,6 +156,7 @@ from linebot.v3.messaging.models.subscription import Subscription from linebot.v3.messaging.models.subscription_period_demographic import SubscriptionPeriodDemographic from linebot.v3.messaging.models.subscription_period_demographic_filter import SubscriptionPeriodDemographicFilter +from linebot.v3.messaging.models.substitution_object import SubstitutionObject from linebot.v3.messaging.models.template import Template from linebot.v3.messaging.models.template_image_aspect_ratio import TemplateImageAspectRatio from linebot.v3.messaging.models.template_image_size import TemplateImageSize @@ -159,9 +164,11 @@ from linebot.v3.messaging.models.test_webhook_endpoint_request import TestWebhookEndpointRequest from linebot.v3.messaging.models.test_webhook_endpoint_response import TestWebhookEndpointResponse from linebot.v3.messaging.models.text_message import TextMessage +from linebot.v3.messaging.models.text_message_v2 import TextMessageV2 from linebot.v3.messaging.models.uri_action import URIAction from linebot.v3.messaging.models.uri_imagemap_action import URIImagemapAction from linebot.v3.messaging.models.update_rich_menu_alias_request import UpdateRichMenuAliasRequest +from linebot.v3.messaging.models.user_mention_target import UserMentionTarget from linebot.v3.messaging.models.user_profile_response import UserProfileResponse from linebot.v3.messaging.models.validate_message_request import ValidateMessageRequest from linebot.v3.messaging.models.video_message import VideoMessage diff --git a/linebot/v3/messaging/models/all_mention_target.py b/linebot/v3/messaging/models/all_mention_target.py new file mode 100644 index 000000000..c0810061d --- /dev/null +++ b/linebot/v3/messaging/models/all_mention_target.py @@ -0,0 +1,73 @@ +# coding: utf-8 + +""" + LINE Messaging API + + This document describes LINE Messaging API. # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + + + +from linebot.v3.messaging.models.mention_target import MentionTarget + +class AllMentionTarget(MentionTarget): + """ + AllMentionTarget + https://developers.line.biz/en/reference/messaging-api/#text-message-v2-mentionee-all + """ + type: str = "all" + + __properties = ["type"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> AllMentionTarget: + """Create an instance of AllMentionTarget from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> AllMentionTarget: + """Create an instance of AllMentionTarget from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AllMentionTarget.parse_obj(obj) + + _obj = AllMentionTarget.parse_obj({ + "type": obj.get("type") + }) + return _obj + diff --git a/linebot/v3/messaging/models/emoji_substitution_object.py b/linebot/v3/messaging/models/emoji_substitution_object.py new file mode 100644 index 000000000..e61ee0342 --- /dev/null +++ b/linebot/v3/messaging/models/emoji_substitution_object.py @@ -0,0 +1,77 @@ +# coding: utf-8 + +""" + LINE Messaging API + + This document describes LINE Messaging API. # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Optional +from pydantic.v1 import Field, StrictStr +from linebot.v3.messaging.models.substitution_object import SubstitutionObject + +class EmojiSubstitutionObject(SubstitutionObject): + """ + An object representing a emoji substitution. + https://developers.line.biz/en/reference/messaging-api/#text-message-v2-emoji-object + """ + product_id: Optional[StrictStr] = Field(None, alias="productId") + emoji_id: Optional[StrictStr] = Field(None, alias="emojiId") + type: str = "emoji" + + __properties = ["type", "productId", "emojiId"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> EmojiSubstitutionObject: + """Create an instance of EmojiSubstitutionObject from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> EmojiSubstitutionObject: + """Create an instance of EmojiSubstitutionObject from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return EmojiSubstitutionObject.parse_obj(obj) + + _obj = EmojiSubstitutionObject.parse_obj({ + "type": obj.get("type"), + "product_id": obj.get("productId"), + "emoji_id": obj.get("emojiId") + }) + return _obj + diff --git a/linebot/v3/messaging/models/mention_substitution_object.py b/linebot/v3/messaging/models/mention_substitution_object.py new file mode 100644 index 000000000..646c9adb5 --- /dev/null +++ b/linebot/v3/messaging/models/mention_substitution_object.py @@ -0,0 +1,79 @@ +# coding: utf-8 + +""" + LINE Messaging API + + This document describes LINE Messaging API. # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Optional + +from linebot.v3.messaging.models.mention_target import MentionTarget +from linebot.v3.messaging.models.substitution_object import SubstitutionObject + +class MentionSubstitutionObject(SubstitutionObject): + """ + An object representing a mention substitution. + https://developers.line.biz/en/reference/messaging-api/#text-message-v2-mention-object + """ + mentionee: Optional[MentionTarget] = None + type: str = "mention" + + __properties = ["type", "mentionee"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> MentionSubstitutionObject: + """Create an instance of MentionSubstitutionObject from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + # override the default output from pydantic.v1 by calling `to_dict()` of mentionee + if self.mentionee: + _dict['mentionee'] = self.mentionee.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> MentionSubstitutionObject: + """Create an instance of MentionSubstitutionObject from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return MentionSubstitutionObject.parse_obj(obj) + + _obj = MentionSubstitutionObject.parse_obj({ + "type": obj.get("type"), + "mentionee": MentionTarget.from_dict(obj.get("mentionee")) if obj.get("mentionee") is not None else None + }) + return _obj + diff --git a/linebot/v3/messaging/models/mention_target.py b/linebot/v3/messaging/models/mention_target.py new file mode 100644 index 000000000..13c3b55b1 --- /dev/null +++ b/linebot/v3/messaging/models/mention_target.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + LINE Messaging API + + This document describes LINE Messaging API. # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json +import linebot.v3.messaging.models + + +from typing import Union +from pydantic.v1 import BaseModel, Field, StrictStr + +class MentionTarget(BaseModel): + """ + MentionTarget + """ + type: StrictStr = Field(..., description="Target to be mentioned") + + __properties = ["type"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + # JSON field name that stores the object type + __discriminator_property_name = 'type' + + # discriminator mappings + __discriminator_value_class_map = { + 'all': 'AllMentionTarget', + 'user': 'UserMentionTarget' + } + + @classmethod + def get_discriminator_value(cls, obj: dict) -> str: + """Returns the discriminator value (object type) of the data""" + discriminator_value = obj[cls.__discriminator_property_name] + if discriminator_value: + return cls.__discriminator_value_class_map.get(discriminator_value) + else: + return None + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Union(AllMentionTarget, UserMentionTarget): + """Create an instance of MentionTarget from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Union(AllMentionTarget, UserMentionTarget): + """Create an instance of MentionTarget from a dict""" + # look up the object type based on discriminator mapping + object_type = cls.get_discriminator_value(obj) + if object_type: + klass = getattr(linebot.v3.messaging.models, object_type) + return klass.from_dict(obj) + else: + raise ValueError("MentionTarget failed to lookup discriminator value from " + + json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + + ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) + diff --git a/linebot/v3/messaging/models/message.py b/linebot/v3/messaging/models/message.py index 8a38f0ddd..c792f804f 100644 --- a/linebot/v3/messaging/models/message.py +++ b/linebot/v3/messaging/models/message.py @@ -53,6 +53,7 @@ class Config: 'sticker': 'StickerMessage', 'template': 'TemplateMessage', 'text': 'TextMessage', + 'textV2': 'TextMessageV2', 'video': 'VideoMessage' } @@ -74,7 +75,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Union(AudioMessage, FlexMessage, ImageMessage, ImagemapMessage, LocationMessage, StickerMessage, TemplateMessage, TextMessage, VideoMessage): + def from_json(cls, json_str: str) -> Union(AudioMessage, FlexMessage, ImageMessage, ImagemapMessage, LocationMessage, StickerMessage, TemplateMessage, TextMessage, TextMessageV2, VideoMessage): """Create an instance of Message from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -93,7 +94,7 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Union(AudioMessage, FlexMessage, ImageMessage, ImagemapMessage, LocationMessage, StickerMessage, TemplateMessage, TextMessage, VideoMessage): + def from_dict(cls, obj: dict) -> Union(AudioMessage, FlexMessage, ImageMessage, ImagemapMessage, LocationMessage, StickerMessage, TemplateMessage, TextMessage, TextMessageV2, VideoMessage): """Create an instance of Message from a dict""" # look up the object type based on discriminator mapping object_type = cls.get_discriminator_value(obj) diff --git a/linebot/v3/messaging/models/substitution_object.py b/linebot/v3/messaging/models/substitution_object.py new file mode 100644 index 000000000..ea69e951c --- /dev/null +++ b/linebot/v3/messaging/models/substitution_object.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + LINE Messaging API + + This document describes LINE Messaging API. # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json +import linebot.v3.messaging.models + + +from typing import Union +from pydantic.v1 import BaseModel, Field, StrictStr + +class SubstitutionObject(BaseModel): + """ + An object that defines the replacement value for a placeholder in the text. + """ + type: StrictStr = Field(..., description="Type of substitution object") + + __properties = ["type"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + # JSON field name that stores the object type + __discriminator_property_name = 'type' + + # discriminator mappings + __discriminator_value_class_map = { + 'emoji': 'EmojiSubstitutionObject', + 'mention': 'MentionSubstitutionObject' + } + + @classmethod + def get_discriminator_value(cls, obj: dict) -> str: + """Returns the discriminator value (object type) of the data""" + discriminator_value = obj[cls.__discriminator_property_name] + if discriminator_value: + return cls.__discriminator_value_class_map.get(discriminator_value) + else: + return None + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Union(EmojiSubstitutionObject, MentionSubstitutionObject): + """Create an instance of SubstitutionObject from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Union(EmojiSubstitutionObject, MentionSubstitutionObject): + """Create an instance of SubstitutionObject from a dict""" + # look up the object type based on discriminator mapping + object_type = cls.get_discriminator_value(obj) + if object_type: + klass = getattr(linebot.v3.messaging.models, object_type) + return klass.from_dict(obj) + else: + raise ValueError("SubstitutionObject failed to lookup discriminator value from " + + json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + + ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) + diff --git a/linebot/v3/messaging/models/text_message_v2.py b/linebot/v3/messaging/models/text_message_v2.py new file mode 100644 index 000000000..e50f69c85 --- /dev/null +++ b/linebot/v3/messaging/models/text_message_v2.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + LINE Messaging API + + This document describes LINE Messaging API. # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Dict, Optional +from pydantic.v1 import Field, StrictStr +from linebot.v3.messaging.models.dict[str,_substitution_object] import Dict[str, SubstitutionObject] +from linebot.v3.messaging.models.message import Message +from linebot.v3.messaging.models.quick_reply import QuickReply +from linebot.v3.messaging.models.sender import Sender +from linebot.v3.messaging.models.substitution_object import SubstitutionObject + +class TextMessageV2(Message): + """ + TextMessageV2 + https://developers.line.biz/en/reference/messaging-api/#text-message-v2 + """ + text: StrictStr = Field(...) + substitution: Optional[Dict[str, SubstitutionObject]] = Field(None, description="A mapping that specifies substitutions for parts enclosed in {} within the 'text' field.") + quote_token: Optional[StrictStr] = Field(None, alias="quoteToken", description="Quote token of the message you want to quote.") + type: str = "textV2" + + __properties = ["type", "quickReply", "sender", "text", "substitution", "quoteToken"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> TextMessageV2: + """Create an instance of TextMessageV2 from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + # override the default output from pydantic.v1 by calling `to_dict()` of quick_reply + if self.quick_reply: + _dict['quickReply'] = self.quick_reply.to_dict() + # override the default output from pydantic.v1 by calling `to_dict()` of sender + if self.sender: + _dict['sender'] = self.sender.to_dict() + # override the default output from pydantic.v1 by calling `to_dict()` of each value in substitution (dict) + _field_dict = {} + if self.substitution: + for _key in self.substitution: + if self.substitution[_key]: + _field_dict[_key] = self.substitution[_key].to_dict() + _dict['substitution'] = _field_dict + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> TextMessageV2: + """Create an instance of TextMessageV2 from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return TextMessageV2.parse_obj(obj) + + _obj = TextMessageV2.parse_obj({ + "type": obj.get("type"), + "quick_reply": QuickReply.from_dict(obj.get("quickReply")) if obj.get("quickReply") is not None else None, + "sender": Sender.from_dict(obj.get("sender")) if obj.get("sender") is not None else None, + "text": obj.get("text"), + "substitution": dict( + (_k, SubstitutionObject.from_dict(_v)) + for _k, _v in obj.get("substitution").items() + ) + if obj.get("substitution") is not None + else None, + "quote_token": obj.get("quoteToken") + }) + return _obj + diff --git a/linebot/v3/messaging/models/user_mention_target.py b/linebot/v3/messaging/models/user_mention_target.py new file mode 100644 index 000000000..566aca1f8 --- /dev/null +++ b/linebot/v3/messaging/models/user_mention_target.py @@ -0,0 +1,75 @@ +# coding: utf-8 + +""" + LINE Messaging API + + This document describes LINE Messaging API. # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + + +from pydantic.v1 import Field, StrictStr +from linebot.v3.messaging.models.mention_target import MentionTarget + +class UserMentionTarget(MentionTarget): + """ + UserMentionTarget + https://developers.line.biz/en/reference/messaging-api/#text-message-v2-mentionee-user + """ + user_id: StrictStr = Field(..., alias="userId") + type: str = "user" + + __properties = ["type", "userId"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> UserMentionTarget: + """Create an instance of UserMentionTarget from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> UserMentionTarget: + """Create an instance of UserMentionTarget from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return UserMentionTarget.parse_obj(obj) + + _obj = UserMentionTarget.parse_obj({ + "type": obj.get("type"), + "user_id": obj.get("userId") + }) + return _obj + diff --git a/linebot/v3/webhooks/models/user_mentionee.py b/linebot/v3/webhooks/models/user_mentionee.py index 2bb201152..aa54d3905 100644 --- a/linebot/v3/webhooks/models/user_mentionee.py +++ b/linebot/v3/webhooks/models/user_mentionee.py @@ -19,7 +19,7 @@ from typing import Optional -from pydantic.v1 import Field, StrictStr +from pydantic.v1 import Field, StrictBool, StrictStr from linebot.v3.webhooks.models.mentionee import Mentionee class UserMentionee(Mentionee): @@ -27,9 +27,10 @@ class UserMentionee(Mentionee): Mentioned target is user """ user_id: Optional[StrictStr] = Field(None, alias="userId", description="User ID of the mentioned user. Only included if mention.mentions[].type is user and the user consents to the LINE Official Account obtaining their user profile information.") + is_self: Optional[StrictBool] = Field(None, alias="isSelf", description="Whether the mentioned user is the bot that receives the webhook.") type: str = "user" - __properties = ["type", "index", "length", "userId"] + __properties = ["type", "index", "length", "userId", "isSelf"] class Config: """Pydantic configuration""" @@ -70,7 +71,8 @@ def from_dict(cls, obj: dict) -> UserMentionee: "type": obj.get("type"), "index": obj.get("index"), "length": obj.get("length"), - "user_id": obj.get("userId") + "user_id": obj.get("userId"), + "is_self": obj.get("isSelf") }) return _obj