tencentcloud-sdk-ruby 0.3.4 → 0.3.6
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/Gemfile.lock +2 -2
- data/examples/nlp/v20190408/lexical_analysis.rb +17 -0
- data/examples/ocr/v20181119/bussiness_card.rb +2 -2
- data/examples/ocr/v20181119/recognize_table_ocr.rb +15 -0
- data/examples/tms/v20190722/text_moderation.rb +2 -2
- data/examples/trtc/v20190722/describe_room_information.rb +2 -2
- data/examples/trtc/v20190722/start_mcu_mix_transcode.rb +2 -2
- data/lib/tencent_cloud/captcha/v20190722/captcha_client.rb +108 -0
- data/lib/tencent_cloud/common/base_client.rb +6 -3
- data/lib/tencent_cloud/nlp/v20190408/nlp_client.rb +41 -0
- data/lib/tencent_cloud/ocr/v20181119/ocr_client.rb +5 -0
- data/lib/tencent_cloud/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a660b1a26fdbd2f0564ad8fd9dd2ca52b1a1dc57186f7bf0e8832eda35cab4e5
|
4
|
+
data.tar.gz: 1a382388800705f92ee23cf46127d67b1cc48e1b2a3f96d07a64c9347587102c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09c0b042a6dfb3c4fc80995560ec8e69814b6d6c30d7fae93c9b4d21ba056b16b1fe34ade7cff0ad5ed756e6d1913c2b2c712bfbb6deef4c49d4190fa0b3bc3b'
|
7
|
+
data.tar.gz: 96ec85883076fec0694fcc19083d7beddd82d43ec21fab653cf94a8cca5a8430a2aff94a73a16f5072e22548268a0306d8ff38a712c18b59f00b5a3c6e2b3617
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tencentcloud-sdk-ruby (0.3.
|
4
|
+
tencentcloud-sdk-ruby (0.3.5)
|
5
5
|
typhoeus (~> 1.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -11,7 +11,7 @@ GEM
|
|
11
11
|
diff-lcs (1.3)
|
12
12
|
ethon (0.14.0)
|
13
13
|
ffi (>= 1.15.0)
|
14
|
-
ffi (1.15.
|
14
|
+
ffi (1.15.4)
|
15
15
|
method_source (1.0.0)
|
16
16
|
pry (0.13.1)
|
17
17
|
coderay (~> 1.1)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'tencent_cloud'
|
5
|
+
require 'tencent_cloud/nlp/v20190408/nlp_client'
|
6
|
+
# replace secret_id secret_key
|
7
|
+
secret_id = ENV['TENCENT_SECRET_ID']
|
8
|
+
secret_key = ENV['TENCENT_SECRET_KEY']
|
9
|
+
credential = TencentCloud::Common::Credential.new(secret_id, secret_key)
|
10
|
+
payload = {
|
11
|
+
'Text' => '阿森纳俱乐部的成立则晚于热刺4年。它最早成立的地方并不是伦敦北部,而是伦敦东南部的戴尔广场的皇家兵工厂地带。它最早的名字叫做皇家阿森纳队。
|
12
|
+
1891年,这支球队才完成了职业化改革,成为了职业俱乐部,球队名称更名为:“伍尔维奇阿森纳”(Woolwich Arsenal)。加入乙级联赛(当时英格兰最高赛事是英甲)。
|
13
|
+
阿森纳和热刺的矛盾是在1913年的那次搬迁。1910年,亨利-诺里斯爵士成为了伍尔维奇-阿森纳的最大股东,而这个诺里斯爵士在当时还有个身份——富勒姆主席。',
|
14
|
+
'Flag' => 2
|
15
|
+
}
|
16
|
+
resp = TencentCloud::NlpClient.new(credential, 'ap-guangzhou').lexical_analysis(payload)
|
17
|
+
pp JSON.parse(resp.body)
|
@@ -4,8 +4,8 @@ require 'bundler/setup'
|
|
4
4
|
require 'tencent_cloud'
|
5
5
|
require 'tencent_cloud/ocr/v20181119/ocr_client'
|
6
6
|
# replace secret_id secret_key
|
7
|
-
secret_id = '
|
8
|
-
secret_key = '
|
7
|
+
secret_id = ENV['TENCENT_SECRET_ID']
|
8
|
+
secret_key = ENV['TENCENT_SECRET_KEY']
|
9
9
|
credential = TencentCloud::Common::Credential.new(secret_id, secret_key)
|
10
10
|
payload = {
|
11
11
|
'ImageUrl' => 'IMAGE URL'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'tencent_cloud'
|
5
|
+
require 'tencent_cloud/ocr/v20181119/ocr_client'
|
6
|
+
# replace secret_id secret_key
|
7
|
+
secret_id = ENV['TENCENT_SECRET_ID']
|
8
|
+
secret_key = ENV['TENCENT_SECRET_KEY']
|
9
|
+
credential = TencentCloud::Common::Credential.new(secret_id, secret_key)
|
10
|
+
payload = {
|
11
|
+
'ImageUrl' => '',
|
12
|
+
'IsPdf' => true
|
13
|
+
}
|
14
|
+
resp = TencentCloud::OcrClient.new(credential, 'ap-beijing').recognize_table_ocr(payload)
|
15
|
+
pp JSON.parse(resp.body)
|
@@ -5,8 +5,8 @@ require 'tencent_cloud'
|
|
5
5
|
require 'tencent_cloud/tms/v20200713/tms_client'
|
6
6
|
require 'base64'
|
7
7
|
# replace secret_id secret_key
|
8
|
-
secret_id = '
|
9
|
-
secret_key = '
|
8
|
+
secret_id = ENV['TENCENT_SECRET_ID']
|
9
|
+
secret_key = ENV['TENCENT_SECRET_KEY']
|
10
10
|
credential = TencentCloud::Common::Credential.new(secret_id, secret_key)
|
11
11
|
str = Base64.encode64('
|
12
12
|
北京时间12月16日,在马刺对阵火箭的比赛中,马刺遗憾输掉比赛。不过马刺也不是没有惊喜,他们的首轮秀瓦塞尔继续有精彩表现,全场打了31分钟,拿到了11分4板4抢断,8投4中的命中率。虽然球队输球,但是瓦塞尔的表现不错,不仅进攻端表现出色,面对哈登也不胆怯,哈登全场10投3中,被成功防死,瓦塞尔功不可没。
|
@@ -4,8 +4,8 @@ require 'bundler/setup'
|
|
4
4
|
require 'tencent_cloud'
|
5
5
|
require 'tencent_cloud/trtc/v20190722/trtc_client'
|
6
6
|
# replace secret_id secret_key
|
7
|
-
secret_id = '
|
8
|
-
secret_key = '
|
7
|
+
secret_id = ENV['TENCENT_SECRET_ID']
|
8
|
+
secret_key = ENV['TENCENT_SECRET_KEY']
|
9
9
|
credential = TencentCloud::Common::Credential.new(secret_id, secret_key)
|
10
10
|
payload = {
|
11
11
|
'SdkAppId' => 'SDKAPPID',
|
@@ -4,8 +4,8 @@ require 'bundler/setup'
|
|
4
4
|
require 'tencent_cloud'
|
5
5
|
require 'tencent_cloud/trtc/v20190722/trtc_client'
|
6
6
|
# replace secret_id secret_key
|
7
|
-
secret_id = '
|
8
|
-
secret_key = '
|
7
|
+
secret_id = ENV['TENCENT_SECRET_ID']
|
8
|
+
secret_key = ENV['TENCENT_SECRET_KEY']
|
9
9
|
credential = TencentCloud::Common::Credential.new(secret_id, secret_key)
|
10
10
|
|
11
11
|
payload = {
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module TencentCloud
|
6
|
+
class CaptchaClient
|
7
|
+
API_VERSION = '2019-07-22'
|
8
|
+
Action = 'DescribeCaptchaResult'
|
9
|
+
CaptchaType = 9
|
10
|
+
REQUEST_PATH = '/'
|
11
|
+
JSON_CONTENT = 'application/json'
|
12
|
+
MULTIPART_CONTENT = 'multipart/form-data'
|
13
|
+
FORM_URLENCODED_CONTENT = 'application/x-www-form-urlencoded'
|
14
|
+
ENDPOINT = 'captcha.tencentcloudapi.com'
|
15
|
+
|
16
|
+
def initialize(secret_id, secret_key)
|
17
|
+
@api_version = '2019-07-22'
|
18
|
+
@secret_id = secret_id
|
19
|
+
@secret_key = secret_key
|
20
|
+
@token = nil
|
21
|
+
@region = nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def http_request(data)
|
25
|
+
uri = URI.parse("https://#{ENDPOINT}")
|
26
|
+
request = Net::HTTP::Post.new(uri.to_s)
|
27
|
+
request = build_req_with_v3_signature(Action, data, request, options = {})
|
28
|
+
|
29
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
30
|
+
http.request request
|
31
|
+
end
|
32
|
+
end
|
33
|
+
def build_req_with_v3_signature(action, params, req, options = {})
|
34
|
+
content_type = JSON_CONTENT
|
35
|
+
timestamp = Time.current.to_i
|
36
|
+
header = {}
|
37
|
+
header['Content-Type'] = content_type
|
38
|
+
header['Host'] = ENDPOINT
|
39
|
+
header['X-TC-Action'] = action
|
40
|
+
header['X-TC-Timestamp'] = timestamp
|
41
|
+
header['X-TC-Version'] = @api_version
|
42
|
+
header['X-TC-Region'] = @region
|
43
|
+
header['X-TC-Token'] = @token if @token
|
44
|
+
req.body = JSON.generate(params, { 'ascii_only' => true, 'space' => ' ' })
|
45
|
+
payload = req.body
|
46
|
+
canonical_querystring = ''
|
47
|
+
hashed_payload = Digest::SHA256.hexdigest(payload)
|
48
|
+
|
49
|
+
authorization = sign_v3(content_type, ENDPOINT, 'POST', '/',
|
50
|
+
canonical_querystring, hashed_payload, header['X-TC-Timestamp'],
|
51
|
+
@secret_id, @secret_key)
|
52
|
+
header['Authorization'] = authorization
|
53
|
+
header.each do |k, v|
|
54
|
+
req[k] = v
|
55
|
+
end
|
56
|
+
req
|
57
|
+
end
|
58
|
+
def sign_v3(content_type, endpoint, method, uri, query, payload, timestamp, secret_id, secret_key)
|
59
|
+
canonical_headers = "content-type:#{content_type}\nhost:#{endpoint}\n"
|
60
|
+
signed_headers = 'content-type;host'
|
61
|
+
canonical_request = [
|
62
|
+
method,
|
63
|
+
uri,
|
64
|
+
query,
|
65
|
+
canonical_headers,
|
66
|
+
signed_headers,
|
67
|
+
payload,
|
68
|
+
].join("\n")
|
69
|
+
service = endpoint.split('.')[0]
|
70
|
+
|
71
|
+
date = Time.at(timestamp).utc.strftime('%Y-%m-%d')
|
72
|
+
credential_scope = date + '/' + service + '/' + 'tc3_request'
|
73
|
+
algorithm = 'TC3-HMAC-SHA256'
|
74
|
+
hashed_request_payload = Digest::SHA256.hexdigest(canonical_request)
|
75
|
+
string_to_sign = [
|
76
|
+
algorithm,
|
77
|
+
timestamp,
|
78
|
+
credential_scope,
|
79
|
+
hashed_request_payload,
|
80
|
+
].join("\n")
|
81
|
+
|
82
|
+
digest = OpenSSL::Digest.new('sha256')
|
83
|
+
secret_date = OpenSSL::HMAC.digest(digest, 'TC3' + secret_key, date)
|
84
|
+
secret_service = OpenSSL::HMAC.digest(digest, secret_date, service)
|
85
|
+
secret_signing = OpenSSL::HMAC.digest(digest, secret_service, 'tc3_request')
|
86
|
+
signature = OpenSSL::HMAC.hexdigest(digest, secret_signing, string_to_sign)
|
87
|
+
"#{algorithm} Credential=#{secret_id}/#{credential_scope}, SignedHeaders=#{signed_headers}, Signature=#{signature}"
|
88
|
+
end
|
89
|
+
def format_params(prefix = nil, params)
|
90
|
+
d = {}
|
91
|
+
case params
|
92
|
+
when Hash
|
93
|
+
params.each do |k, v|
|
94
|
+
key = prefix ? "#{prefix}.#{k}" : k.to_s
|
95
|
+
d.update(format_params(key, v))
|
96
|
+
end
|
97
|
+
when Array
|
98
|
+
params.each_with_index do |v, i|
|
99
|
+
key = prefix ? "#{prefix}.#{i}" : i.to_s
|
100
|
+
d.update(format_params(key, v))
|
101
|
+
end
|
102
|
+
else
|
103
|
+
d[prefix] = params
|
104
|
+
end
|
105
|
+
d
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -7,7 +7,7 @@ require 'tencent_cloud/common/http/sign'
|
|
7
7
|
module TencentCloud
|
8
8
|
module Common
|
9
9
|
class BaseClient
|
10
|
-
def initialize(credential, region)
|
10
|
+
def initialize(credential, region = nil)
|
11
11
|
@credential = credential
|
12
12
|
@region = region
|
13
13
|
end
|
@@ -22,10 +22,13 @@ module TencentCloud
|
|
22
22
|
headers = {
|
23
23
|
'X-TC-Action' => action,
|
24
24
|
'X-TC-Version' => self.class::API_VERSION,
|
25
|
-
'X-TC-Region' => @region,
|
26
25
|
'X-TC-Timestamp' => Time.now.to_i
|
27
26
|
}
|
28
|
-
|
27
|
+
headers['X-TC-Region'] = @region if @region
|
28
|
+
request = TencentCloud::Common::Http::Request.new @credential,
|
29
|
+
self.class,
|
30
|
+
headers: headers,
|
31
|
+
body: JSON.generate(body, space: ' ')
|
29
32
|
request.run
|
30
33
|
end
|
31
34
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'tencent_cloud/common/base_client'
|
4
|
+
module TencentCloud
|
5
|
+
class NlpClient < Common::BaseClient
|
6
|
+
API_VERSION = '2019-04-08'
|
7
|
+
ENDPOINT = 'nlp.tencentcloudapi.com'
|
8
|
+
SERVICE_NAME = 'nlp'
|
9
|
+
APIS = {
|
10
|
+
#################### 自然语言处理 > 词法分析相关接口
|
11
|
+
# 词法分析
|
12
|
+
# https://cloud.tencent.com/document/api/271/35494
|
13
|
+
lexical_analysis: 'LexicalAnalysis',
|
14
|
+
|
15
|
+
# 相似词
|
16
|
+
# https://cloud.tencent.com/document/api/271/35493
|
17
|
+
similar_words: 'SimilarWords',
|
18
|
+
|
19
|
+
#################### 自然语言处理 > 篇章分析相关接口
|
20
|
+
# 自动摘要
|
21
|
+
# https://cloud.tencent.com/document/api/271/35499
|
22
|
+
auto_summarization: 'AutoSummarization',
|
23
|
+
|
24
|
+
# 情感分析
|
25
|
+
# https://cloud.tencent.com/document/api/271/35497
|
26
|
+
sentiment_analysis: 'SentimentAnalysis',
|
27
|
+
|
28
|
+
# 关键词提取
|
29
|
+
# https://cloud.tencent.com/document/api/271/35498
|
30
|
+
keywords_extraction: 'KeywordsExtraction',
|
31
|
+
|
32
|
+
# 文本分类
|
33
|
+
# https://cloud.tencent.com/document/api/271/35496
|
34
|
+
text_classification: 'TextClassification',
|
35
|
+
|
36
|
+
# 词法分析V2
|
37
|
+
# https://cloud.tencent.com/document/product/271/90611
|
38
|
+
parse_words: 'ParseWords'
|
39
|
+
}.freeze
|
40
|
+
end
|
41
|
+
end
|
@@ -121,6 +121,11 @@ module TencentCloud
|
|
121
121
|
## 金融票据整单识别
|
122
122
|
## https://cloud.tencent.com/document/api/866/38296
|
123
123
|
finan_bill_ocr: 'FinanBillOCR',
|
124
|
+
|
125
|
+
#################### 行业文档识别相关接口
|
126
|
+
## 表格识别(V2)
|
127
|
+
## https://cloud.tencent.com/document/product/866/49525
|
128
|
+
recognize_table_ocr: 'RecognizeTableOCR'
|
124
129
|
}.freeze
|
125
130
|
end
|
126
131
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tencentcloud-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FengCe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,16 +99,20 @@ files:
|
|
99
99
|
- Rakefile
|
100
100
|
- bin/console
|
101
101
|
- bin/setup
|
102
|
+
- examples/nlp/v20190408/lexical_analysis.rb
|
102
103
|
- examples/ocr/v20181119/bussiness_card.rb
|
104
|
+
- examples/ocr/v20181119/recognize_table_ocr.rb
|
103
105
|
- examples/tms/v20190722/text_moderation.rb
|
104
106
|
- examples/trtc/v20190722/describe_room_information.rb
|
105
107
|
- examples/trtc/v20190722/start_mcu_mix_transcode.rb
|
106
108
|
- lib/tencent_cloud.rb
|
109
|
+
- lib/tencent_cloud/captcha/v20190722/captcha_client.rb
|
107
110
|
- lib/tencent_cloud/common/base_client.rb
|
108
111
|
- lib/tencent_cloud/common/credential.rb
|
109
112
|
- lib/tencent_cloud/common/exception/tencent_cloud_sdk_exception.rb
|
110
113
|
- lib/tencent_cloud/common/http/request.rb
|
111
114
|
- lib/tencent_cloud/common/http/sign.rb
|
115
|
+
- lib/tencent_cloud/nlp/v20190408/nlp_client.rb
|
112
116
|
- lib/tencent_cloud/ocr/v20181119/ocr_client.rb
|
113
117
|
- lib/tencent_cloud/tms/v20200713/tms_client.rb
|
114
118
|
- lib/tencent_cloud/tpns/v20210422/tpns_client.rb
|
@@ -137,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
141
|
- !ruby/object:Gem::Version
|
138
142
|
version: '0'
|
139
143
|
requirements: []
|
140
|
-
rubygems_version: 3.
|
144
|
+
rubygems_version: 3.4.13
|
141
145
|
signing_key:
|
142
146
|
specification_version: 4
|
143
147
|
summary: 腾讯云开发者工具套件(SDK)3.0,SDK3.0是云 API3.0 平台的配套工具
|