Commit e4d37df8cc742fe4deda1df61f73ef579942a7ba

Authored by Jeff Lai
1 parent 07b11136
Exists in master

Add response_json helper to client

Showing 1 changed file with 14 additions and 2 deletions   Show diff stats
lib/dingtalk/client.rb
... ... @@ -12,9 +12,21 @@ module Dingtalk
12 12 JSON.parse(content)
13 13 end
14 14  
15   - def signature(return_str)
  15 + def response_json(return_str)
  16 + {
  17 + msg_signature: signature(return_str),
  18 + encrypt: encrypt(return_str),
  19 + timeStamp: timestamp,
  20 + nonce: nonce
  21 + }
  22 + end
  23 +
  24 + def encrypt(return_str)
16 25 encrypt = Dingtalk::Prpcrypt.encrypt(aes_key, return_str, Dingtalk.suite_key)
17   - sort_params = [suite.suite_access_token, timestamp, nonce, encrypt].sort.join
  26 + end
  27 +
  28 + def signature(return_str)
  29 + sort_params = [suite.suite_access_token, timestamp, nonce, encrypt(return_str)].sort.join
18 30 Digest::SHA1.hexdigest(sort_params)
19 31 end
20 32  
... ...