Commit 14a220bd by mingyuan

test get token

parent eab4e9c8
...@@ -8,14 +8,14 @@ gem 'sidekiq' ...@@ -8,14 +8,14 @@ gem 'sidekiq'
gem 'jbuilder' gem 'jbuilder'
gem 'viter', github: 'qinmingyuan/viter' gem 'viter', github: 'qinmingyuan/viter'
gem 'rails_ui', github: 'work-design/rails_ui' gem 'rails_design', github: 'work-design/rails_design'
gem 'rails_com', github: 'work-design/rails_com'
gem 'rails_extend', github: 'work-design/rails_extend' gem 'rails_extend', github: 'work-design/rails_extend'
gem 'rails_com', github: 'work-design/rails_com'
gem 'amazing_print' gem 'amazing_print'
group :development, :test do group :development, :test do
gem 'debug', '>= 1.0.0.rc' gem 'debug'
gem 'minitest-hooks' gem 'minitest-hooks'
gem 'sdoc' gem 'sdoc'
end end
...@@ -22,23 +22,23 @@ GIT ...@@ -22,23 +22,23 @@ GIT
turbo-rails turbo-rails
GIT 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 remote: https://github.com/work-design/rails_extend.git
revision: 48e8b20f65097c981b8ecc3b9b35d2082512d9e8 revision: 48e8b20f65097c981b8ecc3b9b35d2082512d9e8
specs: specs:
rails_extend (1.0.0) rails_extend (1.0.0)
rails (>= 6.0) rails (>= 6.0)
GIT
remote: https://github.com/work-design/rails_ui.git
revision: c8d7bfe6d598c9433373e4e8c0e7c17ebc98b17a
specs:
rails_ui (0.0.1)
rails
PATH PATH
remote: . remote: .
specs: specs:
rails_dingtalk (0.1) rails_dingtalk (0.0.2)
http-form_data (~> 2.3) http-form_data (~> 2.3)
httpx (~> 0.16) httpx (~> 0.16)
rails (>= 5.0) rails (>= 5.0)
...@@ -117,7 +117,7 @@ GEM ...@@ -117,7 +117,7 @@ GEM
concurrent-ruby (1.1.9) concurrent-ruby (1.1.9)
connection_pool (2.2.5) connection_pool (2.2.5)
crass (1.0.6) crass (1.0.6)
debug (1.0.0.rc2) debug (1.0.0)
irb irb
reline (>= 0.2.7) reline (>= 0.2.7)
default_where (2.3.0) default_where (2.3.0)
...@@ -253,15 +253,15 @@ PLATFORMS ...@@ -253,15 +253,15 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
amazing_print amazing_print
debug (>= 1.0.0.rc) debug
jbuilder jbuilder
minitest-hooks minitest-hooks
pg pg
puma puma
rails_com! rails_com!
rails_design!
rails_dingtalk! rails_dingtalk!
rails_extend! rails_extend!
rails_ui!
sdoc sdoc
sidekiq sidekiq
viter! 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