コード例 #1
0
    def search_by_custom_fields(self,
                                list_uid: str,
                                fields: dict,
                                page=1,
                                per_page=10):
        """
        Search in a list by custom fields
        :param list_uid:
        :param fields:
        :param page:
        :param per_page:
        :return:
        """

        params_get = fields
        params_get[page] = page
        params_get[per_page] = per_page

        client = Client({
            'method':
            Client.METHOD_GET,
            'url':
            self.config.get_api_url(
                'lists/{list_uid}/subscribers/search-by-custom-fields'.format(
                    list_uid=list_uid)),
            'params_get':
            params_get
        })

        return client.request()
コード例 #2
0
    def delete(self, list_uid: str):
        """
        Delete one list
        :param list_uid:
        :return:
        """

        client = Client({
            'method': Client.METHOD_DELETE,
            'url': self.config.get_api_url('lists/{list_uid}'.format(list_uid=list_uid)),
        })

        return client.request()
コード例 #3
0
    def copy(self, list_uid: str):
        """
        Copy one list
        :param list_uid:
        :return:
        """

        client = Client({
            'method': Client.METHOD_POST,
            'url': self.config.get_api_url('lists/{list_uid}/copy'.format(list_uid=list_uid)),
        })

        return client.request()
コード例 #4
0
    def delete(self, template_uid: str):
        """
        Delete one template
        :param template_uid:
        :return:
        """

        client = Client({
            'method': Client.METHOD_DELETE,
            'url': self.config.get_api_url('templates/{template_uid}'.format(template_uid=template_uid)),
        })

        return client.request()
コード例 #5
0
    def delete(self, email_uid: str):
        """
        Delete one email
        :param email_uid:
        :return:
        """

        client = Client({
            'method': Client.METHOD_DELETE,
            'url': self.config.get_api_url('transactional-emails/{email_uid}'.format(email_uid=email_uid)),
        })

        return client.request()
コード例 #6
0
    def get_email(self, email_uid: str):
        """
        Get one email
        :param email_uid:
        :return:
        """

        client = Client({
            'method': Client.METHOD_GET,
            'url': self.config.get_api_url('transactional-emails/{email_uid}'.format(email_uid=email_uid)),
            'params_get': {}
        })

        return client.request()
コード例 #7
0
    def create(self, data: dict):
        """
        Create a new template
        :param data:
        :return:
        """

        client = Client({
            'method': Client.METHOD_POST,
            'url': self.config.get_api_url('templates'),
            'params_post': self._prepare_body(data)
        })

        return client.request()
コード例 #8
0
    def get_list(self, list_uid: str):
        """
        Get one list
        :param list_uid:
        :return:
        """

        client = Client({
            'method': Client.METHOD_GET,
            'url': self.config.get_api_url('lists/{list_uid}'.format(list_uid=list_uid)),
            'params_get': {}
        })

        return client.request()
コード例 #9
0
    def get_template(self, template_uid: str):
        """
        Get one template
        :param template_uid:
        :return:
        """

        client = Client({
            'method': Client.METHOD_GET,
            'url': self.config.get_api_url('templates/{template_uid}'.format(template_uid=template_uid)),
            'params_get': {}
        })

        return client.request()
コード例 #10
0
    def update(self, list_uid: str, data: dict):
        """
        Update one list
        :param list_uid:
        :param data:
        :return:
        """

        client = Client({
            'method': Client.METHOD_PUT,
            'url': self.config.get_api_url('lists/{list_uid}'.format(list_uid=list_uid)),
            'params_put': self._prepare_body(data)
        })

        return client.request()
コード例 #11
0
    def update(self, template_uid: str, data: dict):
        """
        Update one template
        :param template_uid:
        :param data:
        :return:
        """

        client = Client({
            'method': Client.METHOD_PUT,
            'url': self.config.get_api_url('templates/{template_uid}'.format(template_uid=template_uid)),
            'params_put': self._prepare_body(data)
        })

        return client.request()
コード例 #12
0
    def copy(self, campaign_uid: str):
        """
        Copy one campaign
        :param campaign_uid:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_POST,
            'url':
            self.config.get_api_url('campaigns/{campaign_uid}/copy'.format(
                campaign_uid=campaign_uid)),
        })

        return client.request()
コード例 #13
0
    def delete(self, campaign_uid: str):
        """
        Delete one campaign
        :param campaign_uid:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_DELETE,
            'url':
            self.config.get_api_url(
                'campaigns/{campaign_uid}'.format(campaign_uid=campaign_uid)),
        })

        return client.request()
コード例 #14
0
    def pause_unpause(self, campaign_uid: str):
        """
        Pause/Unpause one campaign
        :param campaign_uid:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_PUT,
            'url':
            self.config.get_api_url(
                'campaigns/{campaign_uid}/pause-unpause'.format(
                    campaign_uid=campaign_uid)),
        })

        return client.request()
コード例 #15
0
    def get_campaign(self, campaign_uid: str):
        """
        Get one campaign
        :param campaign_uid:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_GET,
            'url':
            self.config.get_api_url(
                'campaigns/{campaign_uid}'.format(campaign_uid=campaign_uid)),
            'params_get': {}
        })

        return client.request()
コード例 #16
0
    def mark_sent(self, campaign_uid: str):
        """
        Mark as sent one campaign
        :param campaign_uid:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_PUT,
            'url':
            self.config.get_api_url(
                'campaigns/{campaign_uid}/mark-sent'.format(
                    campaign_uid=campaign_uid)),
        })

        return client.request()
コード例 #17
0
    def get_fields(self, list_uid: str):
        """
        Get fields from a certain mail list
        :param list_uid:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_GET,
            'url':
            self.config.get_api_url(
                'lists/{list_uid}/fields'.format(list_uid=list_uid)),
            'params_get': {}
        })

        return client.request()
コード例 #18
0
    def get_templates(self, page=1, per_page=10):
        """
        Get all the email templates of the current customer
        :param page:
        :param per_page:
        :return:
        """

        client = Client({
            'method': Client.METHOD_GET,
            'url': self.config.get_api_url('templates'),
            'params_get': {
                'page': page,
                'per_page': per_page
            }
        })

        return client.request()
コード例 #19
0
    def get_countries(self, page=1, per_page=10):
        """
        Get all available countries
        :param page:
        :param per_page:
        :return:
        """

        client = Client({
            'method': Client.METHOD_GET,
            'url': self.config.get_api_url('countries'),
            'params_get': {
                'page': page,
                'per_page': per_page
            }
        })

        return client.request()
コード例 #20
0
    def get_subscriber(self, list_uid: str, subscriber_uid: str):
        """
        Get one subscriber from a certain mail list
        :param list_uid:
        :param subscriber_uid:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_GET,
            'url':
            self.config.get_api_url(
                'lists/{list_uid}/subscribers/{subscriber_uid}'.format(
                    list_uid=list_uid, subscriber_uid=subscriber_uid)),
            'params_get': {}
        })

        return client.request()
コード例 #21
0
    def update(self, campaign_uid: str, data: dict):
        """
        Update one campaign
        :param campaign_uid:
        :param data:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_PUT,
            'url':
            self.config.get_api_url(
                'campaigns/{campaign_uid}'.format(campaign_uid=campaign_uid)),
            'params_put':
            self._prepare_body(data)
        })

        return client.request()
コード例 #22
0
    def unsubscribe(self, list_uid: str, subscriber_uid: str):
        """
        Unsubscribe existing subscriber from given list
        :param list_uid:
        :param subscriber_uid:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_PUT,
            'url':
            self.config.get_api_url(
                'lists/{list_uid}/subscribers/{subscriber_uid}/unsubscribe'.
                format(list_uid=list_uid, subscriber_uid=subscriber_uid)),
            'params_put': {}
        })

        return client.request()
コード例 #23
0
    def unsubscribe_by_email_from_all_lists(self, email_address: str):
        """
        Unsubscribe existing subscriber by email address from all lists
        :param email_address:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_PUT,
            'url':
            self.config.get_api_url(
                'lists/subscribers/unsubscribe-by-email-from-all-lists'),
            'params_put': {
                'EMAIL': email_address
            }
        })

        return client.request()
コード例 #24
0
    def create(self, data: dict):
        """
        Create a new mail list for the customer
        The data param must contain following keys:
            -> general
            -> defaults
            -> notifications
            -> company
        :param data:
        :return:
        """

        client = Client({
            'method': Client.METHOD_POST,
            'url': self.config.get_api_url('lists'),
            'params_post': self._prepare_body(data)
        })

        return client.request()
コード例 #25
0
    def delete(self, list_uid: str, subscriber_uid: str):
        """
        Delete existing subscriber from given list
        :param list_uid:
        :param subscriber_uid:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_DELETE,
            'url':
            self.config.get_api_url(
                'lists/{list_uid}/subscribers/{subscriber_uid}'.format(
                    list_uid=list_uid, subscriber_uid=subscriber_uid)),
            'params_delete': {}
        })

        return client.request()
コード例 #26
0
    def create(self, list_uid: str, data: dict):
        """
        Create a new subscriber in the given list
        :param list_uid:
        :param data:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_POST,
            'url':
            self.config.get_api_url(
                'lists/{list_uid}/subscribers'.format(list_uid=list_uid)),
            'params_post':
            data
        })

        return client.request()
コード例 #27
0
    def create(self, campaign_uid: str, data: dict):
        """
        Create a new bounce in the given campaign
        :param campaign_uid:
        :param data:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_POST,
            'url':
            self.config.get_api_url('campaigns/{campaign_uid}/bounces'.format(
                campaign_uid=campaign_uid)),
            'params_post':
            self._prepare_body(data)
        })

        return client.request()
コード例 #28
0
    def email_search_all_lists(self, email_address: str):
        """
        Search in a all lists for given subscriber by email address
        Please note that this is available only for mailwizz >= 1.3.6.2
        :param email_address:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_GET,
            'url':
            self.config.get_api_url(
                'lists/subscribers/search-by-email-in-all-lists'),
            'params_get': {
                'EMAIL': email_address
            }
        })

        return client.request()
コード例 #29
0
    def track_opening(self, campaign_uid: str, subscriber_uid: str):
        """
        Track campaign url click for certain subscriber
        :param campaign_uid:
        :param subscriber_uid:
        :return:
        """

        client = Client({
            'method': Client.METHOD_GET,
            'url': self.config.get_api_url(
                'campaigns/{campaign_uid}/track-opening/{subscriber_uid}'.format(
                    campaign_uid=campaign_uid,
                    subscriber_uid=subscriber_uid
                )
            ),
            'params_get': {}
        })

        return client.request()
コード例 #30
0
    def create_bulk(self, list_uid: str, data):
        """
        Create subscribers in bulk in the given list
        This feature is available since  1.8.1
        :param list_uid:
        :param data:
        :return:
        """

        client = Client({
            'method':
            Client.METHOD_POST,
            'url':
            self.config.get_api_url(
                'lists/{list_uid}/subscribers/bulk'.format(list_uid=list_uid)),
            'params_post':
            self._prepare_body(data)
        })

        return client.request()