Commit b948cf46 by mingyuan

upgrae stuct

parent f88d9746
module Dingtalk::Api
class BaseNew < Base
BASE = 'https://api.dingtalk.com/'
def token
payload = {
appKey: app.app_key,
appSecret: app.app_secret,
}
r = @client.post 'v1.0/oauth2/accessToken', payload.to_json, base: BASE
{
'access_token' => r['accessToken'],
'expires_in' => r['expireIn']
}
end
end
end
module Dingtalk::Api
module Inner::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::Api
module User
module Inner::User
BASE = 'https://oapi.dingtalk.com/'
def getuserinfo(code)
......
module Dingtalk::Api
module New
class New < Base
BASE = 'https://api.dingtalk.com/'
include Inner::New
def getuserinfo(union_id)
r = get "v1.0/contact/users/#{union_id}"
r['result']
def token
payload = {
appKey: app.app_key,
appSecret: app.app_secret,
}
r = @client.post 'v1.0/oauth2/accessToken', payload.to_json, base: BASE
{
'access_token' => r['accessToken'],
'expires_in' => r['expireIn']
}
end
end
......
module Dingtalk::Api
class Normal < Base
include Inner::User
end
end
module Dingtalk
class NormalApp < App
include Model::App::NormalApp
end
end
......@@ -18,7 +18,7 @@ module Dingtalk
def api
return @api if defined? @api
@api = Api::Base.new(self)
@api = Api::Normal.new(self)
end
def refresh_access_token
......
......@@ -3,7 +3,7 @@ module Dingtalk
def api
return @api if defined? @api
@api = Api::BaseNew.new(self)
@api = Api::New.new(self)
end
end
......
module Dingtalk
module Model::App::NormalApp
extend ActiveSupport::Concern
included do
has_one :new_app, foreign_key: :app_key, primary_key: :app_key
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