Skip to content

Commit

Permalink
Merge pull request #53 from ginping/opt/openapi_endpoint
Browse files Browse the repository at this point in the history
🐛 fix: 优化 DINGTALK_OPENAPI_ENDPOINT 变量, 避免设置了 DINGTALK_OPENAPI_ENDPOI…
  • Loading branch information
ginping authored Dec 13, 2024
2 parents 262f2bf + 8a86cf1 commit 4c3f540
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dingtalk_stream/card_replier.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def finish(self, card_instance_id: str, card_data: dict):
card_data_with_status["flowStatus"] = AICardStatus.FINISHED
self.put_card_data(card_instance_id, card_data_with_status)

async def finish(self, card_instance_id: str, card_data: dict):
async def async_finish(self, card_instance_id: str, card_data: dict):
"""
AI卡片执行完成的接口,整体更新
:param card_instance_id:
Expand Down
6 changes: 3 additions & 3 deletions dingtalk_stream/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
from .frames import EventMessage
from .frames import CallbackMessage
from .log import setup_default_logger
from .utils import get_dingtalk_endpoint
from .utils import DINGTALK_OPENAPI_ENDPOINT
from .version import VERSION_STRING


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

def __init__(self, credential: Credential, logger: logging.Logger = None):
Expand Down Expand Up @@ -198,7 +198,7 @@ def get_access_token(self):
'appSecret': self.credential.client_secret,
}
try:
url = get_dingtalk_endpoint() + '/v1.0/oauth2/accessToken'
url = DINGTALK_OPENAPI_ENDPOINT + '/v1.0/oauth2/accessToken'
response_text = ''
response = requests.post(url,
headers=request_headers,
Expand Down
9 changes: 3 additions & 6 deletions dingtalk_stream/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import os

DINGTALK_OPENAPI_ENDPOINT = "https://api.dingtalk.com"
DINGTALK_OPENAPI_ENDPOINT = os.getenv(
"DINGTALK_OPENAPI_ENDPOINT", "https://api.dingtalk.com"
)

def get_dingtalk_endpoint():
endpoint_env = os.getenv('DINGTALK_OPENAPI_ENDPOINT')
if endpoint_env:
return endpoint_env
return DINGTALK_OPENAPI_ENDPOINT
2 changes: 1 addition & 1 deletion dingtalk_stream/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION_STRING = '0.22.0'
VERSION_STRING = '0.22.1'

0 comments on commit 4c3f540

Please sign in to comment.