Class: OfferEngine::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/reg_path/offer_engine/client.rb

Instance Method Summary collapse

Instance Method Details

#add_data(email, keys, values, options = {}) ⇒ Object



23
24
25
26
27
# File 'lib/reg_path/offer_engine/client.rb', line 23

def add_data(email, keys, values, options={})
  uri = URI.parse("#{OfferEngine::Properties.offer_engine_host}/data_store/add_data?email=#{email}&#{keys.to_query('keys')}&#{values.to_query('values')}&#{options.to_query}&#{OfferEngine::Properties.source.to_query(:source)}")
  resp = Net::HTTP.get(uri)
  return resp.is_a?(Net::HTTPSuccess)
end

#submit_to_offer_engine(params) ⇒ Object

Submit the passed in params to the OfferEngine.

If this class, or any extending classes, provide a handler method for the particular offer type being sent back to the OfferEngine, call that. Otherwise, use the standard submit method.



13
14
15
16
17
18
19
20
21
# File 'lib/reg_path/offer_engine/client.rb', line 13

def submit_to_offer_engine(params)
  offer_type = params.delete(:reg_path_offer_type)
  if offer_type && self.respond_to?("_#{offer_type}_submit_to_offer_engine")
    submission_xml = self.__send__("_#{offer_type}_submit_to_offer_engine", params) #handle non-standard forms (e.g. multiple offers on short form)
  else
    submission_xml = _submit_to_offer_engine(params)
  end
  OfferEngine::Models::Submission.new.load(Hash.from_xml(submission_xml)["submission"]) unless submission_xml.blank?
end