Skip to content

Commit

Permalink
[Zendesk] connector improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneLightsOn committed Dec 22, 2023
1 parent 2c74c45 commit 3877e5f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions zendesk/provider/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
BEARER_PREFIX = "Bearer "
DEFAULT_LIMIT = 20

client = None


class ZendeskClient:
def __init__(self, email, domain, access_token, limit):
Expand All @@ -29,11 +31,13 @@ def search(self, query):


def get_client():
assert (email := app.config.get("EMAIL")), "ZENDESK_EMAIL must be set"
assert (domain := app.config.get("DOMAIN")), "ZENDESK_DOMAIN must be set"
assert (token := app.config.get("API_TOKEN")), "ZENDESK_API_TOKEN must be set"
limit = app.config.get("SEARCH_LIMIT", DEFAULT_LIMIT)

client = ZendeskClient(email, domain, token, limit)
global client
if client is None:
assert (email := app.config.get("EMAIL")), "ZENDESK_EMAIL must be set"
assert (domain := app.config.get("DOMAIN")), "ZENDESK_DOMAIN must be set"
assert (token := app.config.get("API_TOKEN")), "ZENDESK_API_TOKEN must be set"
limit = app.config.get("SEARCH_LIMIT", DEFAULT_LIMIT)

client = ZendeskClient(email, domain, token, limit)

return client

0 comments on commit 3877e5f

Please sign in to comment.