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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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', '')