Skip to content

Commit 4c3f540

Browse files
authored
Merge pull request #53 from ginping/opt/openapi_endpoint
🐛 fix: 优化 DINGTALK_OPENAPI_ENDPOINT 变量, 避免设置了 DINGTALK_OPENAPI_ENDPOI…
2 parents 262f2bf + 8a86cf1 commit 4c3f540

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

dingtalk_stream/card_replier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ def finish(self, card_instance_id: str, card_data: dict):
686686
card_data_with_status["flowStatus"] = AICardStatus.FINISHED
687687
self.put_card_data(card_instance_id, card_data_with_status)
688688

689-
async def finish(self, card_instance_id: str, card_data: dict):
689+
async def async_finish(self, card_instance_id: str, card_data: dict):
690690
"""
691691
AI卡片执行完成的接口,整体更新
692692
:param card_instance_id:

dingtalk_stream/stream.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
from .frames import EventMessage
2323
from .frames import CallbackMessage
2424
from .log import setup_default_logger
25-
from .utils import get_dingtalk_endpoint
25+
from .utils import DINGTALK_OPENAPI_ENDPOINT
2626
from .version import VERSION_STRING
2727

2828

2929
class DingTalkStreamClient(object):
30-
OPEN_CONNECTION_API = get_dingtalk_endpoint() + '/v1.0/gateway/connections/open'
30+
OPEN_CONNECTION_API = DINGTALK_OPENAPI_ENDPOINT + '/v1.0/gateway/connections/open'
3131
TAG_DISCONNECT = 'disconnect'
3232

3333
def __init__(self, credential: Credential, logger: logging.Logger = None):
@@ -198,7 +198,7 @@ def get_access_token(self):
198198
'appSecret': self.credential.client_secret,
199199
}
200200
try:
201-
url = get_dingtalk_endpoint() + '/v1.0/oauth2/accessToken'
201+
url = DINGTALK_OPENAPI_ENDPOINT + '/v1.0/oauth2/accessToken'
202202
response_text = ''
203203
response = requests.post(url,
204204
headers=request_headers,

dingtalk_stream/utils.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import os
44

5-
DINGTALK_OPENAPI_ENDPOINT = "https://api.dingtalk.com"
5+
DINGTALK_OPENAPI_ENDPOINT = os.getenv(
6+
"DINGTALK_OPENAPI_ENDPOINT", "https://api.dingtalk.com"
7+
)
68

7-
def get_dingtalk_endpoint():
8-
endpoint_env = os.getenv('DINGTALK_OPENAPI_ENDPOINT')
9-
if endpoint_env:
10-
return endpoint_env
11-
return DINGTALK_OPENAPI_ENDPOINT

dingtalk_stream/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION_STRING = '0.22.0'
1+
VERSION_STRING = '0.22.1'

0 commit comments

Comments
 (0)