Class: TradeTracker::Conversion
- Inherits:
-
Object
- Object
- TradeTracker::Conversion
- Defined in:
- lib/trade_tracker/conversion.rb
Constant Summary collapse
- PARAMETERS =
%w(use_https campaign_id product_id conversion_type tracking_data tracking_type transaction_id transaction_amount quantity email merchant_description affiliate_description)
Instance Method Summary collapse
- #affiliate_description=(value) ⇒ Object
- #campaign_id=(value) ⇒ Object
- #conversion_type=(value) ⇒ Object
- #cookie_name ⇒ Object
- #email=(value) ⇒ Object
-
#initialize(params, config = nil) ⇒ Conversion
constructor
A new instance of Conversion.
- #merchant_description=(value) ⇒ Object
- #product_id=(value) ⇒ Object
- #quantity=(value) ⇒ Object
- #trackback_url ⇒ Object
- #tracking_data=(value) ⇒ Object
- #tracking_type=(value) ⇒ Object
- #transaction_amount=(value) ⇒ Object
- #transaction_id=(value) ⇒ Object
- #use_https ⇒ Object
- #use_https=(value) ⇒ Object
Constructor Details
#initialize(params, config = nil) ⇒ Conversion
Returns a new instance of Conversion.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/trade_tracker/conversion.rb', line 7 def initialize(params, config = nil) PARAMETERS.each do |p| values = config && config.include?(p.to_sym) ? config : params self.send "#{p}=", values[p.to_sym] unless self.respond_to?(p) self.class.send(:define_method, p, lambda { instance_variable_get('@' + p) }) end end end |
Instance Method Details
#affiliate_description=(value) ⇒ Object
68 69 70 |
# File 'lib/trade_tracker/conversion.rb', line 68 def affiliate_description=(value) @affiliate_description = CGI.escape value.to_s end |
#campaign_id=(value) ⇒ Object
20 21 22 |
# File 'lib/trade_tracker/conversion.rb', line 20 def campaign_id=(value) @campaign_id = value.to_s end |
#conversion_type=(value) ⇒ Object
28 29 30 |
# File 'lib/trade_tracker/conversion.rb', line 28 def conversion_type=(value) @conversion_type = value.to_s end |
#cookie_name ⇒ Object
80 81 82 |
# File 'lib/trade_tracker/conversion.rb', line 80 def "TT2_#{campaign_id}" end |
#email=(value) ⇒ Object
60 61 62 |
# File 'lib/trade_tracker/conversion.rb', line 60 def email=(value) @email = CGI.escape value.to_s end |
#merchant_description=(value) ⇒ Object
64 65 66 |
# File 'lib/trade_tracker/conversion.rb', line 64 def merchant_description=(value) @merchant_description = CGI.escape value.to_s end |
#product_id=(value) ⇒ Object
24 25 26 |
# File 'lib/trade_tracker/conversion.rb', line 24 def product_id=(value) @product_id = value.to_s end |
#quantity=(value) ⇒ Object
56 57 58 |
# File 'lib/trade_tracker/conversion.rb', line 56 def quantity=(value) @quantity = CGI.escape value.to_s end |
#trackback_url ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/trade_tracker/conversion.rb', line 72 def trackback_url if campaign_id.blank? || product_id.blank? raise 'Wrong or missing parameters' else "#{use_https ? 'https' : 'http'}://#{conversion_type == 'lead' ? 'tl' : 'ts'}.tradetracker.net/?cid=#{campaign_id}&pid=#{product_id}&data=#{tracking_data}&type=#{tracking_type}&tid=#{transaction_id}&tam=#{transaction_amount}&qty=#{quantity}&eml=#{email}&descrMerchant=#{merchant_description}&descrAffiliate=#{affiliate_description}" end end |
#tracking_data=(value) ⇒ Object
40 41 42 |
# File 'lib/trade_tracker/conversion.rb', line 40 def tracking_data=(value) @tracking_data = CGI.escape value.to_s end |
#tracking_type=(value) ⇒ Object
44 45 46 |
# File 'lib/trade_tracker/conversion.rb', line 44 def tracking_type=(value) @tracking_type = value.to_s end |
#transaction_amount=(value) ⇒ Object
52 53 54 |
# File 'lib/trade_tracker/conversion.rb', line 52 def transaction_amount=(value) @transaction_amount = value.to_f end |
#transaction_id=(value) ⇒ Object
48 49 50 |
# File 'lib/trade_tracker/conversion.rb', line 48 def transaction_id=(value) @transaction_id = value.to_s end |
#use_https ⇒ Object
32 33 34 |
# File 'lib/trade_tracker/conversion.rb', line 32 def use_https @use_https == 1 end |
#use_https=(value) ⇒ Object
36 37 38 |
# File 'lib/trade_tracker/conversion.rb', line 36 def use_https=(value) @use_https = value.to_i end |