Module: TipsanityMerchantExtractor::OneEightThousandLighting

Included in:
Cj
Defined in:
lib/tipsanity_merchant_extractor/1800lighting.rb

Instance Method Summary collapse

Instance Method Details

#extract_cj_one_eight_thousand_lighting(merchant_url) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/tipsanity_merchant_extractor/1800lighting.rb', line 11

def extract_cj_one_eight_thousand_lighting(merchant_url)
  if is_merchant_cj_one_eight_thousand_lighting?(merchant_url){}
    path = URI(merchant_url).path
    product_name = path.split("/")[path.split("/").index("site")+1] if path.split("/").include?("site")
    query = URI(merchant_url).query
    yield(product_name, query)
  else
    block_given? ? yield("It is not bestbuy merchant connected with commission junction.") : "It is not bestbuy merchant connected with commission junction."
  end
end

#find_product_one_eight_thousand_lighting(merchant_url, cj) ⇒ Object



22
23
24
25
26
# File 'lib/tipsanity_merchant_extractor/1800lighting.rb', line 22

def find_product_one_eight_thousand_lighting merchant_url, cj
	product_name = extract_cj_one_eight_thousand_lighting(merchant_url){|product_name| product_name}
  skuId = extract_cj_one_eight_thousand_lighting(merchant_url){|product_name, query| CGI.parse(query)["skuId"].first}
  cj.product_search("keywords" => product_name, "advertiser-ids" => "notjoined", "advertiser-sku" => skuId).collect{|product| product}.first
end

#is_merchant_cj_one_eight_thousand_lighting?(merchant_url) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
# File 'lib/tipsanity_merchant_extractor/1800lighting.rb', line 3

def is_merchant_cj_one_eight_thousand_lighting?(merchant_url)
  if URI(merchant_url).host == RegisteredMerchantList::REGISTERED_MERCHANT[:cjunction][:one_eight_thousand_lighting]
    block_given? ? true : RegisteredMerchantList::REGISTERED_MERCHANT[:cjunction][:one_eight_thousand_lighting]
  else
    false
  end
end