Skip to content

Commit

Permalink
Added freshdesk api (#1892)
Browse files Browse the repository at this point in the history
Co-authored-by: William B <[email protected]>
  • Loading branch information
jzbahrai and whabanks authored Jul 15, 2024
1 parent 35be8f4 commit d35afaa
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/notify_client/user_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ def send_branding_request(
endpoint = "/user/{0}/branding-request".format(user_id)
self.post(endpoint, data=data)

def send_new_template_category_request(
self, user_id, service_id, template_category_name_en, template_category_name_fr, template_id
):
data = {
"service_id": service_id,
"template_category_name_en": template_category_name_en,
"template_category_name_fr": template_category_name_fr,
"template_id": template_id,
}
endpoint = "/user/{0}/new-template-category-request".format(user_id)
self.post(endpoint, data=data)

@cache.delete("user-{user_id}")
def check_verify_code(self, user_id, code, code_type):
data = {"code_type": code_type, "code": code}
Expand Down
25 changes: 25 additions & 0 deletions tests/app/notify_client/test_user_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,28 @@ def test_get_last_email_login_datetime(mocker, value, expected_return):

assert user_api_client.get_last_email_login_datetime(user_id) == expected_return
mock_redis_get.assert_called_once_with(f"user-{user_id}-last-email-login")


class TestFreshdesk:

def test_send_new_template_category_request(self, mocker):
mock_post = mocker.patch("app.notify_client.user_api_client.UserApiClient.post")

data = {
"user_id": user_id,
"service_id": "456",
"template_category_name_en": "Category EN",
"template_category_name_fr": "Category FR",
"template_id": "789",
}

user_api_client.send_new_template_category_request(**data)

expected_data = {
"service_id": data["service_id"],
"template_category_name_en": data["template_category_name_en"],
"template_category_name_fr": data["template_category_name_fr"],
"template_id": data["template_id"],
}
del data["user_id"]
mock_post.assert_called_once_with(f"/user/{user_id}/new-template-category-request", data=expected_data)

0 comments on commit d35afaa

Please sign in to comment.