lark-sdk 1.0.13 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lark.gemspec +3 -3
- data/lib/lark/api.rb +14 -13
- data/lib/lark/apis/application.rb +4 -0
- data/lib/lark/apis/contact.rb +6 -4
- data/lib/lark/apis/message.rb +5 -1
- data/lib/lark/apis/pay.rb +2 -2
- data/lib/lark/apis/search.rb +16 -0
- data/lib/lark/request.rb +12 -8
- data/lib/lark/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 984dbad3f83acdb46fa85412a40a4a24ace271a77f78be3d1ace8db19ad7853b
|
4
|
+
data.tar.gz: 8bda6a46d00120a07cb8211d1810125bdde4a1514a8d07d8edb13081d9ceeb73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e46b2b15de32650c6a9d1351445b580da7293fec1e09566c510e16ed04490b090ddeaaf4be6f3c6b765d7accdee591c6910f6145ad20b4b94af6282bcdd4ca8
|
7
|
+
data.tar.gz: d59629e8c97033036f10b65d59d0473523f9a80bd862745e70269abd10e31c76565ccabe011f016857a03f1f79b90a734d3773873c2f4641062319c0b4d6608e
|
data/README.md
CHANGED
data/lark.gemspec
CHANGED
@@ -8,15 +8,15 @@ Gem::Specification.new do |spec|
|
|
8
8
|
|
9
9
|
spec.summary = %q{Lark(飞书) API SDKs for ruby}
|
10
10
|
spec.description = %q{Lark(飞书) API SDKs for ruby https://open.feishu.cn}
|
11
|
-
spec.homepage = "https://github.com/
|
11
|
+
spec.homepage = "https://github.com/seandong/lark-ruby-sdk"
|
12
12
|
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
14
|
|
15
15
|
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
spec.metadata["source_code_uri"] = "https://github.com/
|
19
|
-
spec.metadata["changelog_uri"] = "https://github.com/
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/seandong/lark-ruby-sdk"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/seandong/lark-ruby-sdk"
|
20
20
|
|
21
21
|
# Specify which files should be added to the gem when it is released.
|
22
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
data/lib/lark/api.rb
CHANGED
@@ -8,6 +8,7 @@ module Lark
|
|
8
8
|
api_mount :authen
|
9
9
|
api_mount :contact
|
10
10
|
api_mount :user
|
11
|
+
api_mount :search
|
11
12
|
api_mount :application
|
12
13
|
api_mount :pay
|
13
14
|
api_mount :chat
|
@@ -23,7 +24,7 @@ module Lark
|
|
23
24
|
|
24
25
|
attr_reader :app_id, :app_secret, :tenant_key, :isv, :options
|
25
26
|
|
26
|
-
def initialize
|
27
|
+
def initialize(options = {})
|
27
28
|
@app_id = options.delete(:app_id) || Lark.config.default_app_id
|
28
29
|
@app_secret = options.delete(:app_secret) || Lark.config.default_app_secret
|
29
30
|
raise AppNotConfigException if @app_id.nil? || @app_id.empty?
|
@@ -41,26 +42,26 @@ module Lark
|
|
41
42
|
@request ||= Lark::Request.new(false)
|
42
43
|
end
|
43
44
|
|
44
|
-
def get(path, headers={})
|
45
|
-
with_token(headers) do |
|
46
|
-
request.get path,
|
45
|
+
def get(path, headers = {})
|
46
|
+
with_token(headers) do |headers_with_token|
|
47
|
+
request.get path, headers_with_token
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
|
-
def post(path, payload, headers={})
|
51
|
-
with_token(headers) do |
|
52
|
-
request.post path, payload,
|
51
|
+
def post(path, payload, headers = {})
|
52
|
+
with_token(headers) do |headers_with_token|
|
53
|
+
request.post path, payload, headers_with_token
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
56
|
-
def post_file(path, file, headers={})
|
57
|
-
with_token(headers) do |
|
58
|
-
request.post_file path, file,
|
57
|
+
def post_file(path, file, headers = {})
|
58
|
+
with_token(headers) do |headers_with_token|
|
59
|
+
request.post_file path, file, headers_with_token
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
62
|
-
def app_ticket=
|
63
|
-
Lark.redis.set "APP_TICKET_#{app_id}",
|
63
|
+
def app_ticket=(new_ticket)
|
64
|
+
Lark.redis.set "APP_TICKET_#{app_id}", new_ticket
|
64
65
|
end
|
65
66
|
|
66
67
|
def app_ticket
|
@@ -91,7 +92,7 @@ module Lark
|
|
91
92
|
@tenant_token_store = klass.new(self)
|
92
93
|
end
|
93
94
|
|
94
|
-
def with_token(headers, tries=2)
|
95
|
+
def with_token(headers, tries = 2)
|
95
96
|
token = headers[:access_token]
|
96
97
|
if token.nil?
|
97
98
|
via = headers[:via] || 'tenant'
|
data/lib/lark/apis/contact.rb
CHANGED
@@ -42,19 +42,21 @@ module Lark
|
|
42
42
|
get 'contact/v1/department/detail/batch_get', params: {department_ids: department_ids}
|
43
43
|
end
|
44
44
|
|
45
|
-
def department_user_list(department_id:, offset
|
45
|
+
def department_user_list(department_id:, offset: nil, page_token: nil, page_size:, fetch_child: false)
|
46
46
|
get 'contact/v1/department/user/list', params: {
|
47
47
|
department_id: department_id,
|
48
|
-
offset: offset,
|
48
|
+
offset: offset, # deprecation
|
49
|
+
page_token: page_token,
|
49
50
|
page_size: page_size,
|
50
51
|
fetch_child: fetch_child
|
51
52
|
}.compact
|
52
53
|
end
|
53
54
|
|
54
|
-
def department_user_detail_list(department_id:, offset
|
55
|
+
def department_user_detail_list(department_id:, offset: nil, page_token: nil, page_size:, fetch_child: false)
|
55
56
|
get 'contact/v1/department/user/detail/list', params: {
|
56
57
|
department_id: department_id,
|
57
|
-
offset: offset,
|
58
|
+
offset: offset, # deprecation
|
59
|
+
page_token: page_token,
|
58
60
|
page_size: page_size,
|
59
61
|
fetch_child: fetch_child
|
60
62
|
}.compact
|
data/lib/lark/apis/message.rb
CHANGED
data/lib/lark/apis/pay.rb
CHANGED
@@ -9,11 +9,11 @@ module Lark
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def order_list(params={})
|
12
|
-
get 'pay/v1/order/list',
|
12
|
+
get 'pay/v1/order/list', params: params
|
13
13
|
end
|
14
14
|
|
15
15
|
def order_get(order_id)
|
16
|
-
get 'pay/v1/order/get',
|
16
|
+
get 'pay/v1/order/get', params: {order_id: order_id}
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Lark
|
2
|
+
module Apis
|
3
|
+
module Search
|
4
|
+
def user(query:, user_access_token:, page_size: 20, page_token: nil)
|
5
|
+
get 'search/v1/user', {
|
6
|
+
access_token: user_access_token,
|
7
|
+
params: {
|
8
|
+
query: query,
|
9
|
+
page_size: page_size,
|
10
|
+
page_token: page_token
|
11
|
+
}.compact
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/lark/request.rb
CHANGED
@@ -4,14 +4,14 @@ module Lark
|
|
4
4
|
class Request
|
5
5
|
attr_reader :ssl_context, :http
|
6
6
|
|
7
|
-
def initialize(skip_verify_ssl=true)
|
7
|
+
def initialize(skip_verify_ssl = true)
|
8
8
|
@http = HTTP.timeout(**Lark.http_timeout_options)
|
9
9
|
@ssl_context = OpenSSL::SSL::SSLContext.new
|
10
10
|
@ssl_context.ssl_version = :TLSv1
|
11
11
|
@ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE if skip_verify_ssl
|
12
12
|
end
|
13
13
|
|
14
|
-
def get(path, get_header={})
|
14
|
+
def get(path, get_header = {})
|
15
15
|
request(path, get_header) do |url, header|
|
16
16
|
params = header.delete(:params)
|
17
17
|
http.headers(header).get(url, params: params, ssl_context: ssl_context)
|
@@ -19,7 +19,7 @@ module Lark
|
|
19
19
|
end
|
20
20
|
alias delete get
|
21
21
|
|
22
|
-
def post(path, post_body, post_header={})
|
22
|
+
def post(path, post_body, post_header = {})
|
23
23
|
request(path, post_header) do |url, header|
|
24
24
|
Lark.logger.info "payload: #{post_body}"
|
25
25
|
params = header.delete(:params)
|
@@ -27,7 +27,7 @@ module Lark
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def post_file(path, file, post_header={})
|
30
|
+
def post_file(path, file, post_header = {})
|
31
31
|
request(path, post_header) do |url, header|
|
32
32
|
params = header.delete(:params)
|
33
33
|
http.headers(header).post(
|
@@ -44,13 +44,16 @@ module Lark
|
|
44
44
|
|
45
45
|
private
|
46
46
|
|
47
|
-
def request(path, header={}, &_block)
|
48
|
-
url = URI
|
47
|
+
def request(path, header = {}, &_block)
|
48
|
+
url = URI.join(API_BASE_URL, path)
|
49
49
|
Lark.logger.info "request url(#{url}) with headers: #{header}"
|
50
50
|
as = header.delete(:as)
|
51
51
|
header['Accept'] = 'application/json'
|
52
52
|
response = yield(url, header)
|
53
|
-
|
53
|
+
unless response.status.success?
|
54
|
+
Lark.logger.error "request #{url} happen error: #{response.body}"
|
55
|
+
raise ResponseError.new(response.status, response.body)
|
56
|
+
end
|
54
57
|
handle_response(response, as || :json)
|
55
58
|
end
|
56
59
|
|
@@ -77,6 +80,7 @@ module Lark
|
|
77
80
|
data = JSON.parse body.to_s
|
78
81
|
result = Result.new(data)
|
79
82
|
raise ::Lark::AccessTokenExpiredError if [99991663, 99991664].include?(result.code)
|
83
|
+
|
80
84
|
result
|
81
85
|
end
|
82
86
|
|
@@ -99,7 +103,7 @@ module Lark
|
|
99
103
|
end
|
100
104
|
|
101
105
|
def success?
|
102
|
-
code
|
106
|
+
code.zero?
|
103
107
|
end
|
104
108
|
end
|
105
109
|
end
|
data/lib/lark/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lark-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Dong
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- lib/lark/apis/mina.rb
|
129
129
|
- lib/lark/apis/notify.rb
|
130
130
|
- lib/lark/apis/pay.rb
|
131
|
+
- lib/lark/apis/search.rb
|
131
132
|
- lib/lark/apis/user.rb
|
132
133
|
- lib/lark/cipher.rb
|
133
134
|
- lib/lark/config.rb
|
@@ -140,14 +141,14 @@ files:
|
|
140
141
|
- lib/lark/token_store/isv_tenant_token.rb
|
141
142
|
- lib/lark/token_store/tenant_token.rb
|
142
143
|
- lib/lark/version.rb
|
143
|
-
homepage: https://github.com/
|
144
|
+
homepage: https://github.com/seandong/lark-ruby-sdk
|
144
145
|
licenses:
|
145
146
|
- MIT
|
146
147
|
metadata:
|
147
148
|
allowed_push_host: https://rubygems.org/
|
148
|
-
homepage_uri: https://github.com/
|
149
|
-
source_code_uri: https://github.com/
|
150
|
-
changelog_uri: https://github.com/
|
149
|
+
homepage_uri: https://github.com/seandong/lark-ruby-sdk
|
150
|
+
source_code_uri: https://github.com/seandong/lark-ruby-sdk
|
151
|
+
changelog_uri: https://github.com/seandong/lark-ruby-sdk
|
151
152
|
post_install_message:
|
152
153
|
rdoc_options: []
|
153
154
|
require_paths:
|