lark-sdk 1.0.13 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08a4fde8fbeb4ee1de6296383a3213ef9e9fc165dcef5bb686de850c1d55ee97'
4
- data.tar.gz: 7260c1e561d94e347a9db46c023578dd6561fc0ae9321f18421b573d66695ba9
3
+ metadata.gz: 984dbad3f83acdb46fa85412a40a4a24ace271a77f78be3d1ace8db19ad7853b
4
+ data.tar.gz: 8bda6a46d00120a07cb8211d1810125bdde4a1514a8d07d8edb13081d9ceeb73
5
5
  SHA512:
6
- metadata.gz: f7c041bbb3b7339dad3fa7b0e7e0d7c8d34b4b6e324d623785838b4c79dd13af99f8e149c0f41b034fda7c5c89833a3b19bfa8699f948bfc13ada9ecc59a9044
7
- data.tar.gz: b6facce755dafa4bcd048fb342d1c7dc95636b1db1dddeb3e39a4a86815f0f4a2b084a429d3515b184ba24372129608815c59554adf5f476b496e6ae604a79d4
6
+ metadata.gz: 8e46b2b15de32650c6a9d1351445b580da7293fec1e09566c510e16ed04490b090ddeaaf4be6f3c6b765d7accdee591c6910f6145ad20b4b94af6282bcdd4ca8
7
+ data.tar.gz: d59629e8c97033036f10b65d59d0473523f9a80bd862745e70269abd10e31c76565ccabe011f016857a03f1f79b90a734d3773873c2f4641062319c0b4d6608e
data/README.md CHANGED
@@ -60,7 +60,7 @@ cipher.decrypt(message)
60
60
  cipher.encrypt(message)
61
61
  ```
62
62
 
63
- [Api 列表](https://github.com/mycolorway/lark-ruby-sdk/wiki/API-List)
63
+ [Api 列表](https://github.com/seandong/lark-ruby-sdk/wiki/apis)
64
64
 
65
65
 
66
66
  ## 贡献
@@ -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/mycolorway/lark-ruby-sdk"
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/mycolorway/lark-ruby-sdk"
19
- spec.metadata["changelog_uri"] = "https://github.com/mycolorway/lark-ruby-sdk"
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.
@@ -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 options={}
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 |headers|
46
- request.get path, headers
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 |headers|
52
- request.post path, payload, headers
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 |headers|
58
- request.post_file path, file, headers
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= ticket
63
- Lark.redis.set "APP_TICKET_#{app_id}", ticket
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'
@@ -1,6 +1,10 @@
1
1
  module Lark
2
2
  module Apis
3
3
  module Application
4
+ def app_admin_user_list
5
+ get 'user/v4/app_admin_user/list'
6
+ end
7
+
4
8
  def is_user_admin(params={})
5
9
  get 'application/v3/is_user_admin', params: params
6
10
  end
@@ -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:, page_size:, fetch_child: false)
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:, page_size:, fetch_child: false)
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
@@ -8,6 +8,10 @@ module Lark
8
8
  def direct_send(payload)
9
9
  post 'message/v4/send/', payload
10
10
  end
11
+
12
+ def ephemeral_send(payload)
13
+ post 'ephemeral/v1/send/', payload
14
+ end
11
15
  end
12
16
  end
13
- end
17
+ end
@@ -9,11 +9,11 @@ module Lark
9
9
  end
10
10
 
11
11
  def order_list(params={})
12
- get 'pay/v1/order/list', via: 'app', params: params
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', via: 'app', params: {order_id: order_id}
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
@@ -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::join(API_BASE_URL, path)
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
- raise ResponseError.new(response.status) unless response.status.success?
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 == 0
106
+ code.zero?
103
107
  end
104
108
  end
105
109
  end
@@ -1,3 +1,3 @@
1
1
  module Lark
2
- VERSION = '1.0.13'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
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.13
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-06-30 00:00:00.000000000 Z
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/mycolorway/lark-ruby-sdk
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/mycolorway/lark-ruby-sdk
149
- source_code_uri: https://github.com/mycolorway/lark-ruby-sdk
150
- changelog_uri: https://github.com/mycolorway/lark-ruby-sdk
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: