示例#1
0
    def get(self, _id, w_id, **kwargs):
        """
        Here _id is an id of advertising campaign and
        w_id is a id of website

        Args:
            _id (int)
            w_id (int)
            mobile_content (bool)
            landing (int)
            uri_scheme (str)
            limit (int)
            offset (int)

        """
        request_data = {
            'url': self.URL,
            'campaign_id': Item.sanitize_id(_id),
            'website_id': Item.sanitize_id(w_id)
        }

        filtering = {
            'filter_by': kwargs,
            'available': {
                'mobile_content': lambda x: Item.sanitize_bool_value(x, blank=True),
                'landing': lambda x: Item.sanitize_integer_value(x, 'landing', blank=True),
                'uri_scheme': lambda x: Item.sanitize_string_value(x, 'uri_scheme', blank=True)
            }
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_filtering(filtering) \
                   .request(**request_data)
示例#2
0
    def get(self, payment_id, **kwargs):
        """
        Args:
            detailed (bool)
            limit (int)
            offset (int)

        """
        filtering = {
            'filter_by': kwargs,
            'available': {
                'detailed':
                lambda x: Item.sanitize_bool_integer_value(
                    x, 'detailed', blank=True)
            }
        }

        request_data = {
            'url': self.URL,
            'payment_id': Item.sanitize_id(payment_id)
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_filtering(filtering) \
                   .request(**request_data)
示例#3
0
    def getOne(self, _id, c_id, **kwargs):
        """
        Here _id is a website id and c_id is a campaign id

        Args:
            _id (int)
            c_id (int)

        """
        request_data = {
            'url': self.SINGLE_URL,
            'website_id': Item.sanitize_id(_id),
            'campaign_id': Item.sanitize_id(c_id)
        }

        return self.transport.get().request(**request_data)
示例#4
0
    def get(self, _id, **kwargs):
        """
        Here _id is a websites id

        Args:
            _id (int)
            campaign (list of int)
            campaign_category (list of int)
            category (list of int)
            type (str)
            limit (int)
            offset (int)
            order_by (str)

        """
        request_data = {
            'url': self.URL,
            'website_id': Item.sanitize_id(_id)
        }

        filtering = {
            'filter_by': kwargs,
            'available': self.FILTERING
        }

        ordering = {
            'order_by': kwargs.get('order_by', None),
            'available': self.ORDERING
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_ordering(ordering) \
                   .set_filtering(filtering) \
                   .request(**request_data)
示例#5
0
    def get(self, _id, **kwargs):
        """
        Here _id is an id of advertising campaign

        Args:
            _id (int)
            mobile_content (bool)
            limit (int)
            offset(int)

        """
        request_data = {
            'url': self.URL,
            'campaign_id': Item.sanitize_id(_id)
        }

        filtering = {
            'filter_by': kwargs,
            'available': {
                'mobile_content': lambda x: Item.sanitize_bool_value(x, blank=True)
            }
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_filtering(filtering) \
                   .request(**request_data)
示例#6
0
    def get(self, campaign_id, website_id, **kwargs):
        """
        Args:
            campaign_id (int)
            website_id (int)
            limit (int)
            offset (int)

        """
        request_data = {
            'url': self.URL,
            'campaign_id': Item.sanitize_id(campaign_id),
            'website_id': Item.sanitize_id(website_id),
        }

        return self.transport.get().set_pagination(**kwargs).request(**request_data)
示例#7
0
    def getOne(self, _id, c_id, **kwargs):
        """
        Here _id is a website id and c_id is a campaign id

        Args:
            _id (int)
            c_id (int)

        """
        request_data = {
            'url': self.SINGLE_URL,
            'website_id': Item.sanitize_id(_id),
            'campaign_id': Item.sanitize_id(c_id)
        }

        return self.transport.get().request(**request_data)
示例#8
0
    def disconnect(self, c_id, w_id, **kwargs):
        """
        Disconnect an advertising campaign from a website
        Here w_id is a website id and c_id is a campaign id

        Args:
            c_id (int)
            w_id (int)

        """
        request_data = {
            'url': self.DISCONNECT_URL,
            'campaign_id': Item.sanitize_id(c_id),
            'website_id': Item.sanitize_id(w_id)
        }

        return self.transport.post().request(**request_data)
示例#9
0
    def update(self, optcode_id, **kwargs):
        data = Item.sanitize_fields(self.UPDATE_FIELDS, **kwargs)
        request_data = {
            'url': self.UPDATE_URL,
            'optcode_id': Item.sanitize_id(optcode_id),
        }

        return self.transport.post().set_data(data).request(**request_data)
示例#10
0
    def get(self, campaign_id, website_id, **kwargs):
        """
        Args:
            campaign_id (int)
            website_id (int)
            limit (int)
            offset (int)

        """
        request_data = {
            'url': self.URL,
            'campaign_id': Item.sanitize_id(campaign_id),
            'website_id': Item.sanitize_id(website_id),
        }

        return self.transport.get().set_pagination(**kwargs).request(
            **request_data)
示例#11
0
    def update(self, optcode_id, **kwargs):
        data = Item.sanitize_fields(self.UPDATE_FIELDS, **kwargs)
        request_data = {
            'url': self.UPDATE_URL,
            'optcode_id': Item.sanitize_id(optcode_id),
        }

        return self.transport.post().set_data(data).request(**request_data)
示例#12
0
    def disconnect(self, c_id, w_id, **kwargs):
        """
        Disconnect an advertising campaign from a website
        Here w_id is a website id and c_id is a campaign id

        Args:
            c_id (int)
            w_id (int)

        """
        request_data = {
            'url': self.DISCONNECT_URL,
            'campaign_id': Item.sanitize_id(c_id),
            'website_id': Item.sanitize_id(w_id)
        }

        return self.transport.post().request(**request_data)
示例#13
0
    def create(self, website_id, campaign_id, **kwargs):
        """
        Args:
            website_id (int)
            campaign_id (int)
            ulp (list of str)
            subid (str)

        """
        data = Item.sanitize_fields(self.CREATE_FIELDS, **kwargs)

        request_data = {
            'url': self.CREATE_URL,
            'website_id': Item.sanitize_id(website_id),
            'campaign_id': Item.sanitize_id(campaign_id),
        }

        return self.transport.get().set_data(data).request(**request_data)
示例#14
0
    def create(self, website_id, campaign_id, **kwargs):
        """
        Args:
            website_id (int)
            campaign_id (int)
            ulp (list of str)
            subid (str)

        """
        data = Item.sanitize_fields(self.CREATE_FIELDS, **kwargs)

        request_data = {
            'url': self.CREATE_URL,
            'website_id': Item.sanitize_id(website_id),
            'campaign_id': Item.sanitize_id(campaign_id),
        }

        return self.transport.get().set_data(data).request(**request_data)
示例#15
0
    def verify(self, _id):
        """
        Args:
            _id (int)

        """
        request_data = {
            'url': self.VERIFY_URL,
            'website_id': Item.sanitize_id(_id)
        }

        return self.transport.post().request(**request_data)
示例#16
0
    def getOne(self, broken_link_id):
        """
        Args:
            broken_link_id (int)

        """
        request_data = {
            'url': self.SINGLE_URL,
            'broken_link_id': Item.sanitize_id(broken_link_id)
        }

        return self.transport.get().request(**request_data)
示例#17
0
    def getOne(self, broken_link_id):
        """
        Args:
            broken_link_id (int)

        """
        request_data = {
            'url': self.SINGLE_URL,
            'broken_link_id': Item.sanitize_id(broken_link_id)
        }

        return self.transport.get().request(**request_data)
示例#18
0
    def getOne(self, coupon_category_id):
        """
        Args:
            coupon_category_id (int)

        """
        request_data = {
            'url': self.SINGLE_URL,
            'coupon_category_id': Item.sanitize_id(coupon_category_id)
        }

        return self.transport.get().request(**request_data)
示例#19
0
    def getLevelsForCampaign(self, campaign_id):
        """
        Args:
            capaign_id (int)

        """
        request_data = {
            'url': self.LEVELS_FOR_CAMPAIGN_URL,
            'campaign_id': Item.sanitize_id(campaign_id)
        }

        return self.transport.get().request(**request_data)
示例#20
0
    def getLevelsForWebsite(self, website_id):
        """
        Args:
            website_id (int)

        """
        request_data = {
            'url': self.LEVELS_FOR_WEBSITE_URL,
            'website_id': Item.sanitize_id(website_id)
        }

        return self.transport.get().request(**request_data)
示例#21
0
    def getOne(self, retag_id):
        """
        Args:
            retag_id (int)

        """
        request_data = {
            'url': self.SINGLE_URL,
            'retag_id': Item.sanitize_id(retag_id)
        }

        return self.transport.get().request(**request_data)
示例#22
0
    def delete(self, _id):
        """
        Args:
            _id (int)

        """
        request_data = {
            'url': self.DELETE_URL,
            'website_id': Item.sanitize_id(_id)
        }

        return self.transport.post().request(**request_data)
示例#23
0
    def delete(self, lost_order_id):
        """
        Args:
            lost_order_id (int)

        """
        request_data = {
            'url': self.DELETE_URL,
            'lost_order_id': Item.sanitize_id(lost_order_id),
        }

        return self.transport.delete().request(**request_data)
示例#24
0
    def getOne(self, _id, **kwargs):
        """
        Args:
            _id (int)

        """
        request_data = {
            'url': self.SINGLE_URL,
            'payment_id': Item.sanitize_id(_id)
        }

        return self.transport.get().request(**request_data)
示例#25
0
    def getOne(self, lost_order_id):
        """
        Args:
            lost_order_id (int)

        """
        request_data = {
            'url': self.SINGLE_URL,
            'lost_order_id': Item.sanitize_id(lost_order_id)
        }

        return self.transport.get().request(**request_data)
示例#26
0
    def getOne(self, _id, **kwargs):
        """
        Args:
            _id (int)

        """
        request_data = {
            'url': self.SINGLE_URL,
            'referral_id': Item.sanitize_id(_id)
        }

        return self.transport.get().request(**request_data)
示例#27
0
    def get(self, _id, **kwargs):
        """
        Here _id is a website id

        Args:
            _id (int)
            limit (int)
            offset (int)

        """
        request_data = {'url': self.URL, 'website_id': Item.sanitize_id(_id)}

        return self.transport.get().set_pagination(**kwargs).request(
            **request_data)
示例#28
0
    def delete(self, _id, **kwargs):
        """
        Delete a payment request.
        _id is a payment id.

        Args:
            _id (int)

        """
        request_data = {
            'url': self.DELETE_URL,
            'payment_id': Item.sanitize_id(_id)
        }

        return self.transport.post().request(**request_data)
示例#29
0
    def confirm(self, _id, **kwargs):
        """
        Confirm a payment request.
        _id is a payment id.

        Args:
            _id (int)

        """
        request_data = {
            'url': self.CONFIRM_URL,
            'payment_id': Item.sanitize_id(_id)
        }

        return self.transport.post().request(**request_data)
示例#30
0
    def comment(self, ticket_id, **kwargs):
        """
        Args:
            ticket_id (int)
            text (str)

        """
        request_data = {
            'url': self.COMMENT_URL,
            'ticket_id': Item.sanitize_id(ticket_id)
        }

        data = Item.sanitize_fields(self.COMMENT_FIELDS, **kwargs)

        return self.transport.post().set_data(data).request(**request_data)
示例#31
0
    def delete(self, _id, **kwargs):
        """
        Delete a payment request.
        _id is a payment id.

        Args:
            _id (int)

        """
        request_data = {
            'url': self.DELETE_URL,
            'payment_id': Item.sanitize_id(_id)
        }

        return self.transport.post().request(**request_data)
示例#32
0
    def confirm(self, _id, **kwargs):
        """
        Confirm a payment request.
        _id is a payment id.

        Args:
            _id (int)

        """
        request_data = {
            'url': self.CONFIRM_URL,
            'payment_id': Item.sanitize_id(_id)
        }

        return self.transport.post().request(**request_data)
示例#33
0
    def get(self, _id, **kwargs):
        """
        Here _id is a website id

        Args:
            _id (int)
            limit (int)
            offset (int)

        """
        request_data = {
            'url': self.URL,
            'website_id': Item.sanitize_id(_id)
        }

        return self.transport.get().set_pagination(**kwargs).request(**request_data)
示例#34
0
    def update(self, lost_order_id, appeal_status):
        """
        Args:
            lost_order_id (int)
            appeal_status (str)

        """
        request_data = {
            'url': self.UPDATE_URL,
            'lost_order_id': Item.sanitize_id(lost_order_id),
        }

        data = {
            'appeal_status': self.sanitize_string_value(appeal_status, 'appeal_status'),
        }

        return self.transport.put().set_data(data).request(**request_data)
示例#35
0
    def update(self, retag_id, **kwargs):
        """
        Args:
            retag_id (int)
            level (int)
            active (bool)
            script (str)
            comment (str)

        """
        request_data = {
            'url': self.UPDATE_URL,
            'retag_id': Item.sanitize_id(retag_id)
        }

        data = Item.sanitize_fields(self.UPDATE_FIELDS, **kwargs)

        return self.transport.post().set_data(data).request(**request_data)
示例#36
0
    def getOne(self, _id, **kwargs):
        """
        Args:
            _id (int)
            language (str)

        """
        filtering = {
            'filter_by': kwargs,
            'available': {
                'language':
                lambda x: Item.sanitize_string_value(x, 'language', 2, 2, True
                                                     ),
            }
        }

        request_data = {
            'url': self.SINGLE_URL,
            'announcement_id': Item.sanitize_id(_id)
        }

        return self.transport.get().set_filtering(filtering).request(
            **request_data)
示例#37
0
    def update(self, _id, **kwargs):
        """
        Args:
            _id (int)
            name (str)
            kind (str)
            language (str)
            adservice (int)
            site_url (str)
            description (str)
            categories (list of int)
            regions (list of str)
            mailing_targeting (bool)

        """
        data = Item.sanitize_fields(self.UPDATE_FIELDS, **kwargs)

        request_data = {
            'url': self.UPDATE_URL,
            'website_id': Item.sanitize_id(_id)
        }

        return self.transport.post().set_data(data).request(**request_data)
示例#38
0
    def get(self, payment_id, **kwargs):
        """
        Args:
            detailed (bool)
            limit (int)
            offset (int)

        """
        filtering = {
            'filter_by': kwargs,
            'available': {
                'detailed': lambda x: Item.sanitize_bool_integer_value(x, 'detailed', blank=True)
            }
        }

        request_data = {
            'url': self.URL,
            'payment_id': Item.sanitize_id(payment_id)
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_filtering(filtering) \
                   .request(**request_data)
示例#39
0
 def delete(self, optcode_id):
     request_data = {
         'url': self.DELETE_URL,
         'optcode_id': Item.sanitize_id(optcode_id),
     }
     return self.transport.post().request(**request_data)
示例#40
0
    def test_sanitize_id(self):
        self.assertEqual(Item.sanitize_id(2, ''), 2)
        self.assertEqual(Item.sanitize_id(2**64, ''), 2**64)
        self.assertEqual(Item.sanitize_id('64', ''), '64')

        with self.assertRaises(ValueError):
            Item.sanitize_id(0, '')
            Item.sanitize_id(None, '')
            Item.sanitize_id(3.14, '')
            Item.sanitize_id('foo', '')
示例#41
0
 def delete(self, optcode_id):
     request_data = {
         'url': self.DELETE_URL,
         'optcode_id': Item.sanitize_id(optcode_id),
     }
     return self.transport.post().request(**request_data)