Class: Trustly::JSONRPCNotificationResponse
- Inherits:
-
Data
- Object
- Data
- Trustly::JSONRPCNotificationResponse
show all
- Defined in:
- lib/trustly/data/jsonrpcnotification_response.rb
Instance Attribute Summary
Attributes inherited from Data
#payload
Instance Method Summary
collapse
Methods inherited from Data
#get, #get_from, #json, #pop, #set, #set_in, #vacumm
Constructor Details
Returns a new instance of JSONRPCNotificationResponse.
3
4
5
6
7
8
9
10
11
12
|
# 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
|
Instance Method Details
#get_data(name = nil) ⇒ Object
36
37
38
39
|
# 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 ⇒ Object
51
52
53
|
# File 'lib/trustly/data/jsonrpcnotification_response.rb', line 51
def get_method
return self.get_result('method')
end
|
#get_result(name) ⇒ Object
31
32
33
34
|
# 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 ⇒ Object
59
60
61
|
# File 'lib/trustly/data/jsonrpcnotification_response.rb', line 59
def get_signature
return self.get_result('signature')
end
|
#get_uuid ⇒ Object
55
56
57
|
# File 'lib/trustly/data/jsonrpcnotification_response.rb', line 55
def get_uuid
return self.get_result('uuid')
end
|
#set_data(name, value) ⇒ Object
24
25
26
27
28
29
|
# 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) ⇒ Object
18
19
20
21
22
|
# 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) ⇒ Object
14
15
16
|
# File 'lib/trustly/data/jsonrpcnotification_response.rb', line 14
def set_signature(signature)
self.set_result('signature',signature)
end
|