Commit 14a220bd by mingyuan

test get token

parent eab4e9c8
......@@ -8,14 +8,14 @@ gem 'sidekiq'
gem 'jbuilder'
gem 'viter', github: 'qinmingyuan/viter'
gem 'rails_ui', github: 'work-design/rails_ui'
gem 'rails_com', github: 'work-design/rails_com'
gem 'rails_design', github: 'work-design/rails_design'
gem 'rails_extend', github: 'work-design/rails_extend'
gem 'rails_com', github: 'work-design/rails_com'
gem 'amazing_print'
group :development, :test do
gem 'debug', '>= 1.0.0.rc'
gem 'debug'
gem 'minitest-hooks'
gem 'sdoc'
end
......@@ -22,23 +22,23 @@ GIT
turbo-rails
GIT
remote: https://github.com/work-design/rails_design.git
revision: 074ee48cd8cd754977c8946f73479fe4a7e9b3f5
specs:
rails_design (0.0.1)
rails
GIT
remote: https://github.com/work-design/rails_extend.git
revision: 48e8b20f65097c981b8ecc3b9b35d2082512d9e8
specs:
rails_extend (1.0.0)
rails (>= 6.0)
GIT
remote: https://github.com/work-design/rails_ui.git
revision: c8d7bfe6d598c9433373e4e8c0e7c17ebc98b17a
specs:
rails_ui (0.0.1)
rails
PATH
remote: .
specs:
rails_dingtalk (0.1)
rails_dingtalk (0.0.2)
http-form_data (~> 2.3)
httpx (~> 0.16)
rails (>= 5.0)
......@@ -117,7 +117,7 @@ GEM
concurrent-ruby (1.1.9)
connection_pool (2.2.5)
crass (1.0.6)
debug (1.0.0.rc2)
debug (1.0.0)
irb
reline (>= 0.2.7)
default_where (2.3.0)
......@@ -253,15 +253,15 @@ PLATFORMS
DEPENDENCIES
amazing_print
debug (>= 1.0.0.rc)
debug
jbuilder
minitest-hooks
pg
puma
rails_com!
rails_design!
rails_dingtalk!
rails_extend!
rails_ui!
sdoc
sidekiq
viter!
......
module Dingtalk::Api
class Saas < Base
BASE = 'https://openplatform.dg-work.cn/'
def token
payload = {
appkey: app.app_key,
appsecret: app.app_secret,
}
r = @client.post 'gettoken.json', payload.to_json, base: BASE
{
'access_token' => r.dig('content', 'data', 'accessToken'),
'expires_in' => r.dig('content', 'data', 'expiresIn')
}
end
protected
def with_access_token(params = {}, tries = 2)
yield params.merge!(
accessKey: app.app_key,
secretKey: app.app_secret
)
rescue => e
Rails.logger.debug e.full_message
retry unless (tries -= 1).zero?
end
end
end
module Dingtalk
class SaasApp < App
include Model::App::SaasApp
end
end
module Dingtalk
module Model::App::SaasApp
extend ActiveSupport::Concern
included do
end
def api
return @api if defined? @api
@api = Api::Saas.new(self)
end
def xx(code)
result = api.getuserinfo(code)
new_app.api.getuserinfo(result['unionid'])
end
end
end
Subproject commit 7ee1db8640f7767c51824e66c3d8e0928b62f4e3
Subproject commit cdb9e21f88f14e12235aa2f3221dd61ba3f7a2bc
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