Skip to content

Commit

Permalink
Implementation of getChannelMembers (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
nanato12 authored Jan 26, 2025
1 parent 83d3a21 commit 83b1b95
Show file tree
Hide file tree
Showing 12 changed files with 1,074 additions and 2 deletions.
72 changes: 72 additions & 0 deletions docs/DefaultApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,82 @@ All URIs are relative to *https://talk.worksmobile.com*

Method | HTTP request | Description
------------- | ------------- | -------------
[**get_channel_members**](DefaultApi.md#get_channel_members) | **POST** /p/oneapp/client/chat/getChannelMembers | Get Channel Members
[**get_my_info**](DefaultApi.md#get_my_info) | **GET** /p/contact/v3/domain/contacts/my | Get My Information
[**send_message**](DefaultApi.md#send_message) | **POST** /p/oneapp/client/chat/sendMessage | Send Message


# **get_channel_members**
> GetChannelMembersResponse get_channel_members(cookie=cookie, get_channel_members_request=get_channel_members_request)
Get Channel Members

Get information about the members in the channel.

### Example


```python
import line_works.openapi.talk
from line_works.openapi.talk.models.get_channel_members_request import GetChannelMembersRequest
from line_works.openapi.talk.models.get_channel_members_response import GetChannelMembersResponse
from line_works.openapi.talk.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://talk.worksmobile.com
# See configuration.py for a list of all supported configuration parameters.
configuration = line_works.openapi.talk.Configuration(
host = "https://talk.worksmobile.com"
)


# Enter a context with an instance of the API client
with line_works.openapi.talk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = line_works.openapi.talk.DefaultApi(api_client)
cookie = 'cookie_example' # str | cookie (optional)
get_channel_members_request = line_works.openapi.talk.GetChannelMembersRequest() # GetChannelMembersRequest | (optional)

try:
# Get Channel Members
api_response = api_instance.get_channel_members(cookie=cookie, get_channel_members_request=get_channel_members_request)
print("The response of DefaultApi->get_channel_members:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling DefaultApi->get_channel_members: %s\n" % e)
```



### Parameters


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**cookie** | **str**| cookie | [optional]
**get_channel_members_request** | [**GetChannelMembersRequest**](GetChannelMembersRequest.md)| | [optional]

### Return type

[**GetChannelMembersResponse**](GetChannelMembersResponse.md)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: application/json
- **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_my_info**
> MyInfo get_my_info(cookie=cookie)
Expand Down
31 changes: 31 additions & 0 deletions docs/GetChannelMembersRequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# GetChannelMembersRequest


## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**channel_no** | **int** | |
**member_update_time** | **int** | | [optional] [default to 0]
**paging_count** | **int** | | [optional] [default to 500]

## Example

```python
from line_works.openapi.talk.models.get_channel_members_request import GetChannelMembersRequest

# TODO update the JSON string below
json = "{}"
# create an instance of GetChannelMembersRequest from a JSON string
get_channel_members_request_instance = GetChannelMembersRequest.from_json(json)
# print the JSON string representation of the object
print(GetChannelMembersRequest.to_json())

# convert the object into a dict
get_channel_members_request_dict = get_channel_members_request_instance.to_dict()
# create an instance of GetChannelMembersRequest from a dict
get_channel_members_request_from_dict = GetChannelMembersRequest.from_dict(get_channel_members_request_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


31 changes: 31 additions & 0 deletions docs/GetChannelMembersResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# GetChannelMembersResponse


## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**code** | **int** | |
**message** | **str** | |
**members** | [**List[Member]**](Member.md) | |

## Example

```python
from line_works.openapi.talk.models.get_channel_members_response import GetChannelMembersResponse

# TODO update the JSON string below
json = "{}"
# create an instance of GetChannelMembersResponse from a JSON string
get_channel_members_response_instance = GetChannelMembersResponse.from_json(json)
# print the JSON string representation of the object
print(GetChannelMembersResponse.to_json())

# convert the object into a dict
get_channel_members_response_dict = get_channel_members_response_instance.to_dict()
# create an instance of GetChannelMembersResponse from a dict
get_channel_members_response_from_dict = GetChannelMembersResponse.from_dict(get_channel_members_response_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


51 changes: 51 additions & 0 deletions docs/Member.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Member


## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**user_no** | **int** | |
**name** | **str** | |
**i18n_name** | **str** | |
**i18n_names** | **List[object]** | |
**nick_name** | **str** | |
**position** | **str** | |
**i18n_positions** | **List[object]** | |
**group_name** | **str** | |
**i18n_group_names** | **List[object]** | |
**group_position** | **str** | |
**i18n_group_positions** | **List[object]** | |
**photo_hash** | **str** | |
**join** | **bool** | |
**join_time** | **int** | |
**update_time** | **int** | |
**domain_id** | **int** | |
**property_flag** | **int** | |
**domain_name** | **str** | |
**i18n_domain_names** | **List[object]** | |
**service_type** | **str** | |
**relation_status** | **str** | |
**tenant_id** | **int** | |
**guest** | **bool** | |

## Example

```python
from line_works.openapi.talk.models.member import Member

# TODO update the JSON string below
json = "{}"
# create an instance of Member from a JSON string
member_instance = Member.from_json(json)
# print the JSON string representation of the object
print(Member.to_json())

# convert the object into a dict
member_dict = member_instance.to_dict()
# create an instance of Member from a dict
member_from_dict = Member.from_dict(member_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


34 changes: 32 additions & 2 deletions hooks/receive_publish_packet.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from datetime import datetime

from line_works.client import LineWorks
from line_works.logger import get_file_path_logger
from line_works.mqtt.enums.notification_type import NotificationType
from line_works.mqtt.models.packet import MQTTPacket
from line_works.mqtt.models.payload.message import MessagePayload
from line_works.openapi.talk.models.get_channel_members_request import (
GetChannelMembersRequest,
)

logger = get_file_path_logger(__name__)

Expand All @@ -24,8 +29,33 @@ def receive_publish_packet(w: LineWorks, p: MQTTPacket) -> None:
elif payload.loc_args1 == "/msg":
w.send_text_message(payload.channel_no, f"{payload!r}")

elif payload.loc_args1 == "/id":
w.send_text_message(payload.channel_no, str(payload.from_user_no))

elif payload.loc_args1 == "/join_time":
r = w.get_channel_members(
get_channel_members_request=GetChannelMembersRequest(
channel_no=payload.channel_no
)
)
m = next(
filter(lambda m: m.user_no == payload.from_user_no, r.members),
None,
)
if m:
j_time = datetime.fromtimestamp(int(m.join_time / 1000))
w.send_text_message(payload.channel_no, f"{j_time!r}")
else:
w.send_text_message(payload.channel_no, "not found")

elif payload.loc_args1 == "/members":
r = w.get_channel_members_with_http_info(
get_channel_members_request=GetChannelMembersRequest(
channel_no=payload.channel_no
)
)
w.send_text_message(payload.channel_no, f"{r.data.members[0]!r}")

if payload.notification_type == NotificationType.NOTIFICATION_STICKER:
w.send_text_message(payload.channel_no, "スタンプ")
w.send_text_message(payload.channel_no, f"{payload.sticker=}")

w.send_sticker_message(payload.channel_no, payload.sticker)
3 changes: 3 additions & 0 deletions line_works/openapi/talk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
from line_works.openapi.talk.models.base_response import BaseResponse
from line_works.openapi.talk.models.caller import Caller
from line_works.openapi.talk.models.email import Email
from line_works.openapi.talk.models.get_channel_members_request import GetChannelMembersRequest
from line_works.openapi.talk.models.get_channel_members_response import GetChannelMembersResponse
from line_works.openapi.talk.models.member import Member
from line_works.openapi.talk.models.my_info import MyInfo
from line_works.openapi.talk.models.name import Name
from line_works.openapi.talk.models.organization import Organization
Expand Down
Loading

0 comments on commit 83b1b95

Please sign in to comment.