Class: Dingtalk::Api::New
- Inherits:
-
Base
- Object
- Base
- Dingtalk::Api::New
show all
- Includes:
- Inner::New
- Defined in:
- app/apis/dingtalk/api/new.rb
Constant Summary
collapse
- BASE =
'https://api.dingtalk.com/'
Instance Attribute Summary
Attributes inherited from Base
#app, #client
Instance Method Summary
collapse
-
#base_host ⇒ Object
-
#get(path, params: {}, headers: {}, base: base_host, as: nil) ⇒ Object
-
#post(path, params: {}, headers: {}, base: base_host, **payload) ⇒ Object
-
#post_file(path, file, params: {}, headers: {}, base: base_host) ⇒ Object
-
#token ⇒ Object
Methods inherited from Base
#initialize, #jsapi_ticket
Instance Method Details
#base_host ⇒ Object
18
19
20
|
# File 'app/apis/dingtalk/api/new.rb', line 18
def base_host
BASE
end
|
#get(path, params: {}, headers: {}, base: base_host, as: nil) ⇒ Object
22
23
24
25
26
|
# File 'app/apis/dingtalk/api/new.rb', line 22
def get(path, params: {}, headers: {}, base: base_host, as: nil)
with_access_token() do ||
@client.get path, headers: , params: params, base: base, as: as
end
end
|
#post(path, params: {}, headers: {}, base: base_host, **payload) ⇒ Object
28
29
30
31
32
|
# File 'app/apis/dingtalk/api/new.rb', line 28
def post(path, params: {}, headers: {}, base: base_host, **payload)
with_access_token() do ||
@client.post path, payload.to_json, headers: , params: params, base: base
end
end
|
#post_file(path, file, params: {}, headers: {}, base: base_host) ⇒ Object
34
35
36
37
38
|
# File 'app/apis/dingtalk/api/new.rb', line 34
def post_file(path, file, params: {}, headers: {}, base: base_host)
with_access_token() do ||
@client.post_file path, file, headers: , params: params, base: base
end
end
|
#token ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
|
# File 'app/apis/dingtalk/api/new.rb', line 6
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
|