lark-sdk 1.1.2 → 1.1.3

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: 9552cdde34c23f537cf389250697d3fc0bbe7e987961de95fcc638a66d78e785
4
- data.tar.gz: 11ad0bde0365ca9a9a7ab7197d117747b23f8149f75f4082c329268377f6b3ce
3
+ metadata.gz: 9e9e89f6b11b38bdd10e46f82670f14bc4c3b6be4793708d1950cd9487b0326a
4
+ data.tar.gz: 97557dad510c8ac560acff87fe174615164142c4c5ca0ef422d849bb99a0412a
5
5
  SHA512:
6
- metadata.gz: 707ab49de07187d9904a2aa28cc43e914c32dbb9ac3a6b66d0b99198b2c66a88a0fd3ebe91262d95d38462d67dfd1ea4e25b50d1c6b2e6dfec1c438be3fe5f9b
7
- data.tar.gz: 4964f7bad268c6cefa516ab8e5faca75bb64d4bd964a248f85070ec5eb1313179c7d11547d3c87f52617e8412732279661770aff210f5f98970b748dcf264655
6
+ metadata.gz: 5befe4a9fb2437add97a51e6e7d777991460552d0b712f71c84a1b95b383e5594548497af84f56c853f6ee4f8f7166200126c137d3c25da16f004201dd43a21d
7
+ data.tar.gz: 3ca75566751184f9c3a891720ec048c9e4c6d9bace74014467b40d9e77230a32c0200400361d025ff2607861ffb249563f5b65eae1efe7391cfabe8b0e8a08b7
@@ -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'
@@ -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,8 +44,8 @@ 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'
@@ -80,6 +80,7 @@ module Lark
80
80
  data = JSON.parse body.to_s
81
81
  result = Result.new(data)
82
82
  raise ::Lark::AccessTokenExpiredError if [99991663, 99991664].include?(result.code)
83
+
83
84
  result
84
85
  end
85
86
 
@@ -102,7 +103,7 @@ module Lark
102
103
  end
103
104
 
104
105
  def success?
105
- code == 0
106
+ code.zero?
106
107
  end
107
108
  end
108
109
  end
@@ -1,3 +1,3 @@
1
1
  module Lark
2
- VERSION = '1.1.2'.freeze
2
+ VERSION = '1.1.3'.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.1.2
4
+ version: 1.1.3
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-10-26 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