From d35afaa71d18a8aed4028ed645e52fc7e15c7474 Mon Sep 17 00:00:00 2001 From: Jumana B Date: Mon, 15 Jul 2024 15:01:00 -0400 Subject: [PATCH] Added freshdesk api (#1892) Co-authored-by: William B <7444334+whabanks@users.noreply.github.com> --- app/notify_client/user_api_client.py | 12 ++++++++++ tests/app/notify_client/test_user_client.py | 25 +++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/app/notify_client/user_api_client.py b/app/notify_client/user_api_client.py index 18936639cb..6cbd930f63 100644 --- a/app/notify_client/user_api_client.py +++ b/app/notify_client/user_api_client.py @@ -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} diff --git a/tests/app/notify_client/test_user_client.py b/tests/app/notify_client/test_user_client.py index 04717d734d..d1e4c387df 100644 --- a/tests/app/notify_client/test_user_client.py +++ b/tests/app/notify_client/test_user_client.py @@ -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)