Class: CouponAggregator

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

Constant Summary collapse

CJ =

apparently there are no enums in ruby

1
FMTC =
2

Instance Method Summary collapse

Constructor Details

#initialize(params, feed) ⇒ CouponAggregator

params for fmtc is just a “key” => “api key”

params for cj involve website-id (ours, assigned by CJ), records-per-page (100 max), promotion-type (coupon), and page-number


23
24
25
26
27
28
# File 'lib/coupon_aggregator.rb', line 23

def initialize(params, feed)
  #I think we will probably move towards a place where params can be replaced by
  # a db object
  @params = params
  @feed = feed
end

Instance Method Details

#aggregate(site_id) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/coupon_aggregator.rb', line 31

def aggregate(site_id)
  case @feed
    when CouponAggregator::CJ
      aggregate_cj_coupons(site_id)
    when CouponAggregator::FMTC
      aggregate_fmtc_coupons()
    else
      aggregate_all_coupons_for_site(site_id)
  end
end