From d935003694d1a4e5343ad81456b57ae7ad001b6a Mon Sep 17 00:00:00 2001 From: ghimes Date: Thu, 18 Apr 2024 10:34:44 +0300 Subject: [PATCH] added endpoint to get the list segment subscribers --- examples/list_segments.py | 20 +++++++++++++ mailwizz/endpoint/list_segments.py | 48 ++++++++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/examples/list_segments.py b/examples/list_segments.py index 3b93896..3867c5e 100644 --- a/examples/list_segments.py +++ b/examples/list_segments.py @@ -21,3 +21,23 @@ DISPLAY RESPONSE """ print(response.content) + +""" +GET ONE ITEM +""" +response = endpoint.get_segment(list_uid='LIST_UID', segment_uid='SEGMENT_UID') + +""" +DISPLAY RESPONSE +""" +print(response.content) + +""" +GET ALL SUBSCRIBERS OF A LIST SEGMENT +""" +response = endpoint.get_subscribers(list_uid='LIST_UID', segment_uid='SEGMENT_UID', page=1, per_page=10) + +""" +DISPLAY RESPONSE +""" +print(response.content) \ No newline at end of file diff --git a/mailwizz/endpoint/list_segments.py b/mailwizz/endpoint/list_segments.py index 094126e..16a4374 100644 --- a/mailwizz/endpoint/list_segments.py +++ b/mailwizz/endpoint/list_segments.py @@ -26,3 +26,51 @@ def get_segments(self, list_uid: str, page=1, per_page=10): }) return client.request() + + def get_segment(self, list_uid: str, segment_uid: str): + """ + Get segments from a certain mail list + :param list_uid: + :param segment_uid: + :return: + """ + + client = Client({ + 'method': Client.METHOD_GET, + 'url': self.config.get_api_url( + 'lists/{list_uid}/segments/{segment_uid}'.format( + list_uid=list_uid, + segment_uid=segment_uid + ) + ), + 'params_get': {} + }) + + return client.request() + + def get_subscribers(self, list_uid: str, segment_uid: str, page=1, per_page=10): + """ + Get subscribers from a certain mail list segment + :param list_uid: + :param segment_uid: + :param page: + :param per_page: + :return: + """ + + client = Client({ + 'method': Client.METHOD_GET, + 'url': self.config.get_api_url( + 'lists/{list_uid}/segments/{segment_uid}/subscribers'.format( + list_uid=list_uid, + segment_uid=segment_uid + ) + ), + 'params_get': { + 'page': page, + 'per_page': per_page + } + }) + + return client.request() + diff --git a/setup.py b/setup.py index c765a80..a61ddd8 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name='mailwizz-python-sdk', - version='1.0.2', + version='1.0.3', packages=setuptools.find_packages(), url='https://www.mailwizz.com', license='MIT',