lib/soapy_cake/affiliate.rb in soapy_cake-0.3.4 vs lib/soapy_cake/affiliate.rb in soapy_cake-1.0.0
- old
+ new
@@ -1,29 +1,17 @@
module SoapyCake
- class Affiliate
- attr_reader :api_key, :affiliate_id
-
- def initialize(opts = {})
- @api_key = opts[:api_key]
- @affiliate_id = opts[:affiliate_id]
- end
-
+ class Affiliate < Client
def bills(opts = {})
- cake_client(:reports, :bills, opts)
+ run Request.new(:affiliate, :reports, :bills, affiliate_opts(opts))
end
def offer_feed(opts = {})
- cake_client(:offers, :offer_feed, opts)
+ run Request.new(:affiliate, :offers, :offer_feed, affiliate_opts(opts))
end
- def campaign(opts = {})
- cake_client(:offers, :get_campaign, opts)
- end
-
private
- def cake_client(api, method, opts = {})
- Client::CakeClient.send(api, role: :affiliates)
- .send(method, opts.merge(affiliate_id: affiliate_id, api_key: api_key))
+ def affiliate_opts(opts)
+ { affiliate_id: self.opts[:affiliate_id] }.merge(opts)
end
end
end