Class: CouponFactory
- Inherits:
-
Object
- Object
- CouponFactory
- Defined in:
- lib/coupon_factory.rb
Class Method Summary collapse
-
.create_coupon_from_item(item, site_id, vendor_id) ⇒ Object
Deprecated.
- .update_coupon_with_item(coupon, item, site_id, vendor_id) ⇒ Object
Class Method Details
.create_coupon_from_item(item, site_id, vendor_id) ⇒ Object
Deprecated
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/coupon_factory.rb', line 53 def self.create_coupon_from_item(item, site_id, vendor_id) site = Site.find(site_id) vendor = Vendor.find(vendor_id) advertiser_name = item.xpath("./advertiser-name/text()").to_s advertiser = self.check_advertiser(advertiser_name, site.id, vendor.id) coupon = Coupon.new() coupon.site_id = site.id coupon.vendor_id = vendor.id coupon.advertiser_id = advertiser.id coupon.code = item.xpath("./couponcode/text()").to_s coupon.description = item.xpath("./description/text()").to_s coupon.link = item.xpath("./link/*").to_s coupon.save #set up the categories coupon = self.add_categories_to_coupon(coupon,item) coupon = self.add_products_to_coupon(coupon,item) return coupon #set up the products =begin coupon.item_id = item.xpath("./item-id/text()").to_s.to_i coupon.category = item.xpath("./category/text()").to_s coupon.language = item.xpath("./language/text()").to_s coupon.click_commission = item.xpath("./click-commission/text()").to_s coupon.lead_commission = item.xpath("./lead-commission/text()").to_s coupon.item_code_html = item.xpath("./item-code-html/*").to_s coupon.item_code_description = item.xpath("./item-code-description/text()").to_s coupon.item_code_destination = item.xpath("./item-code-destination/text()").to_s coupon.item_name = item.xpath("./item-name/text()").to_s coupon.item_type = item.xpath("./item-type/text()").to_s coupon.performance_incentive = item.xpath("./performance-incentive/text()").to_s coupon.promotion_start = item.xpath("./promotion-start-date/text()").to_s coupon.promotion_end = item.xpath("./promotion-end-date/text()").to_s coupon.promotion_type = item.xpath("./promotion-type/text()").to_s coupon.ad_relationship = item.xpath("./relationship-status/text()").to_s coupon.sale_commission = item.xpath("./sale-commission/text()").to_s coupon.seven_day_epc = item.xpath("./seven-day-epc/text()").to_s.to_f coupon.three_month_epc = item.xpath("./three-month-epc/text()").to_s.to_f =end end |
.update_coupon_with_item(coupon, item, site_id, vendor_id) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/coupon_factory.rb', line 3 def self.update_coupon_with_item(coupon,item,site_id,vendor_id) site = Site.find(site_id) vendor = Vendor.find(vendor_id) advertiser_name = item.xpath("./advertiser-name/text()").to_s advertiser_id = item.xpath("./advertiser-id/text()").to_s advertiser = self.check_advertiser(advertiser_id, advertiser_name, site.id, vendor.id) coupon.site_id = site.id coupon.vendor_id = vendor.id coupon.advertiser_id = advertiser.id coupon.code = item.xpath("./couponcode/text()").to_s coupon.description = item.xpath("./description/text()").to_s coupon.link = item.xpath("./link/*").to_s coupon.save #sort out categories coupon.categories.clear coupon = self.add_categories_to_coupon(coupon,item) #sort out products coupon.products.clear coupon = self.add_products_to_coupon(coupon,item) return coupon =begin coupon.advertiser_name = item.xpath("./advertiser-name/text()").to_s coupon.category = item.xpath("./category/text()").to_s coupon.language = item.xpath("./language/text()").to_s coupon.click_commission = item.xpath("./click-commission/text()").to_s coupon.lead_commission = item.xpath("./lead-commission/text()").to_s coupon.item_code_html = item.xpath("./item-code-html/*").to_s coupon.item_code_description = item.xpath("./item-code-description/text()").to_s coupon.item_code_destination = item.xpath("./item-code-destination/text()").to_s coupon.item_name = item.xpath("./item-name/text()").to_s coupon.item_type = item.xpath("./item-type/text()").to_s coupon.performance_incentive = item.xpath("./performance-incentive/text()").to_s coupon.start_date = item.xpath("./startdate/text()").to_s coupon.end_date = item.xpath("./enddate/text()").to_s coupon.promotion_type = item.xpath("./promotion-type/text()").to_s coupon.ad_relationship = item.xpath("./relationship-status/text()").to_s coupon.sale_commission = item.xpath("./sale-commission/text()").to_s coupon.seven_day_epc = item.xpath("./seven-day-epc/text()").to_s.to_f coupon.three_month_epc = item.xpath("./three-month-epc/text()").to_s.to_f =end end |