From 2eac2cf4ea60c2f92a876e105d2649fc57cf117b Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 29 Sep 2026 04:22:42 +0000 Subject: [PATCH] Code are generated by openapi generator --- line-openapi | 2 +- linebot/v3/messaging/__init__.py | 5 + .../v3/messaging/api/async_messaging_api.py | 316 ++++++++++++++++++ linebot/v3/messaging/api/messaging_api.py | 296 ++++++++++++++++ linebot/v3/messaging/docs/MessagingApi.md | 153 +++++++++ linebot/v3/messaging/models/__init__.py | 5 + .../messaging/models/pnp_messages_request.py | 8 +- .../messaging/models/pnp_templated_button.py | 74 ++++ .../models/pnp_templated_emphasized_item.py | 74 ++++ .../v3/messaging/models/pnp_templated_item.py | 74 ++++ .../models/pnp_templated_message_body.py | 96 ++++++ .../models/pnp_templated_message_request.py | 82 +++++ 12 files changed, 1181 insertions(+), 4 deletions(-) create mode 100644 linebot/v3/messaging/models/pnp_templated_button.py create mode 100644 linebot/v3/messaging/models/pnp_templated_emphasized_item.py create mode 100644 linebot/v3/messaging/models/pnp_templated_item.py create mode 100644 linebot/v3/messaging/models/pnp_templated_message_body.py create mode 100644 linebot/v3/messaging/models/pnp_templated_message_request.py diff --git a/line-openapi b/line-openapi index de8bd9e28..fa5577c9e 160000 --- a/line-openapi +++ b/line-openapi @@ -1 +1 @@ -Subproject commit de8bd9e2872ed9d9800e23b86136695fcd370a0c +Subproject commit fa5577c9ea874d2dbd8fadc85a4cb3a1b29d8cbe diff --git a/linebot/v3/messaging/__init__.py b/linebot/v3/messaging/__init__.py index 19338cb0b..a9ff0d122 100644 --- a/linebot/v3/messaging/__init__.py +++ b/linebot/v3/messaging/__init__.py @@ -174,6 +174,11 @@ from linebot.v3.messaging.models.operator_demographic_filter import OperatorDemographicFilter from linebot.v3.messaging.models.operator_recipient import OperatorRecipient from linebot.v3.messaging.models.pnp_messages_request import PnpMessagesRequest +from linebot.v3.messaging.models.pnp_templated_button import PnpTemplatedButton +from linebot.v3.messaging.models.pnp_templated_emphasized_item import PnpTemplatedEmphasizedItem +from linebot.v3.messaging.models.pnp_templated_item import PnpTemplatedItem +from linebot.v3.messaging.models.pnp_templated_message_body import PnpTemplatedMessageBody +from linebot.v3.messaging.models.pnp_templated_message_request import PnpTemplatedMessageRequest from linebot.v3.messaging.models.postback_action import PostbackAction from linebot.v3.messaging.models.push_message_request import PushMessageRequest from linebot.v3.messaging.models.push_message_response import PushMessageResponse diff --git a/linebot/v3/messaging/api/async_messaging_api.py b/linebot/v3/messaging/api/async_messaging_api.py index 433e7956e..311ed482e 100644 --- a/linebot/v3/messaging/api/async_messaging_api.py +++ b/linebot/v3/messaging/api/async_messaging_api.py @@ -51,6 +51,7 @@ from linebot.v3.messaging.models.narrowcast_request import NarrowcastRequest from linebot.v3.messaging.models.number_of_messages_response import NumberOfMessagesResponse from linebot.v3.messaging.models.pnp_messages_request import PnpMessagesRequest +from linebot.v3.messaging.models.pnp_templated_message_request import PnpTemplatedMessageRequest from linebot.v3.messaging.models.push_message_request import PushMessageRequest from linebot.v3.messaging.models.push_message_response import PushMessageResponse from linebot.v3.messaging.models.quota_consumption_response import QuotaConsumptionResponse @@ -4499,6 +4500,157 @@ def get_pnp_message_statistics_with_http_info(self, var_date : Annotated[constr( collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @overload + async def get_pnp_templated_message_statistics(self, var_date : Annotated[constr(strict=True), Field(..., description="Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 ")], **kwargs) -> NumberOfMessagesResponse: # noqa: E501 + ... + + @overload + def get_pnp_templated_message_statistics(self, var_date : Annotated[constr(strict=True), Field(..., description="Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 ")], async_req: Optional[bool]=True, **kwargs) -> NumberOfMessagesResponse: # noqa: E501 + ... + + @validate_arguments + def get_pnp_templated_message_statistics(self, var_date : Annotated[constr(strict=True), Field(..., description="Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 ")], async_req: Optional[bool]=None, **kwargs) -> Union[NumberOfMessagesResponse, Awaitable[NumberOfMessagesResponse]]: # noqa: E501 + """get_pnp_templated_message_statistics # noqa: E501 + + Get number of sent LINE notification messages (template) # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_pnp_templated_message_statistics(var_date, async_req=True) + >>> result = thread.get() + + :param var_date: Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 (required) + :type var_date: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: NumberOfMessagesResponse + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + raise ValueError("Error! Please call the get_pnp_templated_message_statistics_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data") + if async_req is not None: + kwargs['async_req'] = async_req + return self.get_pnp_templated_message_statistics_with_http_info(var_date, **kwargs) # noqa: E501 + + @validate_arguments + def get_pnp_templated_message_statistics_with_http_info(self, var_date : Annotated[constr(strict=True), Field(..., description="Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 ")], **kwargs) -> ApiResponse: # noqa: E501 + """get_pnp_templated_message_statistics # noqa: E501 + + Get number of sent LINE notification messages (template) # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_pnp_templated_message_statistics_with_http_info(var_date, async_req=True) + >>> result = thread.get() + + :param var_date: Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 (required) + :type var_date: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(NumberOfMessagesResponse, status_code(int), headers(HTTPHeaderDict)) + """ + + _host = self.line_base_path + _params = locals() + + _all_params = [ + 'var_date' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_pnp_templated_message_statistics" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('var_date') is not None: # noqa: E501 + _query_params.append(('date', _params['var_date'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = ['Bearer'] # noqa: E501 + + _response_types_map = { + '200': "NumberOfMessagesResponse", + } + + return self.api_client.call_api( + '/v2/bot/message/delivery/pnp/templated', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + _host=_host, + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + @overload async def get_profile(self, user_id : Annotated[StrictStr, Field(..., description="User ID")], **kwargs) -> UserProfileResponse: # noqa: E501 ... @@ -8053,6 +8205,170 @@ def push_messages_by_phone_with_http_info(self, pnp_messages_request : PnpMessag collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @overload + async def push_templated_messages_by_phone(self, pnp_templated_message_request : PnpTemplatedMessageRequest, x_line_delivery_tag : Annotated[Optional[constr(strict=True, max_length=100, min_length=16)], Field(description="String returned in the delivery.data property of the delivery completion event via Webhook.")] = None, **kwargs) -> None: # noqa: E501 + ... + + @overload + def push_templated_messages_by_phone(self, pnp_templated_message_request : PnpTemplatedMessageRequest, x_line_delivery_tag : Annotated[Optional[constr(strict=True, max_length=100, min_length=16)], Field(description="String returned in the delivery.data property of the delivery completion event via Webhook.")] = None, async_req: Optional[bool]=True, **kwargs) -> None: # noqa: E501 + ... + + @validate_arguments + def push_templated_messages_by_phone(self, pnp_templated_message_request : PnpTemplatedMessageRequest, x_line_delivery_tag : Annotated[Optional[constr(strict=True, max_length=100, min_length=16)], Field(description="String returned in the delivery.data property of the delivery completion event via Webhook.")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[None, Awaitable[None]]: # noqa: E501 + """push_templated_messages_by_phone # noqa: E501 + + Send LINE notification message (template) # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.push_templated_messages_by_phone(pnp_templated_message_request, x_line_delivery_tag, async_req=True) + >>> result = thread.get() + + :param pnp_templated_message_request: (required) + :type pnp_templated_message_request: PnpTemplatedMessageRequest + :param x_line_delivery_tag: String returned in the delivery.data property of the delivery completion event via Webhook. + :type x_line_delivery_tag: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + raise ValueError("Error! Please call the push_templated_messages_by_phone_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data") + if async_req is not None: + kwargs['async_req'] = async_req + return self.push_templated_messages_by_phone_with_http_info(pnp_templated_message_request, x_line_delivery_tag, **kwargs) # noqa: E501 + + @validate_arguments + def push_templated_messages_by_phone_with_http_info(self, pnp_templated_message_request : PnpTemplatedMessageRequest, x_line_delivery_tag : Annotated[Optional[constr(strict=True, max_length=100, min_length=16)], Field(description="String returned in the delivery.data property of the delivery completion event via Webhook.")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """push_templated_messages_by_phone # noqa: E501 + + Send LINE notification message (template) # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.push_templated_messages_by_phone_with_http_info(pnp_templated_message_request, x_line_delivery_tag, async_req=True) + >>> result = thread.get() + + :param pnp_templated_message_request: (required) + :type pnp_templated_message_request: PnpTemplatedMessageRequest + :param x_line_delivery_tag: String returned in the delivery.data property of the delivery completion event via Webhook. + :type x_line_delivery_tag: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _host = self.line_base_path + _params = locals() + + _all_params = [ + 'pnp_templated_message_request', + 'x_line_delivery_tag' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method push_templated_messages_by_phone" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + if _params['x_line_delivery_tag']: + _header_params['X-Line-Delivery-Tag'] = _params['x_line_delivery_tag'] + + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['pnp_templated_message_request'] is not None: + _body_params = _params['pnp_templated_message_request'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = ['Bearer'] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/v2/bot/message/pnp/templated/push', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + _host=_host, + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + @overload async def reply_message(self, reply_message_request : ReplyMessageRequest, **kwargs) -> ReplyMessageResponse: # noqa: E501 ... diff --git a/linebot/v3/messaging/api/messaging_api.py b/linebot/v3/messaging/api/messaging_api.py index b364179bb..fce6d9029 100644 --- a/linebot/v3/messaging/api/messaging_api.py +++ b/linebot/v3/messaging/api/messaging_api.py @@ -49,6 +49,7 @@ from linebot.v3.messaging.models.narrowcast_request import NarrowcastRequest from linebot.v3.messaging.models.number_of_messages_response import NumberOfMessagesResponse from linebot.v3.messaging.models.pnp_messages_request import PnpMessagesRequest +from linebot.v3.messaging.models.pnp_templated_message_request import PnpTemplatedMessageRequest from linebot.v3.messaging.models.push_message_request import PushMessageRequest from linebot.v3.messaging.models.push_message_response import PushMessageResponse from linebot.v3.messaging.models.quota_consumption_response import QuotaConsumptionResponse @@ -4207,6 +4208,147 @@ def get_pnp_message_statistics_with_http_info(self, var_date : Annotated[constr( collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @validate_arguments + def get_pnp_templated_message_statistics(self, var_date : Annotated[constr(strict=True), Field(..., description="Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 ")], **kwargs) -> NumberOfMessagesResponse: # noqa: E501 + """get_pnp_templated_message_statistics # noqa: E501 + + Get number of sent LINE notification messages (template) # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_pnp_templated_message_statistics(var_date, async_req=True) + >>> result = thread.get() + + :param var_date: Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 (required) + :type var_date: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: NumberOfMessagesResponse + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + raise ValueError("Error! Please call the get_pnp_templated_message_statistics_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data") + return self.get_pnp_templated_message_statistics_with_http_info(var_date, **kwargs) # noqa: E501 + + @validate_arguments + def get_pnp_templated_message_statistics_with_http_info(self, var_date : Annotated[constr(strict=True), Field(..., description="Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 ")], **kwargs) -> ApiResponse: # noqa: E501 + """get_pnp_templated_message_statistics # noqa: E501 + + Get number of sent LINE notification messages (template) # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_pnp_templated_message_statistics_with_http_info(var_date, async_req=True) + >>> result = thread.get() + + :param var_date: Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 (required) + :type var_date: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(NumberOfMessagesResponse, status_code(int), headers(HTTPHeaderDict)) + """ + + _host = self.line_base_path + _params = locals() + + _all_params = [ + 'var_date' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method get_pnp_templated_message_statistics" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + if _params.get('var_date') is not None: # noqa: E501 + _query_params.append(('date', _params['var_date'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = ['Bearer'] # noqa: E501 + + _response_types_map = { + '200': "NumberOfMessagesResponse", + } + + return self.api_client.call_api( + '/v2/bot/message/delivery/pnp/templated', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + _host=_host, + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + @validate_arguments def get_profile(self, user_id : Annotated[StrictStr, Field(..., description="User ID")], **kwargs) -> UserProfileResponse: # noqa: E501 """get_profile # noqa: E501 @@ -7531,6 +7673,160 @@ def push_messages_by_phone_with_http_info(self, pnp_messages_request : PnpMessag collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @validate_arguments + def push_templated_messages_by_phone(self, pnp_templated_message_request : PnpTemplatedMessageRequest, x_line_delivery_tag : Annotated[Optional[constr(strict=True, max_length=100, min_length=16)], Field(description="String returned in the delivery.data property of the delivery completion event via Webhook.")] = None, **kwargs) -> None: # noqa: E501 + """push_templated_messages_by_phone # noqa: E501 + + Send LINE notification message (template) # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.push_templated_messages_by_phone(pnp_templated_message_request, x_line_delivery_tag, async_req=True) + >>> result = thread.get() + + :param pnp_templated_message_request: (required) + :type pnp_templated_message_request: PnpTemplatedMessageRequest + :param x_line_delivery_tag: String returned in the delivery.data property of the delivery completion event via Webhook. + :type x_line_delivery_tag: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + raise ValueError("Error! Please call the push_templated_messages_by_phone_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data") + return self.push_templated_messages_by_phone_with_http_info(pnp_templated_message_request, x_line_delivery_tag, **kwargs) # noqa: E501 + + @validate_arguments + def push_templated_messages_by_phone_with_http_info(self, pnp_templated_message_request : PnpTemplatedMessageRequest, x_line_delivery_tag : Annotated[Optional[constr(strict=True, max_length=100, min_length=16)], Field(description="String returned in the delivery.data property of the delivery completion event via Webhook.")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """push_templated_messages_by_phone # noqa: E501 + + Send LINE notification message (template) # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.push_templated_messages_by_phone_with_http_info(pnp_templated_message_request, x_line_delivery_tag, async_req=True) + >>> result = thread.get() + + :param pnp_templated_message_request: (required) + :type pnp_templated_message_request: PnpTemplatedMessageRequest + :param x_line_delivery_tag: String returned in the delivery.data property of the delivery completion event via Webhook. + :type x_line_delivery_tag: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _host = self.line_base_path + _params = locals() + + _all_params = [ + 'pnp_templated_message_request', + 'x_line_delivery_tag' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method push_templated_messages_by_phone" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + if _params['x_line_delivery_tag']: + _header_params['X-Line-Delivery-Tag'] = _params['x_line_delivery_tag'] + + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['pnp_templated_message_request'] is not None: + _body_params = _params['pnp_templated_message_request'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = ['Bearer'] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/v2/bot/message/pnp/templated/push', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + _host=_host, + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + @validate_arguments def reply_message(self, reply_message_request : ReplyMessageRequest, **kwargs) -> ReplyMessageResponse: # noqa: E501 """reply_message # noqa: E501 diff --git a/linebot/v3/messaging/docs/MessagingApi.md b/linebot/v3/messaging/docs/MessagingApi.md index 29a80e0fb..569f40285 100644 --- a/linebot/v3/messaging/docs/MessagingApi.md +++ b/linebot/v3/messaging/docs/MessagingApi.md @@ -33,6 +33,7 @@ Method | HTTP request | Description [**get_number_of_sent_push_messages**](MessagingApi.md#get_number_of_sent_push_messages) | **GET** /v2/bot/message/delivery/push | [**get_number_of_sent_reply_messages**](MessagingApi.md#get_number_of_sent_reply_messages) | **GET** /v2/bot/message/delivery/reply | [**get_pnp_message_statistics**](MessagingApi.md#get_pnp_message_statistics) | **GET** /v2/bot/message/delivery/pnp | +[**get_pnp_templated_message_statistics**](MessagingApi.md#get_pnp_templated_message_statistics) | **GET** /v2/bot/message/delivery/pnp/templated | [**get_profile**](MessagingApi.md#get_profile) | **GET** /v2/bot/profile/{userId} | [**get_rich_menu**](MessagingApi.md#get_rich_menu) | **GET** /v2/bot/richmenu/{richMenuId} | [**get_rich_menu_alias**](MessagingApi.md#get_rich_menu_alias) | **GET** /v2/bot/richmenu/alias/{richMenuAliasId} | @@ -56,6 +57,7 @@ Method | HTTP request | Description [**narrowcast**](MessagingApi.md#narrowcast) | **POST** /v2/bot/message/narrowcast | [**push_message**](MessagingApi.md#push_message) | **POST** /v2/bot/message/push | [**push_messages_by_phone**](MessagingApi.md#push_messages_by_phone) | **POST** /bot/pnp/push | +[**push_templated_messages_by_phone**](MessagingApi.md#push_templated_messages_by_phone) | **POST** /v2/bot/message/pnp/templated/push | [**reply_message**](MessagingApi.md#reply_message) | **POST** /v2/bot/message/reply | [**rich_menu_batch**](MessagingApi.md#rich_menu_batch) | **POST** /v2/bot/richmenu/batch | [**set_default_rich_menu**](MessagingApi.md#set_default_rich_menu) | **POST** /v2/bot/user/all/richmenu/{richMenuId} | @@ -2214,6 +2216,81 @@ with linebot.v3.messaging.ApiClient(configuration) as api_client: ``` +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **var_date** | **str**| Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 | + +### Return type + +[**NumberOfMessagesResponse**](NumberOfMessagesResponse.md) + +### Authorization + +[Bearer](../README.md#Bearer) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_pnp_templated_message_statistics** +> NumberOfMessagesResponse get_pnp_templated_message_statistics(var_date) + + + +Get number of sent LINE notification messages (template) + +### Example + +* Bearer Authentication (Bearer): +```python +import time +import os +import linebot.v3.messaging +from linebot.v3.messaging.models.number_of_messages_response import NumberOfMessagesResponse +from linebot.v3.messaging.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://api.line.me +# See configuration.py for a list of all supported configuration parameters. +configuration = linebot.v3.messaging.Configuration( + host = "https://api.line.me" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure Bearer authorization: Bearer +configuration = linebot.v3.messaging.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with linebot.v3.messaging.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = linebot.v3.messaging.MessagingApi(api_client) + var_date = 'var_date_example' # str | Date the message was sent Format: `yyyyMMdd` (Example:`20211231`) Time zone: UTC+9 + + try: + api_response = api_instance.get_pnp_templated_message_statistics(var_date) + print("The response of MessagingApi->get_pnp_templated_message_statistics:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling MessagingApi->get_pnp_templated_message_statistics: %s\n" % e) +``` + + ### Parameters Name | Type | Description | Notes @@ -3972,6 +4049,82 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **push_templated_messages_by_phone** +> push_templated_messages_by_phone(pnp_templated_message_request, x_line_delivery_tag=x_line_delivery_tag) + + + +Send LINE notification message (template) + +### Example + +* Bearer Authentication (Bearer): +```python +import time +import os +import linebot.v3.messaging +from linebot.v3.messaging.models.pnp_templated_message_request import PnpTemplatedMessageRequest +from linebot.v3.messaging.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://api.line.me +# See configuration.py for a list of all supported configuration parameters. +configuration = linebot.v3.messaging.Configuration( + host = "https://api.line.me" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure Bearer authorization: Bearer +configuration = linebot.v3.messaging.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with linebot.v3.messaging.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = linebot.v3.messaging.MessagingApi(api_client) + pnp_templated_message_request = linebot.v3.messaging.PnpTemplatedMessageRequest() # PnpTemplatedMessageRequest | + x_line_delivery_tag = 'x_line_delivery_tag_example' # str | String returned in the delivery.data property of the delivery completion event via Webhook. (optional) + + try: + api_instance.push_templated_messages_by_phone(pnp_templated_message_request, x_line_delivery_tag=x_line_delivery_tag) + except Exception as e: + print("Exception when calling MessagingApi->push_templated_messages_by_phone: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pnp_templated_message_request** | [**PnpTemplatedMessageRequest**](PnpTemplatedMessageRequest.md)| | + **x_line_delivery_tag** | **str**| String returned in the delivery.data property of the delivery completion event via Webhook. | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[Bearer](../README.md#Bearer) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**202** | Accepted | - | +**422** | Failed to send the LINE notification message. For example, there is no LINE user associated with the specified phone number, the phone number is outside the LINE notification message service area, the user has refused to receive LINE notification messages, or the user hasn't agreed to LINE's Privacy Policy. | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **reply_message** > ReplyMessageResponse reply_message(reply_message_request) diff --git a/linebot/v3/messaging/models/__init__.py b/linebot/v3/messaging/models/__init__.py index 2ae5adc2c..65164fcf9 100644 --- a/linebot/v3/messaging/models/__init__.py +++ b/linebot/v3/messaging/models/__init__.py @@ -153,6 +153,11 @@ from linebot.v3.messaging.models.operator_demographic_filter import OperatorDemographicFilter from linebot.v3.messaging.models.operator_recipient import OperatorRecipient from linebot.v3.messaging.models.pnp_messages_request import PnpMessagesRequest +from linebot.v3.messaging.models.pnp_templated_button import PnpTemplatedButton +from linebot.v3.messaging.models.pnp_templated_emphasized_item import PnpTemplatedEmphasizedItem +from linebot.v3.messaging.models.pnp_templated_item import PnpTemplatedItem +from linebot.v3.messaging.models.pnp_templated_message_body import PnpTemplatedMessageBody +from linebot.v3.messaging.models.pnp_templated_message_request import PnpTemplatedMessageRequest from linebot.v3.messaging.models.postback_action import PostbackAction from linebot.v3.messaging.models.push_message_request import PushMessageRequest from linebot.v3.messaging.models.push_message_response import PushMessageResponse diff --git a/linebot/v3/messaging/models/pnp_messages_request.py b/linebot/v3/messaging/models/pnp_messages_request.py index b9e7d0c30..5ab71a19b 100644 --- a/linebot/v3/messaging/models/pnp_messages_request.py +++ b/linebot/v3/messaging/models/pnp_messages_request.py @@ -19,7 +19,7 @@ from typing import List, Optional -from pydantic.v1 import BaseModel, Field, StrictBool, StrictStr, conlist +from pydantic.v1 import BaseModel, Field, StrictBool, StrictStr, conlist, constr, validator from linebot.v3.messaging.models.message import Message class PnpMessagesRequest(BaseModel): @@ -30,8 +30,9 @@ class PnpMessagesRequest(BaseModel): messages: conlist(Message, max_items=5, min_items=1) = Field(..., description="Message to be sent.") to: StrictStr = Field(..., description="Message destination. Specify a phone number that has been normalized to E.164 format and hashed with SHA256.") notification_disabled: Optional[StrictBool] = Field(False, alias="notificationDisabled", description="`true`: The user doesn’t receive a push notification when a message is sent. `false`: The user receives a push notification when the message is sent (unless they have disabled push notifications in LINE and/or their device). The default value is false. ") + custom_aggregation_units: Optional[conlist(constr(strict=True, max_length=30, min_length=1), max_items=1)] = Field(None, alias="customAggregationUnits", description="Name of aggregation unit. Case-sensitive.") - __properties = ["messages", "to", "notificationDisabled"] + __properties = ["messages", "to", "notificationDisabled", "customAggregationUnits"] class Config: """Pydantic configuration""" @@ -78,7 +79,8 @@ def from_dict(cls, obj: dict) -> PnpMessagesRequest: _obj = PnpMessagesRequest.parse_obj({ "messages": [Message.from_dict(_item) for _item in obj.get("messages")] if obj.get("messages") is not None else None, "to": obj.get("to"), - "notification_disabled": obj.get("notificationDisabled") if obj.get("notificationDisabled") is not None else False + "notification_disabled": obj.get("notificationDisabled") if obj.get("notificationDisabled") is not None else False, + "custom_aggregation_units": obj.get("customAggregationUnits") }) return _obj diff --git a/linebot/v3/messaging/models/pnp_templated_button.py b/linebot/v3/messaging/models/pnp_templated_button.py new file mode 100644 index 000000000..9dd3bd675 --- /dev/null +++ b/linebot/v3/messaging/models/pnp_templated_button.py @@ -0,0 +1,74 @@ +# 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 BaseModel, Field, StrictStr, constr + +class PnpTemplatedButton(BaseModel): + """ + PnpTemplatedButton + https://developers.line.biz/en/reference/line-notification-messages/#send-line-notification-message-template-buttons + """ + button_key: StrictStr = Field(..., alias="buttonKey", description="Specify the key of the button you want to include. For available keys, see https://developers.line.biz/en/docs/partner-docs/line-notification-messages/template/#buttons ") + url: constr(strict=True, max_length=1000) = Field(..., description="URL of the page to be opened when the user presses the button.") + + __properties = ["buttonKey", "url"] + + 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) -> PnpTemplatedButton: + """Create an instance of PnpTemplatedButton 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) -> PnpTemplatedButton: + """Create an instance of PnpTemplatedButton from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return PnpTemplatedButton.parse_obj(obj) + + _obj = PnpTemplatedButton.parse_obj({ + "button_key": obj.get("buttonKey"), + "url": obj.get("url") + }) + return _obj + diff --git a/linebot/v3/messaging/models/pnp_templated_emphasized_item.py b/linebot/v3/messaging/models/pnp_templated_emphasized_item.py new file mode 100644 index 000000000..45fa4b639 --- /dev/null +++ b/linebot/v3/messaging/models/pnp_templated_emphasized_item.py @@ -0,0 +1,74 @@ +# 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 BaseModel, Field, StrictStr, constr + +class PnpTemplatedEmphasizedItem(BaseModel): + """ + Item to emphasize in the message. + https://developers.line.biz/en/reference/line-notification-messages/#send-line-notification-message-template-items + """ + item_key: StrictStr = Field(..., alias="itemKey", description="Specify the key of the item you want to include. For available keys, see https://developers.line.biz/en/docs/partner-docs/line-notification-messages/template/#items ") + content: constr(strict=True, max_length=15) = Field(..., description="String to be displayed as the value of the item.") + + __properties = ["itemKey", "content"] + + 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) -> PnpTemplatedEmphasizedItem: + """Create an instance of PnpTemplatedEmphasizedItem 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) -> PnpTemplatedEmphasizedItem: + """Create an instance of PnpTemplatedEmphasizedItem from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return PnpTemplatedEmphasizedItem.parse_obj(obj) + + _obj = PnpTemplatedEmphasizedItem.parse_obj({ + "item_key": obj.get("itemKey"), + "content": obj.get("content") + }) + return _obj + diff --git a/linebot/v3/messaging/models/pnp_templated_item.py b/linebot/v3/messaging/models/pnp_templated_item.py new file mode 100644 index 000000000..4ac8b16fc --- /dev/null +++ b/linebot/v3/messaging/models/pnp_templated_item.py @@ -0,0 +1,74 @@ +# 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 BaseModel, Field, StrictStr, constr + +class PnpTemplatedItem(BaseModel): + """ + PnpTemplatedItem + https://developers.line.biz/en/reference/line-notification-messages/#send-line-notification-message-template-items + """ + item_key: StrictStr = Field(..., alias="itemKey", description="Specify the key of the item you want to include. For available keys, see https://developers.line.biz/en/docs/partner-docs/line-notification-messages/template/#items ") + content: constr(strict=True, max_length=300) = Field(..., description="String to be displayed as the value of the item.") + + __properties = ["itemKey", "content"] + + 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) -> PnpTemplatedItem: + """Create an instance of PnpTemplatedItem 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) -> PnpTemplatedItem: + """Create an instance of PnpTemplatedItem from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return PnpTemplatedItem.parse_obj(obj) + + _obj = PnpTemplatedItem.parse_obj({ + "item_key": obj.get("itemKey"), + "content": obj.get("content") + }) + return _obj + diff --git a/linebot/v3/messaging/models/pnp_templated_message_body.py b/linebot/v3/messaging/models/pnp_templated_message_body.py new file mode 100644 index 000000000..e0f56f174 --- /dev/null +++ b/linebot/v3/messaging/models/pnp_templated_message_body.py @@ -0,0 +1,96 @@ +# 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 List, Optional +from pydantic.v1 import BaseModel, Field, conlist +from linebot.v3.messaging.models.pnp_templated_button import PnpTemplatedButton +from linebot.v3.messaging.models.pnp_templated_emphasized_item import PnpTemplatedEmphasizedItem +from linebot.v3.messaging.models.pnp_templated_item import PnpTemplatedItem + +class PnpTemplatedMessageBody(BaseModel): + """ + The body object of the template you want to send. You can't specify the same item more than once in a single message. + https://developers.line.biz/en/reference/line-notification-messages/#send-line-notification-message-template + """ + emphasized_item: Optional[PnpTemplatedEmphasizedItem] = Field(None, alias="emphasizedItem") + items: Optional[conlist(PnpTemplatedItem, max_items=15)] = Field(None, description="Array of items to include in the message. The `itemKey` must be unique across `emphasizedItem` and `items`.") + buttons: Optional[conlist(PnpTemplatedButton, max_items=2)] = Field(None, description="Array of buttons to include in the message. The `buttonKey` must be unique.") + + __properties = ["emphasizedItem", "items", "buttons"] + + 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) -> PnpTemplatedMessageBody: + """Create an instance of PnpTemplatedMessageBody 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 emphasized_item + if self.emphasized_item: + _dict['emphasizedItem'] = self.emphasized_item.to_dict() + # override the default output from pydantic.v1 by calling `to_dict()` of each item in items (list) + _items = [] + if self.items: + for _item in self.items: + if _item: + _items.append(_item.to_dict()) + _dict['items'] = _items + # override the default output from pydantic.v1 by calling `to_dict()` of each item in buttons (list) + _items = [] + if self.buttons: + for _item in self.buttons: + if _item: + _items.append(_item.to_dict()) + _dict['buttons'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> PnpTemplatedMessageBody: + """Create an instance of PnpTemplatedMessageBody from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return PnpTemplatedMessageBody.parse_obj(obj) + + _obj = PnpTemplatedMessageBody.parse_obj({ + "emphasized_item": PnpTemplatedEmphasizedItem.from_dict(obj.get("emphasizedItem")) if obj.get("emphasizedItem") is not None else None, + "items": [PnpTemplatedItem.from_dict(_item) for _item in obj.get("items")] if obj.get("items") is not None else None, + "buttons": [PnpTemplatedButton.from_dict(_item) for _item in obj.get("buttons")] if obj.get("buttons") is not None else None + }) + return _obj + diff --git a/linebot/v3/messaging/models/pnp_templated_message_request.py b/linebot/v3/messaging/models/pnp_templated_message_request.py new file mode 100644 index 000000000..f56a941c2 --- /dev/null +++ b/linebot/v3/messaging/models/pnp_templated_message_request.py @@ -0,0 +1,82 @@ +# 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 List, Optional +from pydantic.v1 import BaseModel, Field, StrictStr, conlist, constr, validator +from linebot.v3.messaging.models.pnp_templated_message_body import PnpTemplatedMessageBody + +class PnpTemplatedMessageRequest(BaseModel): + """ + PnpTemplatedMessageRequest + https://developers.line.biz/en/reference/line-notification-messages/#send-line-notification-message-template + """ + to: StrictStr = Field(..., description="Message destination. Specify a phone number that has been normalized to E.164 format and hashed with SHA256.") + template_key: StrictStr = Field(..., alias="templateKey", description="Specify the key of the template you want to send. For available keys, see https://developers.line.biz/en/docs/partner-docs/line-notification-messages/template/#templates ") + body: Optional[PnpTemplatedMessageBody] = None + custom_aggregation_units: Optional[conlist(constr(strict=True, max_length=30, min_length=1), max_items=1)] = Field(None, alias="customAggregationUnits", description="Name of aggregation unit. Case-sensitive. For more information about assigning a unit name, see https://developers.line.biz/en/docs/messaging-api/unit-based-statistics-aggregation/#assign-names-to-units-when-sending-messages ") + + __properties = ["to", "templateKey", "body", "customAggregationUnits"] + + 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) -> PnpTemplatedMessageRequest: + """Create an instance of PnpTemplatedMessageRequest 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 body + if self.body: + _dict['body'] = self.body.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> PnpTemplatedMessageRequest: + """Create an instance of PnpTemplatedMessageRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return PnpTemplatedMessageRequest.parse_obj(obj) + + _obj = PnpTemplatedMessageRequest.parse_obj({ + "to": obj.get("to"), + "template_key": obj.get("templateKey"), + "body": PnpTemplatedMessageBody.from_dict(obj.get("body")) if obj.get("body") is not None else None, + "custom_aggregation_units": obj.get("customAggregationUnits") + }) + return _obj +