class AdvertiserParser
Public Instance Methods
create_cj_advertiser_from_xml(xml)
click to toggle source
# File lib/helpers/advertiser_parser.rb, line 6 def create_cj_advertiser_from_xml(xml) doc = Nokogiri::XML(xml) doc.xpath("//advertiser").each do |advertiser_xml| advertiser_id = advertiser_xml.xpath("./advertiser-id/text()").to_s.to_i advertiser = Advertiser.find_or_create_by_advertiser_id(advertiser_id) AdvertiserFactory.update_fields(advertiser, advertiser_xml) # unless advertiser.nil? # advertiser = AdvertiserFactory.update_advertiser(advertiser_xml) # else # advertiser = AdvertiserFactory.create_advertiser(advertiser_xml) # end end # doc = FeedMapper.massage_feed(xml) # puts "create coupons from xml=====" # (doc.xpath("//item")).each do |item| # advertiser_id = item.xpath("./advertiser-id/text()") # item_id = item.xpath("./item-id/text()") # # coupon = Coupon.find_by_advertiser_id_and_item_id(advertiser_id.to_s.to_i, item_id.to_s.to_i) # # if(!coupon.nil?) # coupon = CouponFactory.update_coupon_with_item(coupon,item) # else # coupon = CouponFactory.create_coupon_from_item(item, @site_id, @vendor_id) # end # coupon.save # end end