diff --git a/line-openapi b/line-openapi index 04b9b633..4e10c73d 160000 --- a/line-openapi +++ b/line-openapi @@ -1 +1 @@ -Subproject commit 04b9b633e6558600ee94bc5156e228643f020c79 +Subproject commit 4e10c73df579b4c1821a305f0190dfbe8710d2de diff --git a/linebot/v3/messaging/__init__.py b/linebot/v3/messaging/__init__.py index c02b2244..b973542f 100644 --- a/linebot/v3/messaging/__init__.py +++ b/linebot/v3/messaging/__init__.py @@ -98,6 +98,7 @@ from linebot.v3.messaging.models.get_aggregation_unit_name_list_response import GetAggregationUnitNameListResponse from linebot.v3.messaging.models.get_aggregation_unit_usage_response import GetAggregationUnitUsageResponse from linebot.v3.messaging.models.get_followers_response import GetFollowersResponse +from linebot.v3.messaging.models.get_joined_membership_users_response import GetJoinedMembershipUsersResponse from linebot.v3.messaging.models.get_membership_subscription_response import GetMembershipSubscriptionResponse from linebot.v3.messaging.models.get_message_content_transcoding_response import GetMessageContentTranscodingResponse from linebot.v3.messaging.models.get_webhook_endpoint_response import GetWebhookEndpointResponse diff --git a/linebot/v3/messaging/api/async_messaging_api.py b/linebot/v3/messaging/api/async_messaging_api.py index 3fa62c2c..25bf90e9 100644 --- a/linebot/v3/messaging/api/async_messaging_api.py +++ b/linebot/v3/messaging/api/async_messaging_api.py @@ -20,7 +20,7 @@ from typing_extensions import Annotated from typing import overload, Optional, Union, Awaitable -from pydantic.v1 import Field, StrictStr, conint, constr, validator +from pydantic.v1 import Field, StrictInt, StrictStr, conint, constr, validator from typing import Any, Dict, Optional @@ -30,6 +30,7 @@ from linebot.v3.messaging.models.get_aggregation_unit_name_list_response import GetAggregationUnitNameListResponse from linebot.v3.messaging.models.get_aggregation_unit_usage_response import GetAggregationUnitUsageResponse from linebot.v3.messaging.models.get_followers_response import GetFollowersResponse +from linebot.v3.messaging.models.get_joined_membership_users_response import GetJoinedMembershipUsersResponse from linebot.v3.messaging.models.get_membership_subscription_response import GetMembershipSubscriptionResponse from linebot.v3.messaging.models.get_webhook_endpoint_response import GetWebhookEndpointResponse from linebot.v3.messaging.models.group_member_count_response import GroupMemberCountResponse @@ -2374,6 +2375,175 @@ def get_group_summary_with_http_info(self, group_id : Annotated[StrictStr, Field collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @overload + async def get_joined_membership_users(self, membership_id : Annotated[StrictInt, Field(..., description="Membership plan ID.")], start : Annotated[Optional[StrictStr], Field(description="A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). ")] = None, limit : Annotated[Optional[conint(strict=True, le=1000, ge=1)], Field(description="The max number of items to return for this API call. The value is set to 300 by default, but the max acceptable value is 1000. ")] = None, **kwargs) -> GetJoinedMembershipUsersResponse: # noqa: E501 + ... + + @overload + def get_joined_membership_users(self, membership_id : Annotated[StrictInt, Field(..., description="Membership plan ID.")], start : Annotated[Optional[StrictStr], Field(description="A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). ")] = None, limit : Annotated[Optional[conint(strict=True, le=1000, ge=1)], Field(description="The max number of items to return for this API call. The value is set to 300 by default, but the max acceptable value is 1000. ")] = None, async_req: Optional[bool]=True, **kwargs) -> GetJoinedMembershipUsersResponse: # noqa: E501 + ... + + @validate_arguments + def get_joined_membership_users(self, membership_id : Annotated[StrictInt, Field(..., description="Membership plan ID.")], start : Annotated[Optional[StrictStr], Field(description="A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). ")] = None, limit : Annotated[Optional[conint(strict=True, le=1000, ge=1)], Field(description="The max number of items to return for this API call. The value is set to 300 by default, but the max acceptable value is 1000. ")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[GetJoinedMembershipUsersResponse, Awaitable[GetJoinedMembershipUsersResponse]]: # noqa: E501 + """get_joined_membership_users # noqa: E501 + + Get a list of user IDs who joined the membership. # 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_joined_membership_users(membership_id, start, limit, async_req=True) + >>> result = thread.get() + + :param membership_id: Membership plan ID. (required) + :type membership_id: int + :param start: A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). + :type start: str + :param limit: The max number of items to return for this API call. The value is set to 300 by default, but the max acceptable value is 1000. + :type limit: int + :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: GetJoinedMembershipUsersResponse + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + raise ValueError("Error! Please call the get_joined_membership_users_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_joined_membership_users_with_http_info(membership_id, start, limit, **kwargs) # noqa: E501 + + @validate_arguments + def get_joined_membership_users_with_http_info(self, membership_id : Annotated[StrictInt, Field(..., description="Membership plan ID.")], start : Annotated[Optional[StrictStr], Field(description="A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). ")] = None, limit : Annotated[Optional[conint(strict=True, le=1000, ge=1)], Field(description="The max number of items to return for this API call. The value is set to 300 by default, but the max acceptable value is 1000. ")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """get_joined_membership_users # noqa: E501 + + Get a list of user IDs who joined the membership. # 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_joined_membership_users_with_http_info(membership_id, start, limit, async_req=True) + >>> result = thread.get() + + :param membership_id: Membership plan ID. (required) + :type membership_id: int + :param start: A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). + :type start: str + :param limit: The max number of items to return for this API call. The value is set to 300 by default, but the max acceptable value is 1000. + :type limit: int + :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(GetJoinedMembershipUsersResponse, status_code(int), headers(HTTPHeaderDict)) + """ + + _host = self.line_base_path + _params = locals() + + _all_params = [ + 'membership_id', + 'start', + 'limit' + ] + _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_joined_membership_users" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['membership_id']: + _path_params['membershipId'] = _params['membership_id'] + + + # process the query parameters + _query_params = [] + if _params.get('start') is not None: # noqa: E501 + _query_params.append(('start', _params['start'])) + + if _params.get('limit') is not None: # noqa: E501 + _query_params.append(('limit', _params['limit'])) + + # 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': "GetJoinedMembershipUsersResponse", + '400': "ErrorResponse", + '404': "ErrorResponse", + } + + return self.api_client.call_api( + '/v2/bot/membership/{membershipId}/users/ids', '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_membership_list(self, **kwargs) -> MembershipListResponse: # noqa: E501 ... diff --git a/linebot/v3/messaging/api/messaging_api.py b/linebot/v3/messaging/api/messaging_api.py index ddb354e8..74c20f56 100644 --- a/linebot/v3/messaging/api/messaging_api.py +++ b/linebot/v3/messaging/api/messaging_api.py @@ -18,7 +18,7 @@ from pydantic.v1 import validate_arguments, ValidationError from typing_extensions import Annotated -from pydantic.v1 import Field, StrictStr, conint, constr, validator +from pydantic.v1 import Field, StrictInt, StrictStr, conint, constr, validator from typing import Any, Dict, Optional @@ -28,6 +28,7 @@ from linebot.v3.messaging.models.get_aggregation_unit_name_list_response import GetAggregationUnitNameListResponse from linebot.v3.messaging.models.get_aggregation_unit_usage_response import GetAggregationUnitUsageResponse from linebot.v3.messaging.models.get_followers_response import GetFollowersResponse +from linebot.v3.messaging.models.get_joined_membership_users_response import GetJoinedMembershipUsersResponse from linebot.v3.messaging.models.get_membership_subscription_response import GetMembershipSubscriptionResponse from linebot.v3.messaging.models.get_webhook_endpoint_response import GetWebhookEndpointResponse from linebot.v3.messaging.models.group_member_count_response import GroupMemberCountResponse @@ -2222,6 +2223,165 @@ def get_group_summary_with_http_info(self, group_id : Annotated[StrictStr, Field collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @validate_arguments + def get_joined_membership_users(self, membership_id : Annotated[StrictInt, Field(..., description="Membership plan ID.")], start : Annotated[Optional[StrictStr], Field(description="A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). ")] = None, limit : Annotated[Optional[conint(strict=True, le=1000, ge=1)], Field(description="The max number of items to return for this API call. The value is set to 300 by default, but the max acceptable value is 1000. ")] = None, **kwargs) -> GetJoinedMembershipUsersResponse: # noqa: E501 + """get_joined_membership_users # noqa: E501 + + Get a list of user IDs who joined the membership. # 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_joined_membership_users(membership_id, start, limit, async_req=True) + >>> result = thread.get() + + :param membership_id: Membership plan ID. (required) + :type membership_id: int + :param start: A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). + :type start: str + :param limit: The max number of items to return for this API call. The value is set to 300 by default, but the max acceptable value is 1000. + :type limit: int + :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: GetJoinedMembershipUsersResponse + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + raise ValueError("Error! Please call the get_joined_membership_users_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data") + return self.get_joined_membership_users_with_http_info(membership_id, start, limit, **kwargs) # noqa: E501 + + @validate_arguments + def get_joined_membership_users_with_http_info(self, membership_id : Annotated[StrictInt, Field(..., description="Membership plan ID.")], start : Annotated[Optional[StrictStr], Field(description="A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). ")] = None, limit : Annotated[Optional[conint(strict=True, le=1000, ge=1)], Field(description="The max number of items to return for this API call. The value is set to 300 by default, but the max acceptable value is 1000. ")] = None, **kwargs) -> ApiResponse: # noqa: E501 + """get_joined_membership_users # noqa: E501 + + Get a list of user IDs who joined the membership. # 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_joined_membership_users_with_http_info(membership_id, start, limit, async_req=True) + >>> result = thread.get() + + :param membership_id: Membership plan ID. (required) + :type membership_id: int + :param start: A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). + :type start: str + :param limit: The max number of items to return for this API call. The value is set to 300 by default, but the max acceptable value is 1000. + :type limit: int + :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(GetJoinedMembershipUsersResponse, status_code(int), headers(HTTPHeaderDict)) + """ + + _host = self.line_base_path + _params = locals() + + _all_params = [ + 'membership_id', + 'start', + 'limit' + ] + _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_joined_membership_users" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['membership_id']: + _path_params['membershipId'] = _params['membership_id'] + + + # process the query parameters + _query_params = [] + if _params.get('start') is not None: # noqa: E501 + _query_params.append(('start', _params['start'])) + + if _params.get('limit') is not None: # noqa: E501 + _query_params.append(('limit', _params['limit'])) + + # 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': "GetJoinedMembershipUsersResponse", + '400': "ErrorResponse", + '404': "ErrorResponse", + } + + return self.api_client.call_api( + '/v2/bot/membership/{membershipId}/users/ids', '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_membership_list(self, **kwargs) -> MembershipListResponse: # noqa: E501 """get_membership_list # noqa: E501 diff --git a/linebot/v3/messaging/docs/MessagingApi.md b/linebot/v3/messaging/docs/MessagingApi.md index d8476b96..296798d3 100644 --- a/linebot/v3/messaging/docs/MessagingApi.md +++ b/linebot/v3/messaging/docs/MessagingApi.md @@ -19,6 +19,7 @@ Method | HTTP request | Description [**get_group_member_profile**](MessagingApi.md#get_group_member_profile) | **GET** /v2/bot/group/{groupId}/member/{userId} | [**get_group_members_ids**](MessagingApi.md#get_group_members_ids) | **GET** /v2/bot/group/{groupId}/members/ids | [**get_group_summary**](MessagingApi.md#get_group_summary) | **GET** /v2/bot/group/{groupId}/summary | +[**get_joined_membership_users**](MessagingApi.md#get_joined_membership_users) | **GET** /v2/bot/membership/{membershipId}/users/ids | [**get_membership_list**](MessagingApi.md#get_membership_list) | **GET** /v2/bot/membership/list | [**get_membership_subscription**](MessagingApi.md#get_membership_subscription) | **GET** /v2/bot/membership/subscription/{userId} | [**get_message_quota**](MessagingApi.md#get_message_quota) | **GET** /v2/bot/message/quota | @@ -1183,6 +1184,87 @@ Name | Type | Description | Notes [[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_joined_membership_users** +> GetJoinedMembershipUsersResponse get_joined_membership_users(membership_id, start=start, limit=limit) + + + +Get a list of user IDs who joined the membership. + +### Example + +* Bearer Authentication (Bearer): +```python +import time +import os +import linebot.v3.messaging +from linebot.v3.messaging.models.get_joined_membership_users_response import GetJoinedMembershipUsersResponse +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) + membership_id = 56 # int | Membership plan ID. + start = 'start_example' # str | A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). (optional) + limit = 300 # int | The max number of items to return for this API call. The value is set to 300 by default, but the max acceptable value is 1000. (optional) (default to 300) + + try: + api_response = api_instance.get_joined_membership_users(membership_id, start=start, limit=limit) + print("The response of MessagingApi->get_joined_membership_users:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling MessagingApi->get_joined_membership_users: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **membership_id** | **int**| Membership plan ID. | + **start** | **str**| A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). | [optional] + **limit** | **int**| The max number of items to return for this API call. The value is set to 300 by default, but the max acceptable value is 1000. | [optional] [default to 300] + +### Return type + +[**GetJoinedMembershipUsersResponse**](GetJoinedMembershipUsersResponse.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 | - | +**400** | `start` is incorrect or expired, or `limit` is under 1 or over 1000. | - | +**404** | Membership ID is not owned by the bot or does not exist. | - | + +[[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_membership_list** > MembershipListResponse get_membership_list() diff --git a/linebot/v3/messaging/models/__init__.py b/linebot/v3/messaging/models/__init__.py index dced3bfd..171373b2 100644 --- a/linebot/v3/messaging/models/__init__.py +++ b/linebot/v3/messaging/models/__init__.py @@ -77,6 +77,7 @@ from linebot.v3.messaging.models.get_aggregation_unit_name_list_response import GetAggregationUnitNameListResponse from linebot.v3.messaging.models.get_aggregation_unit_usage_response import GetAggregationUnitUsageResponse from linebot.v3.messaging.models.get_followers_response import GetFollowersResponse +from linebot.v3.messaging.models.get_joined_membership_users_response import GetJoinedMembershipUsersResponse from linebot.v3.messaging.models.get_membership_subscription_response import GetMembershipSubscriptionResponse from linebot.v3.messaging.models.get_message_content_transcoding_response import GetMessageContentTranscodingResponse from linebot.v3.messaging.models.get_webhook_endpoint_response import GetWebhookEndpointResponse diff --git a/linebot/v3/messaging/models/get_joined_membership_users_response.py b/linebot/v3/messaging/models/get_joined_membership_users_response.py new file mode 100644 index 00000000..a50197f9 --- /dev/null +++ b/linebot/v3/messaging/models/get_joined_membership_users_response.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 typing import List, Optional +from pydantic.v1 import BaseModel, Field, StrictStr, conlist + +class GetJoinedMembershipUsersResponse(BaseModel): + """ + List of users who have joined the membership + https://developers.line.biz/en/reference/messaging-api/#get-membership-user-ids + """ + user_ids: conlist(StrictStr, max_items=1000) = Field(..., alias="userIds", description="A list of user IDs who joined the membership. Users who have not agreed to the bot user agreement, are not following the bot, or are not active will be excluded. If there are no users in the membership, an empty list will be returned. ") + next: Optional[StrictStr] = Field(None, description="A continuation token to get next remaining membership user IDs. Returned only when there are remaining user IDs that weren't returned in the userIds property in the previous request. The continuation token expires in 24 hours (86,400 seconds). ") + + __properties = ["userIds", "next"] + + 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) -> GetJoinedMembershipUsersResponse: + """Create an instance of GetJoinedMembershipUsersResponse 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) -> GetJoinedMembershipUsersResponse: + """Create an instance of GetJoinedMembershipUsersResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return GetJoinedMembershipUsersResponse.parse_obj(obj) + + _obj = GetJoinedMembershipUsersResponse.parse_obj({ + "user_ids": obj.get("userIds"), + "next": obj.get("next") + }) + return _obj + diff --git a/linebot/v3/webhooks/__init__.py b/linebot/v3/webhooks/__init__.py index e9efa194..e5d444f0 100644 --- a/linebot/v3/webhooks/__init__.py +++ b/linebot/v3/webhooks/__init__.py @@ -60,13 +60,17 @@ from linebot.v3.webhooks.models.image_set import ImageSet from linebot.v3.webhooks.models.join_event import JoinEvent from linebot.v3.webhooks.models.joined_members import JoinedMembers +from linebot.v3.webhooks.models.joined_membership_content import JoinedMembershipContent from linebot.v3.webhooks.models.leave_event import LeaveEvent from linebot.v3.webhooks.models.left_members import LeftMembers +from linebot.v3.webhooks.models.left_membership_content import LeftMembershipContent from linebot.v3.webhooks.models.link_content import LinkContent from linebot.v3.webhooks.models.link_things_content import LinkThingsContent from linebot.v3.webhooks.models.location_message_content import LocationMessageContent from linebot.v3.webhooks.models.member_joined_event import MemberJoinedEvent from linebot.v3.webhooks.models.member_left_event import MemberLeftEvent +from linebot.v3.webhooks.models.membership_content import MembershipContent +from linebot.v3.webhooks.models.membership_event import MembershipEvent from linebot.v3.webhooks.models.mention import Mention from linebot.v3.webhooks.models.mentionee import Mentionee from linebot.v3.webhooks.models.message_content import MessageContent @@ -77,6 +81,7 @@ from linebot.v3.webhooks.models.pnp_delivery_completion_event import PnpDeliveryCompletionEvent from linebot.v3.webhooks.models.postback_content import PostbackContent from linebot.v3.webhooks.models.postback_event import PostbackEvent +from linebot.v3.webhooks.models.renewed_membership_content import RenewedMembershipContent from linebot.v3.webhooks.models.room_source import RoomSource from linebot.v3.webhooks.models.scenario_result import ScenarioResult from linebot.v3.webhooks.models.scenario_result_things_content import ScenarioResultThingsContent diff --git a/linebot/v3/webhooks/models/__init__.py b/linebot/v3/webhooks/models/__init__.py index 97cd9e77..779719ce 100644 --- a/linebot/v3/webhooks/models/__init__.py +++ b/linebot/v3/webhooks/models/__init__.py @@ -41,13 +41,17 @@ from linebot.v3.webhooks.models.image_set import ImageSet from linebot.v3.webhooks.models.join_event import JoinEvent from linebot.v3.webhooks.models.joined_members import JoinedMembers +from linebot.v3.webhooks.models.joined_membership_content import JoinedMembershipContent from linebot.v3.webhooks.models.leave_event import LeaveEvent from linebot.v3.webhooks.models.left_members import LeftMembers +from linebot.v3.webhooks.models.left_membership_content import LeftMembershipContent from linebot.v3.webhooks.models.link_content import LinkContent from linebot.v3.webhooks.models.link_things_content import LinkThingsContent from linebot.v3.webhooks.models.location_message_content import LocationMessageContent from linebot.v3.webhooks.models.member_joined_event import MemberJoinedEvent from linebot.v3.webhooks.models.member_left_event import MemberLeftEvent +from linebot.v3.webhooks.models.membership_content import MembershipContent +from linebot.v3.webhooks.models.membership_event import MembershipEvent from linebot.v3.webhooks.models.mention import Mention from linebot.v3.webhooks.models.mentionee import Mentionee from linebot.v3.webhooks.models.message_content import MessageContent @@ -58,6 +62,7 @@ from linebot.v3.webhooks.models.pnp_delivery_completion_event import PnpDeliveryCompletionEvent from linebot.v3.webhooks.models.postback_content import PostbackContent from linebot.v3.webhooks.models.postback_event import PostbackEvent +from linebot.v3.webhooks.models.renewed_membership_content import RenewedMembershipContent from linebot.v3.webhooks.models.room_source import RoomSource from linebot.v3.webhooks.models.scenario_result import ScenarioResult from linebot.v3.webhooks.models.scenario_result_things_content import ScenarioResultThingsContent diff --git a/linebot/v3/webhooks/models/event.py b/linebot/v3/webhooks/models/event.py index 8dc54085..0226d6fc 100644 --- a/linebot/v3/webhooks/models/event.py +++ b/linebot/v3/webhooks/models/event.py @@ -60,6 +60,7 @@ class Config: 'leave': 'LeaveEvent', 'memberJoined': 'MemberJoinedEvent', 'memberLeft': 'MemberLeftEvent', + 'membership': 'MembershipEvent', 'message': 'MessageEvent', 'module': 'ModuleEvent', 'postback': 'PostbackEvent', @@ -87,7 +88,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Union(AccountLinkEvent, ActivatedEvent, BeaconEvent, BotResumedEvent, BotSuspendedEvent, DeactivatedEvent, FollowEvent, JoinEvent, LeaveEvent, MemberJoinedEvent, MemberLeftEvent, MessageEvent, ModuleEvent, PnpDeliveryCompletionEvent, PostbackEvent, ThingsEvent, UnfollowEvent, UnsendEvent, VideoPlayCompleteEvent): + def from_json(cls, json_str: str) -> Union(AccountLinkEvent, ActivatedEvent, BeaconEvent, BotResumedEvent, BotSuspendedEvent, DeactivatedEvent, FollowEvent, JoinEvent, LeaveEvent, MemberJoinedEvent, MemberLeftEvent, MembershipEvent, MessageEvent, ModuleEvent, PnpDeliveryCompletionEvent, PostbackEvent, ThingsEvent, UnfollowEvent, UnsendEvent, VideoPlayCompleteEvent): """Create an instance of Event from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -106,7 +107,7 @@ def to_dict(self): return _dict @classmethod - def from_dict(cls, obj: dict) -> Union(AccountLinkEvent, ActivatedEvent, BeaconEvent, BotResumedEvent, BotSuspendedEvent, DeactivatedEvent, FollowEvent, JoinEvent, LeaveEvent, MemberJoinedEvent, MemberLeftEvent, MessageEvent, ModuleEvent, PnpDeliveryCompletionEvent, PostbackEvent, ThingsEvent, UnfollowEvent, UnsendEvent, VideoPlayCompleteEvent): + def from_dict(cls, obj: dict) -> Union(AccountLinkEvent, ActivatedEvent, BeaconEvent, BotResumedEvent, BotSuspendedEvent, DeactivatedEvent, FollowEvent, JoinEvent, LeaveEvent, MemberJoinedEvent, MemberLeftEvent, MembershipEvent, MessageEvent, ModuleEvent, PnpDeliveryCompletionEvent, PostbackEvent, ThingsEvent, UnfollowEvent, UnsendEvent, VideoPlayCompleteEvent): """Create an instance of Event from a dict""" # look up the object type based on discriminator mapping object_type = cls.get_discriminator_value(obj) diff --git a/linebot/v3/webhooks/models/joined_membership_content.py b/linebot/v3/webhooks/models/joined_membership_content.py new file mode 100644 index 00000000..98bb2d95 --- /dev/null +++ b/linebot/v3/webhooks/models/joined_membership_content.py @@ -0,0 +1,74 @@ +# coding: utf-8 + +""" + Webhook Type Definition + + Webhook event definition of the LINE Messaging API # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + 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, StrictInt +from linebot.v3.webhooks.models.membership_content import MembershipContent + +class JoinedMembershipContent(MembershipContent): + """ + JoinedMembershipContent + """ + membership_id: StrictInt = Field(..., alias="membershipId", description="The ID of the membership that the user joined. This is defined for each membership.") + type: str = "joined" + + __properties = ["type", "membershipId"] + + 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) -> JoinedMembershipContent: + """Create an instance of JoinedMembershipContent 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) -> JoinedMembershipContent: + """Create an instance of JoinedMembershipContent from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return JoinedMembershipContent.parse_obj(obj) + + _obj = JoinedMembershipContent.parse_obj({ + "type": obj.get("type"), + "membership_id": obj.get("membershipId") + }) + return _obj + diff --git a/linebot/v3/webhooks/models/left_membership_content.py b/linebot/v3/webhooks/models/left_membership_content.py new file mode 100644 index 00000000..006f0d04 --- /dev/null +++ b/linebot/v3/webhooks/models/left_membership_content.py @@ -0,0 +1,74 @@ +# coding: utf-8 + +""" + Webhook Type Definition + + Webhook event definition of the LINE Messaging API # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + 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, StrictInt +from linebot.v3.webhooks.models.membership_content import MembershipContent + +class LeftMembershipContent(MembershipContent): + """ + LeftMembershipContent + """ + membership_id: StrictInt = Field(..., alias="membershipId", description="The ID of the membership that the user left. This is defined for each membership.") + type: str = "left" + + __properties = ["type", "membershipId"] + + 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) -> LeftMembershipContent: + """Create an instance of LeftMembershipContent 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) -> LeftMembershipContent: + """Create an instance of LeftMembershipContent from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return LeftMembershipContent.parse_obj(obj) + + _obj = LeftMembershipContent.parse_obj({ + "type": obj.get("type"), + "membership_id": obj.get("membershipId") + }) + return _obj + diff --git a/linebot/v3/webhooks/models/membership_content.py b/linebot/v3/webhooks/models/membership_content.py new file mode 100644 index 00000000..0de59734 --- /dev/null +++ b/linebot/v3/webhooks/models/membership_content.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + Webhook Type Definition + + Webhook event definition of the LINE Messaging API # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + 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.webhooks.models + + +from typing import Union +from pydantic.v1 import BaseModel, Field, StrictStr + +class MembershipContent(BaseModel): + """ + Content of the membership event. + """ + type: StrictStr = Field(..., description="Type of membership event.") + + __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 = { + 'joined': 'JoinedMembershipContent', + 'left': 'LeftMembershipContent', + 'renewed': 'RenewedMembershipContent' + } + + @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(JoinedMembershipContent, LeftMembershipContent, RenewedMembershipContent): + """Create an instance of MembershipContent 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(JoinedMembershipContent, LeftMembershipContent, RenewedMembershipContent): + """Create an instance of MembershipContent 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.webhooks.models, object_type) + return klass.from_dict(obj) + else: + raise ValueError("MembershipContent 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/webhooks/models/membership_event.py b/linebot/v3/webhooks/models/membership_event.py new file mode 100644 index 00000000..ec99775d --- /dev/null +++ b/linebot/v3/webhooks/models/membership_event.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + Webhook Type Definition + + Webhook event definition of the LINE Messaging API # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + 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.webhooks.models.delivery_context import DeliveryContext +from linebot.v3.webhooks.models.event import Event +from linebot.v3.webhooks.models.event_mode import EventMode +from linebot.v3.webhooks.models.membership_content import MembershipContent +from linebot.v3.webhooks.models.source import Source + +class MembershipEvent(Event): + """ + This event indicates that a user has subscribed (joined), unsubscribed (left), or renewed the bot's membership. + """ + reply_token: StrictStr = Field(..., alias="replyToken", description="Reply token used to send reply message to this event") + membership: MembershipContent = Field(...) + type: str = "membership" + + __properties = ["type", "source", "timestamp", "mode", "webhookEventId", "deliveryContext", "replyToken", "membership"] + + 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) -> MembershipEvent: + """Create an instance of MembershipEvent 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 source + if self.source: + _dict['source'] = self.source.to_dict() + # override the default output from pydantic.v1 by calling `to_dict()` of delivery_context + if self.delivery_context: + _dict['deliveryContext'] = self.delivery_context.to_dict() + # override the default output from pydantic.v1 by calling `to_dict()` of membership + if self.membership: + _dict['membership'] = self.membership.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> MembershipEvent: + """Create an instance of MembershipEvent from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return MembershipEvent.parse_obj(obj) + + _obj = MembershipEvent.parse_obj({ + "type": obj.get("type"), + "source": Source.from_dict(obj.get("source")) if obj.get("source") is not None else None, + "timestamp": obj.get("timestamp"), + "mode": obj.get("mode"), + "webhook_event_id": obj.get("webhookEventId"), + "delivery_context": DeliveryContext.from_dict(obj.get("deliveryContext")) if obj.get("deliveryContext") is not None else None, + "reply_token": obj.get("replyToken"), + "membership": MembershipContent.from_dict(obj.get("membership")) if obj.get("membership") is not None else None + }) + return _obj + diff --git a/linebot/v3/webhooks/models/renewed_membership_content.py b/linebot/v3/webhooks/models/renewed_membership_content.py new file mode 100644 index 00000000..726a360c --- /dev/null +++ b/linebot/v3/webhooks/models/renewed_membership_content.py @@ -0,0 +1,74 @@ +# coding: utf-8 + +""" + Webhook Type Definition + + Webhook event definition of the LINE Messaging API # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + 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, StrictInt +from linebot.v3.webhooks.models.membership_content import MembershipContent + +class RenewedMembershipContent(MembershipContent): + """ + RenewedMembershipContent + """ + membership_id: StrictInt = Field(..., alias="membershipId", description="The ID of the membership that the user renewed. This is defined for each membership.") + type: str = "renewed" + + __properties = ["type", "membershipId"] + + 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) -> RenewedMembershipContent: + """Create an instance of RenewedMembershipContent 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) -> RenewedMembershipContent: + """Create an instance of RenewedMembershipContent from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return RenewedMembershipContent.parse_obj(obj) + + _obj = RenewedMembershipContent.parse_obj({ + "type": obj.get("type"), + "membership_id": obj.get("membershipId") + }) + return _obj +