Sha256: 68bda1626b76e5873a34175b8dd3c59ae455e1f71e7cb6a39fc44ce1f0e21f7d
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
class SmartsApi::EvaluateMessage < SmartsApi::Message def send(session, member, decision) body = make_form(request_params(session, member, decision)) logger.info "Evaluating" if logger.respond_to?(:info) response = Typhoeus::Request.post(uri, :method => method, :headers => {:Accept => "text/json"}, :body => body ) raise SmartsApi::Error, "Rules Evaluation failed failed. Recieved empty reply" if response.nil? || response.body.blank? reply = JSON.parse(response.body) raise SmartsApi::Error, "Rules Evaluation failed failed. Received malformed response." unless reply["Header"] && ["Body"] body = reply["Body"] if body.blank? logger.info "Rules Engine Evaluation failed. \n\n #{body} \n\n #{response.body}" if logger.respond_to?(:info) raise SmartsApi::Error, "Rules Evaluation failed. Returned JSON is blank." end logger.info "Updating issues" if logger.respond_to?(:info) member.process_smarts_response body return body end def request_params(session, member, decision) params = { :appId => app_id, :reqData => request_document(session, member, decision), :reqTime => timestamp, :session => session } signature = { :sign => sign_request(params) } return params.merge(signature) end def request_document(session, member, decision) doc = {:OperationId =>1 , :Header => {:SessionId => session, :DecisionId => decision}, :Body => {:Documents => []}} doc[:Body][:Documents] = member.smarts_document return doc.to_json end def uri "#{base_uri}evaluate" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
smarts_api-0.0.1 | lib/smarts_api/message/evaluate_message.rb |