Commit 67cff799 by mingyuan

add new api

parent 7880166b
module Dingtalk::Api
class BaseNew < Base
BASE = 'https://api.dingtalk.com/'
def token
@client.post 'v1.0/oauth2/userAccessToken', { clientId: app.app_key, clientSecret: app.app_secret }.to_json, base: BASE
end
end
end
module Dingtalk::Api
module New
BASE = 'https://api.dingtalk.com/'
def getuserinfo(union_id)
r = get "v1.0/contact/users/#{union_id}"
r['result']
end
end
end
module Dingtalk
class NewApp < App
include Model::App::NewApp
end
end
......@@ -3,6 +3,7 @@ module Dingtalk
extend ActiveSupport::Concern
included do
attribute :type, :string
attribute :name, :string
attribute :agent_id, :string
attribute :app_key, :string
......@@ -10,6 +11,7 @@ module Dingtalk
attribute :corp_id, :string
attribute :access_token, :string
attribute :access_token_expires_at, :datetime
attribute :refresh_token, :string
attribute :jsapi_ticket, :string
attribute :oauth2_state, :string
attribute :jsapi_ticket_expires_at, :datetime
......
module Dingtalk::Model
module App::NewApp
def api
return @api if defined? @api
@api = Api::BaseNew.new(self)
end
end
end
module RailsDingtalk
class Engine < ::Rails::Engine
config.autoload_paths += Dir[
"#{config.root}/app/models/govern"
"#{config.root}/app/models/app"
]
config.generators do |g|
......@@ -15,5 +16,6 @@ module RailsDingtalk
}
#g.templates.unshift File.expand_path('lib/templates', RailsCom::Engine.root)
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment