def get_promotion(self, code): ''' Get the promotion with the specified coupon code. https://cheddargetter.com/developers#single-promotion ''' response = self.client.make_request( path='promotions/get', params={'code': code}, ) promotion_parser = PromotionsParser() promotion_data = promotion_parser.parse_xml(response.content) return Promotion(**promotion_data[0])
def get_all_promotions(self): ''' Returns all promotions. https://cheddargetter.com/developers#promotions ''' promotions = [] try: response = self.client.make_request(path='promotions/get') except NotFound: response = None if response: promotions_parser = PromotionsParser() promotions_data = promotions_parser.parse_xml(response.content) promotions = [Promotion(**promotion_data) for promotion_data in promotions_data] return promotions