tencentcloud-sdk-ruby 0.3.1 → 0.3.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25511cf9fe38372b9a86f1fcaaee0a8e4904099ef4c195fef193a737e8b05a2f
4
- data.tar.gz: 190e111e10d523adc06b57fa9b84b8dc78b2c6034fc24c482c38abd59d2b5024
3
+ metadata.gz: 47dcff18eb491fc54a7245fbde3797859ec7b83011c861000a647694a77a6896
4
+ data.tar.gz: 7f7fa4e1f522f04e7adae9dcd4910f65bf7efd04632e921a8bdc83c816f0aa52
5
5
  SHA512:
6
- metadata.gz: 4ee550925f47810de542d09d3b64c9beb45a26b57467dd851389a007d90e16de59bd2e894d239c2fa570b26bd8519b762090a68c3f5335607d3c03b1814dfcd2
7
- data.tar.gz: 8230ed2680ccd8b3b0ee9abe78b0505ad653510a0ca836aaf1b4986c3aa192410811260251501d042fd338bad418ea1d72ed11566be80067b4b9a0686e75cf25
6
+ metadata.gz: 56adc3b2428d5108b27c1edc9ddae500dc0ee0ba92eda22c93bf68184c77b96559ff38b8c7cfb7939e6651f2e15c6b24d3c3513ff6ef62455e058777c37e3353
7
+ data.tar.gz: 6eb392b2e55868edb8d500672ea4dd7a82715ef5c32a6a9cbf563427a45654770060feb11d6cee7e17bcd25c6217dd74779577c64d96746af0ec2703d086afef
data/.gitignore CHANGED
@@ -6,6 +6,6 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
-
9
+ .history/
10
10
  # rspec failure tracking
11
11
  .rspec_status
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tencentcloud-sdk-ruby (0.3.1)
4
+ tencentcloud-sdk-ruby (0.3.5)
5
5
  typhoeus (~> 1.0)
6
6
 
7
7
  GEM
@@ -9,9 +9,9 @@ GEM
9
9
  specs:
10
10
  coderay (1.1.3)
11
11
  diff-lcs (1.3)
12
- ethon (0.12.0)
13
- ffi (>= 1.3.0)
14
- ffi (1.13.1)
12
+ ethon (0.14.0)
13
+ ffi (>= 1.15.0)
14
+ ffi (1.15.4)
15
15
  method_source (1.0.0)
16
16
  pry (0.13.1)
17
17
  coderay (~> 1.1)
@@ -44,4 +44,4 @@ DEPENDENCIES
44
44
  tencentcloud-sdk-ruby!
45
45
 
46
46
  BUNDLED WITH
47
- 2.1.4
47
+ 2.2.16
data/README.md CHANGED
@@ -1,9 +1,4 @@
1
1
  # TencentCloud
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tencent_cloud`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
2
  ## Installation
8
3
 
9
4
  Add this line to your application's Gemfile:
@@ -22,18 +17,21 @@ Or install it yourself as:
22
17
 
23
18
  ## Usage
24
19
 
25
- TODO: Write usage instructions here
26
-
20
+ ```ruby
21
+ require 'tencent_cloud/ocr/v20181119/ocr_client'
22
+ credential = TencentCloud::Common::Credential.new(SECRET_ID, SECRET_KEY)
23
+ payload = {
24
+ 'ImageUrl' => 'IMAGE URL'
25
+ }
26
+ resp = TencentCloud::OcrClient.new(credential, 'ap-beijing').business_card_ocr(payload)
27
+ pp JSON.parse(resp.body)
28
+ ```
27
29
  ## Development
28
30
 
29
31
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
32
 
31
33
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
34
 
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tencent_cloud. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
-
37
35
  ## License
38
36
 
39
37
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -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 = 'SECRET_ID'
8
- secret_key = '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 = 'SECRET_ID'
9
- secret_key = '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 = 'SECRET_ID'
8
- secret_key = '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 = 'SECRET_ID'
8
- secret_key = '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 = {
@@ -3,6 +3,7 @@
3
3
  require 'openssl'
4
4
  require 'typhoeus'
5
5
  require 'uri'
6
+ require 'cgi'
6
7
  require 'json'
7
8
  module TencentCloud
8
9
  module Common
@@ -78,7 +79,7 @@ module TencentCloud
78
79
 
79
80
  def canonical_uri
80
81
  uri = URI(request.base_url)
81
- url_path = URI.encode(uri.path)
82
+ url_path = CGI.escape(uri.path)
82
83
  url_path == '' ? '/' : url_path
83
84
  end
84
85
 
@@ -0,0 +1,37 @@
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
+ }.freeze
36
+ end
37
+ 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
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+ require 'base64'
3
+ require 'openssl'
4
+ require 'net/http'
5
+ require 'uri'
6
+ require 'cgi'
7
+ require 'json'
8
+ module TencentCloud
9
+ class TpnsClient
10
+ API_VERSION = '2021-04-22'
11
+ ENDPOINTS = {
12
+ 'gz' => 'https://api.tpns.tencent.com',
13
+ 'sh' => 'https://api.tpns.sh.tencent.com',
14
+ 'hk' => 'https://api.tpns.hk.tencent.com',
15
+ 'sg' => 'https://api.tpns.sgp.tencent.com'
16
+ }
17
+
18
+ def initialize(access_id, secret_key, region)
19
+ @access_id = access_id
20
+ @secret_key = secret_key
21
+ @end_point = ENDPOINTS[region.to_s]
22
+ end
23
+
24
+ def http_request(api_path, data)
25
+ current_timestamp = Time.current.to_i.to_s
26
+ uri = URI.parse("#{@end_point}#{api_path}")
27
+
28
+ request = Net::HTTP::Post.new(uri.to_s)
29
+ request.body = data.to_json
30
+ request.initialize_http_header({AccessId: @access_id, TimeStamp: current_timestamp, Sign: sign(current_timestamp, request.body)})
31
+ request.set_content_type 'application/json'
32
+
33
+ Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
34
+ http.request request
35
+ end
36
+ end
37
+
38
+ def sign(current_timestamp, body)
39
+ Base64.strict_encode64(OpenSSL::HMAC.hexdigest('sha256', @secret_key, "#{current_timestamp}#{@access_id}#{body}"))
40
+ end
41
+ end
42
+ end
@@ -56,7 +56,7 @@ module TencentCloud
56
56
  #################### 房间管理相关接口
57
57
  ## 解散房间
58
58
  ## https://cloud.tencent.com/document/api/647/37088
59
- dissmiss_room: 'DissmissRoom',
59
+ dissmiss_room: 'DismissRoom',
60
60
  ## 移出用户
61
61
  ## https://cloud.tencent.com/document/api/647/40496
62
62
  remove_user: 'RemoveUser',
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TencentCloud
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.5'
5
5
  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.1
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - FengCe
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-16 00:00:00.000000000 Z
11
+ date: 2021-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,7 +99,9 @@ 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
@@ -109,8 +111,10 @@ files:
109
111
  - lib/tencent_cloud/common/exception/tencent_cloud_sdk_exception.rb
110
112
  - lib/tencent_cloud/common/http/request.rb
111
113
  - lib/tencent_cloud/common/http/sign.rb
114
+ - lib/tencent_cloud/nlp/v20190408/nlp_client.rb
112
115
  - lib/tencent_cloud/ocr/v20181119/ocr_client.rb
113
116
  - lib/tencent_cloud/tms/v20200713/tms_client.rb
117
+ - lib/tencent_cloud/tpns/v20210422/tpns_client.rb
114
118
  - lib/tencent_cloud/trtc/v20190722/trtc_client.rb
115
119
  - lib/tencent_cloud/version.rb
116
120
  - tencent_cloud.gemspec
@@ -121,7 +125,7 @@ metadata:
121
125
  homepage_uri: https://github.com/acecamp/tencentcloud-sdk-ruby
122
126
  source_code_uri: https://github.com/acecamp/tencentcloud-sdk-ruby
123
127
  changelog_uri: https://github.com/acecamp/agora-education-web-demo/blob/master/CHANGELOG.txt
124
- post_install_message:
128
+ post_install_message:
125
129
  rdoc_options: []
126
130
  require_paths:
127
131
  - lib
@@ -136,8 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
140
  - !ruby/object:Gem::Version
137
141
  version: '0'
138
142
  requirements: []
139
- rubygems_version: 3.1.2
140
- signing_key:
143
+ rubygems_version: 3.2.15
144
+ signing_key:
141
145
  specification_version: 4
142
146
  summary: 腾讯云开发者工具套件(SDK)3.0,SDK3.0是云 API3.0 平台的配套工具
143
147
  test_files: []