k3cloud-sdk 0.4.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/k3cloud.gemspec +2 -2
- data/lib/k3cloud/http.rb +3 -3
- data/lib/k3cloud/version.rb +1 -1
- data/lib/k3cloud/web_api_client.rb +34 -31
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb22e56d62809750b9a0184ca7c85f3d0b54cad33808cae01dea08f387e950d4
|
4
|
+
data.tar.gz: 8811b5a8226229361ba16038253540509c37a43ccebd193a973b4ce59670201b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ad03ae0ad58d2d5b11ab541f46f1786d76d2567d1e4ab24ab27fe991ac5031fa50a291ca620aeeafba5df934276d98c4dc82bae5e57f717d5ddf800f3329c76
|
7
|
+
data.tar.gz: 2b66ed76217f6984789149e893e35328163feed7e0be687ff99accf0cc802c22463791d0267957de4ffa9b14f0a2632bab4ada8be08b520f5f42223628727a3a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/k3cloud.gemspec
CHANGED
@@ -6,10 +6,10 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = "k3cloud-sdk"
|
7
7
|
spec.version = K3cloud::VERSION
|
8
8
|
spec.authors = ["zevinto"]
|
9
|
-
spec.email = ["
|
9
|
+
spec.email = ["zevinto@163.com"]
|
10
10
|
|
11
11
|
spec.summary = "Ruby Gem for K3cloud API."
|
12
|
-
spec.description = "Ruby Gem for
|
12
|
+
spec.description = "Ruby Gem for K3Cloud that uses cryptographic signature technology to avoid plaintext transmission of keys and enables automatic login."
|
13
13
|
spec.homepage = "https://github.com/zevinto/k3cloud-sdk"
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = ">= 2.0.0"
|
data/lib/k3cloud/http.rb
CHANGED
@@ -29,10 +29,10 @@ module K3cloud
|
|
29
29
|
request["User-Agent"] = "Kingdee/Ruby WebApi SDK"
|
30
30
|
request.body = @body.to_json
|
31
31
|
response = http.request(request)
|
32
|
+
if response.code.to_i != 200 && response.code.to_i != 206
|
33
|
+
raise StandardError, "status: #{response.code}, desc: #{response.body}"
|
34
|
+
end
|
32
35
|
response.body
|
33
|
-
rescue StandardError => e
|
34
|
-
K3cloud.logger.warn "#{e.message} => K3cloud::HTTP.post('#{@url}')"
|
35
|
-
nil
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
data/lib/k3cloud/version.rb
CHANGED
@@ -16,38 +16,22 @@ module K3cloud
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def execute(service_name, parameters)
|
19
|
-
|
20
|
-
if
|
21
|
-
url = "https://api.kingdee.com/galaxyapi/"
|
22
|
-
else
|
23
|
-
url = url.to_s.strip.chomp("/")
|
24
|
-
url = "#{url}/#{service_name}.common.kdsvc"
|
25
|
-
end
|
26
|
-
|
27
|
-
header = build_header(get_url_path(url))
|
28
|
-
body = {
|
29
|
-
"format" => 1,
|
30
|
-
"useragent" => "ApiClient",
|
31
|
-
"parameters" => parameters,
|
32
|
-
"v" => "1.0"
|
33
|
-
}
|
34
|
-
request = Http.new(url, header, body, @config.connect_timeout, @config.request_timeout)
|
35
|
-
result = request.post
|
36
|
-
|
37
|
-
if result&.start_with?("response_error:")
|
19
|
+
result = execute_json(service_name, parameters)
|
20
|
+
if result.start_with?("response_error:")
|
38
21
|
error = K3cloudError.parse(result)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
22
|
+
if error.nil?
|
23
|
+
raise StandardError, result
|
24
|
+
else
|
25
|
+
message = error.inner_ex_wrapper.nil? ? error.message : "#{error.message} --> #{error.inner_ex_wrapper&.message}"
|
26
|
+
raise StandardError, message
|
27
|
+
end
|
43
28
|
else
|
44
29
|
begin
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
rescue JSON::ParserError => e
|
30
|
+
json = JSON.parse(result)
|
31
|
+
raise StandardError, json if result.include?(',"IsSuccess":false,')
|
32
|
+
|
33
|
+
json
|
34
|
+
rescue StandardError => e
|
51
35
|
raise StandardError, "JSON parse error, response: [#{result}]", e
|
52
36
|
end
|
53
37
|
end
|
@@ -55,10 +39,26 @@ module K3cloud
|
|
55
39
|
|
56
40
|
private
|
57
41
|
|
58
|
-
def
|
42
|
+
def execute_json(service_name, parameters)
|
43
|
+
url = @config.server_url
|
44
|
+
if url.nil? || url.empty?
|
45
|
+
url = "https://api.kingdee.com/galaxyapi/"
|
46
|
+
else
|
47
|
+
url = url.to_s.strip.chomp("/")
|
48
|
+
end
|
49
|
+
url = "#{url}/#{service_name}.common.kdsvc"
|
50
|
+
K3cloud.logger.info("request_url: #{url}")
|
51
|
+
|
52
|
+
header = build_header(url_path(url))
|
53
|
+
body = { parameters: parameters }
|
54
|
+
request = Http.new(url, header, body, @config.connect_timeout, @config.request_timeout)
|
55
|
+
request.post
|
56
|
+
end
|
57
|
+
|
58
|
+
def url_path(url)
|
59
59
|
if url.start_with?("http")
|
60
60
|
index = url.index("/", 10)
|
61
|
-
index
|
61
|
+
index > -1 ? url[index..-1] : url
|
62
62
|
else
|
63
63
|
url
|
64
64
|
end
|
@@ -94,6 +94,9 @@ module K3cloud
|
|
94
94
|
header[ConstDefine::X_KD_SIGNATURE] = kd_signature
|
95
95
|
end
|
96
96
|
header
|
97
|
+
rescue StandardError => e
|
98
|
+
K3cloud.logger.info("#{e.backtrace}")
|
99
|
+
{}
|
97
100
|
end
|
98
101
|
|
99
102
|
def decode_sec(sec)
|
metadata
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: k3cloud-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zevinto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Ruby Gem for
|
13
|
+
description: Ruby Gem for K3Cloud that uses cryptographic signature technology to
|
14
|
+
avoid plaintext transmission of keys and enables automatic login.
|
14
15
|
email:
|
15
|
-
-
|
16
|
+
- zevinto@163.com
|
16
17
|
executables: []
|
17
18
|
extensions: []
|
18
19
|
extra_rdoc_files: []
|