Class: TipsanityMerchantExtractor::AttributeExtractor
- Inherits:
-
Object
- Object
- TipsanityMerchantExtractor::AttributeExtractor
- Extended by:
- UrlFormatter
- Defined in:
- lib/tipsanity_merchant_extractor/attribute_extractor.rb
Instance Attribute Summary collapse
-
#categories ⇒ Object
Returns the value of attribute categories.
-
#currency_code ⇒ Object
Returns the value of attribute currency_code.
-
#description ⇒ Object
Returns the value of attribute description.
-
#details_url ⇒ Object
Returns the value of attribute details_url.
-
#expiry_date ⇒ Object
Returns the value of attribute expiry_date.
-
#final_price ⇒ Object
Returns the value of attribute final_price.
-
#host_provider ⇒ Object
Returns the value of attribute host_provider.
-
#image_url ⇒ Object
Returns the value of attribute image_url.
-
#is_dp ⇒ Object
Returns the value of attribute is_dp.
-
#list_price ⇒ Object
Returns the value of attribute list_price.
-
#merchant_url ⇒ Object
Returns the value of attribute merchant_url.
-
#options ⇒ Object
Returns the value of attribute options.
-
#product_name ⇒ Object
Returns the value of attribute product_name.
-
#product_token ⇒ Object
Returns the value of attribute product_token.
-
#response_object ⇒ Object
Returns the value of attribute response_object.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(merchant_url, *args) ⇒ AttributeExtractor
constructor
end of self methods.
Methods included from UrlFormatter
format_url, url_regexp, valid_url
Constructor Details
#initialize(merchant_url, *args) ⇒ AttributeExtractor
end of self methods
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 44 def initialize merchant_url, *args @options = args. @url = merchant_url @merchant_url = self.class.format_url @url @host_provider = URI(@merchant_url).host @errors = [] case self.class.who_is_merchant(@merchant_url) when RegisteredMerchantList::REGISTERED_MERCHANT[:amazon] find_product_amazon @merchant_url when RegisteredMerchantList::REGISTERED_MERCHANT[:cjunction][:bestbuy] find_product_cj @merchant_url when RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][0][:rakuten] find_product_rakuten @merchant_url, @options[:linkshare][:token], RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][0][:mid] when RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][1][:tiger_direct] find_product_tiger_direct @merchant_url, @options[:linkshare][:token], RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][1][:mid] else @product_name = nil @description = nil @list_price = nil @currency_code = nil @expiry_date = nil @image_url = nil @details_url = nil @final_price = nil @categories = nil @errors << "Unable to retrive from api" end end |
Instance Attribute Details
#categories ⇒ Object
Returns the value of attribute categories.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def categories @categories end |
#currency_code ⇒ Object
Returns the value of attribute currency_code.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def currency_code @currency_code end |
#description ⇒ Object
Returns the value of attribute description.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def description @description end |
#details_url ⇒ Object
Returns the value of attribute details_url.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def details_url @details_url end |
#expiry_date ⇒ Object
Returns the value of attribute expiry_date.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def expiry_date @expiry_date end |
#final_price ⇒ Object
Returns the value of attribute final_price.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def final_price @final_price end |
#host_provider ⇒ Object
Returns the value of attribute host_provider.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def host_provider @host_provider end |
#image_url ⇒ Object
Returns the value of attribute image_url.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def image_url @image_url end |
#is_dp ⇒ Object
Returns the value of attribute is_dp.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def is_dp @is_dp end |
#list_price ⇒ Object
Returns the value of attribute list_price.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def list_price @list_price end |
#merchant_url ⇒ Object
Returns the value of attribute merchant_url.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def merchant_url @merchant_url end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def @options end |
#product_name ⇒ Object
Returns the value of attribute product_name.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def product_name @product_name end |
#product_token ⇒ Object
Returns the value of attribute product_token.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def product_token @product_token end |
#response_object ⇒ Object
Returns the value of attribute response_object.
8 9 10 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 8 def response_object @response_object end |
Class Method Details
.who_is_merchant(merchant_url) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/tipsanity_merchant_extractor/attribute_extractor.rb', line 26 def who_is_merchant(merchant_url) case URI(merchant_url).host when is_merchant_amazon?(merchant_url) RegisteredMerchantList::REGISTERED_MERCHANT[:amazon] when is_merchant_cj_bestbuy?(merchant_url) RegisteredMerchantList::REGISTERED_MERCHANT[:cjunction][:bestbuy] when is_merchant_linkshare_rakuten?(merchant_url) RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][0][:rakuten] when is_merchant_linkshare_tiger_direct?(merchant_url) RegisteredMerchantList::REGISTERED_MERCHANT[:linkshare][1][:tiger_direct] else "this merchant is not registered merchant with our system. Please recommend us to affliate with us." # URI(merchant_url).host end end |