class Trustly::JSONRPCNotificationResponse
Public Class Methods
new(request,success=nil)
click to toggle source
Calls superclass method
Trustly::Data::new
# File lib/trustly/data/jsonrpcnotification_response.rb, line 3 def initialize(request,success=nil) super() uuid = request.get_uuid() method = request.get_method() self.set('version','1.1') self.set_result('uuid', uuid) unless uuid.nil? self.set_result('method', method) unless method.nil? self.set_data( 'status', (!success.nil? && !success ? 'FAILED' : 'OK' )) end
Public Instance Methods
get_data(name=nil)
click to toggle source
# File lib/trustly/data/jsonrpcnotification_response.rb, line 36 def get_data(name=nil) raise KeyError,"#{name} is not present in data" if name.nil? || self.payload.try(:[],"result").nil? || self.payload["result"].try(:[],"data").nil? || self.payload["result"]["data"].try(:[],name).nil? return self.payload["result"]["data"][name] end
get_method()
click to toggle source
# File lib/trustly/data/jsonrpcnotification_response.rb, line 51 def get_method return self.get_result('method') end
get_result(name)
click to toggle source
# File lib/trustly/data/jsonrpcnotification_response.rb, line 31 def get_result(name) raise KeyError,"#{name} is not present in result" if name.nil? || self.payload.try(:[],"result").nil? || self.payload["result"].try(:[],name).nil? return self.payload["result"][name] end
get_signature()
click to toggle source
# File lib/trustly/data/jsonrpcnotification_response.rb, line 59 def get_signature return self.get_result('signature') end
get_uuid()
click to toggle source
# File lib/trustly/data/jsonrpcnotification_response.rb, line 55 def get_uuid return self.get_result('uuid') end
set_data(name,value)
click to toggle source
# File lib/trustly/data/jsonrpcnotification_response.rb, line 24 def set_data(name,value) return nil if name.nil? || value.nil? self.payload["result"] = {} if self.payload.try(:[],"result").nil? self.payload["result"]["data"] = {} if self.payload["result"].try(:[],"data").nil? self.payload["result"]["data"][name] = value end
set_result(name,value)
click to toggle source
# File lib/trustly/data/jsonrpcnotification_response.rb, line 18 def set_result(name,value) return nil if name.nil? || value.nil? self.payload["result"] = {} if self.payload.try(:[],"result").nil? self.payload["result"][name] = value end
set_signature(signature)
click to toggle source
# File lib/trustly/data/jsonrpcnotification_response.rb, line 14 def set_signature(signature) self.set_result('signature',signature) end