Class: DavinciRubyClientSDK::Receiver
- Inherits:
-
Object
- Object
- DavinciRubyClientSDK::Receiver
- Defined in:
- lib/DavinciRubyClientSDK/receiver.rb
Instance Attribute Summary collapse
-
#mode ⇒ Object
Returns the value of attribute mode.
Instance Method Summary collapse
-
#initialize(mode = :notify) ⇒ Receiver
constructor
A new instance of Receiver.
- #receive(params, headers = []) ⇒ Object
Constructor Details
#initialize(mode = :notify) ⇒ Receiver
Returns a new instance of Receiver.
8 9 10 |
# File 'lib/DavinciRubyClientSDK/receiver.rb', line 8 def initialize(mode = :notify) @mode = mode end |
Instance Attribute Details
#mode ⇒ Object
Returns the value of attribute mode.
6 7 8 |
# File 'lib/DavinciRubyClientSDK/receiver.rb', line 6 def mode @mode end |
Instance Method Details
#receive(params, headers = []) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/DavinciRubyClientSDK/receiver.rb', line 12 def receive(params, headers = []) if @mode ==:notify if self.sign_check(params, headers['Davinci-Signature'], headers['Service'], headers['User-Agent']) error = params['error'].nil? ? false : true return error, params else # 验签失败 params['error'] = 'SignCheckError or ServerNotTrust' return true, params end elsif @mode == :response begin params = JSON.parse params error = params['error'].nil? ? false : true rescue Exception => err error = true end return error, params else raise 'receiver not found!' end end |