diff --git a/lib/dingtalk/client.rb b/lib/dingtalk/client.rb new file mode 100644 index 0000000..0964f03 --- /dev/null +++ b/lib/dingtalk/client.rb @@ -0,0 +1,24 @@ +module Dingtalk + class Client + attr_accessor :corp_id + + def initialize(corp_id) + @corp_id = corp_id + end + + def decrypt(echo_str) + aes_key = Base64.decode64(Dingtalk.suite_aes_key + '=') + content, status = Dingtalk::Prpcrypt.decrypt(aes_key, echo_str, Dingtalk.suite_key) + # TODO check status + JSON.parse(content) + end + + def suite + Api::Suite.new + end + + def department + Api::Department.new(@corp_id) + end + end +end diff --git a/lib/dingtalk/config.rb b/lib/dingtalk/config.rb index 5fb7ece..ec008a4 100644 --- a/lib/dingtalk/config.rb +++ b/lib/dingtalk/config.rb @@ -18,9 +18,13 @@ module Dingtalk def suite_secret @suite_secret ||= config.suite_secret end + + def suite_aes_key + @suite_aes_key ||= config.suite_aes_key + end end class Config - attr_accessor :redis, :redis_options, :suite_key, :suite_secret + attr_accessor :redis, :redis_options, :suite_key, :suite_secret, :suite_aes_key end end -- libgit2 0.21.0