Class: AdvertiserParser

Inherits:
Object
  • Object
show all
Defined in:
lib/helpers/advertiser_parser.rb

Instance Method Summary collapse

Instance Method Details

#create_cj_advertiser_from_xml(xml) ⇒ Object



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
# 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