k3cloud-sdk 0.4.2 → 0.4.3
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/.rubocop.yml +1 -1
- data/Gemfile.lock +1 -1
- data/k3cloud.gemspec +3 -3
- data/lib/k3cloud/errors/k3cloud_error.rb +22 -19
- data/lib/k3cloud/errors/response_error.rb +5 -0
- data/lib/k3cloud/http.rb +2 -1
- data/lib/k3cloud/version.rb +1 -1
- data/lib/k3cloud/web_api_client.rb +14 -17
- data/lib/k3cloud-sdk.rb +0 -1
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54bd3c4fb88b3d92fc46d42fbd9593a775387be902aaba4770ed8c5bc6e01334
|
4
|
+
data.tar.gz: 46d438e27f12297fb4f4d94079673b96cd6291412591dec64b8e2723e10fe88d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d67e92e1d0bc2fd9da533f7c847451eea936eb8bcaaff9659756671daa8a78b5027697f66da4613e5be5c72e6211fdcb572e1611e09a978f35d12164bd4c09b7
|
7
|
+
data.tar.gz: 88ec61fd61042c2c560a33e66e7c28786771c43a18464b7b1fbd835c3d37cfc7d5747026fd288a95777074599a73fe8a0e284ba0683f26a6115687812e7d3662
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/k3cloud.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
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 OpenApi 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"
|
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
23
23
|
end
|
24
24
|
end
|
25
|
-
spec.bindir = "
|
26
|
-
spec.executables = spec.files.grep(%r{\
|
25
|
+
spec.bindir = "bin"
|
26
|
+
spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
29
|
# Uncomment to register a new dependency of your gem
|
@@ -2,27 +2,30 @@
|
|
2
2
|
|
3
3
|
require "json"
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
module K3cloud
|
6
|
+
class K3cloudError < StandardError
|
7
|
+
attr_accessor :message, :inner_ex_wrapper, :inner_exception
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
def initialize
|
10
|
+
@message = nil
|
11
|
+
@inner_ex_wrapper = nil
|
12
|
+
@inner_exception = nil
|
13
|
+
super
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
def self.parse(json)
|
17
|
+
index = json.index("{")
|
18
|
+
json = json[index..-1] if index >= 0
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
parsed_json = JSON.parse(json)
|
21
|
+
kd_error = K3cloudError.new
|
22
|
+
kd_error.message = parsed_json["Message"]
|
23
|
+
kd_error.inner_ex_wrapper = K3cloudError.parse(parsed_json["InnerExWrapper"].to_json)
|
24
|
+
kd_error.inner_exception = K3cloudError.parse(parsed_json["InnerException"].to_json)
|
25
|
+
kd_error
|
26
|
+
rescue StandardError => e
|
27
|
+
K3cloud.logger.error("k3cloud Failed to parse exception message: #{e.message}")
|
28
|
+
nil
|
29
|
+
end
|
27
30
|
end
|
28
31
|
end
|
data/lib/k3cloud/http.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "k3cloud/errors/response_error"
|
3
4
|
require "net/http"
|
4
5
|
require "net/https"
|
5
6
|
require "uri"
|
@@ -30,7 +31,7 @@ module K3cloud
|
|
30
31
|
request.body = @body.to_json
|
31
32
|
response = http.request(request)
|
32
33
|
if response.code.to_i != 200 && response.code.to_i != 206
|
33
|
-
raise
|
34
|
+
raise K3cloud::ResponseError, "status: #{response.code}, desc: #{response.body}"
|
34
35
|
end
|
35
36
|
response.body
|
36
37
|
end
|
data/lib/k3cloud/version.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "k3cloud/errors/k3cloud_error"
|
4
|
+
require "k3cloud/errors/response_error"
|
4
5
|
require "k3cloud/utils/md5_utils"
|
5
6
|
require "k3cloud/utils/base64_utils"
|
6
7
|
require "k3cloud/utils/const_define"
|
@@ -19,20 +20,16 @@ module K3cloud
|
|
19
20
|
result = execute_json(service_name, parameters)
|
20
21
|
if result.start_with?("response_error:")
|
21
22
|
error = K3cloudError.parse(result)
|
22
|
-
if error.nil?
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
23
|
+
raise K3cloud::ResponseError, result if error.nil?
|
24
|
+
|
25
|
+
message = error.inner_ex_wrapper.nil? ? error.message : "#{error.message} --> #{error.inner_ex_wrapper&.message}"
|
26
|
+
raise K3cloud::ResponseError, message
|
27
|
+
|
28
28
|
else
|
29
29
|
begin
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
json
|
34
|
-
rescue StandardError => e
|
35
|
-
raise StandardError, "JSON parse error, response: [#{result}]", e
|
30
|
+
JSON.parse(result)
|
31
|
+
rescue JSON::ParserError
|
32
|
+
raise K3cloud::ResponseError, "JSON parse error, response: [#{result}]"
|
36
33
|
end
|
37
34
|
end
|
38
35
|
end
|
@@ -41,11 +38,11 @@ module K3cloud
|
|
41
38
|
|
42
39
|
def execute_json(service_name, parameters)
|
43
40
|
url = @config.server_url
|
44
|
-
if url.nil? || url.empty?
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
url = if url.nil? || url.empty?
|
42
|
+
"https://api.kingdee.com/galaxyapi/"
|
43
|
+
else
|
44
|
+
url.to_s.strip.chomp("/")
|
45
|
+
end
|
49
46
|
url = "#{url}/#{service_name}.common.kdsvc"
|
50
47
|
K3cloud.logger.info("request_url: #{url}")
|
51
48
|
|
data/lib/k3cloud-sdk.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,22 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zevinto
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2023-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Ruby Gem for
|
14
|
-
avoid plaintext transmission of keys and enables automatic login.
|
13
|
+
description: Ruby Gem for K3cloud OpenApi that uses cryptographic signature technology
|
14
|
+
to avoid plaintext transmission of keys and enables automatic login.
|
15
15
|
email:
|
16
16
|
- zevinto@163.com
|
17
|
-
executables:
|
17
|
+
executables:
|
18
|
+
- console
|
19
|
+
- setup
|
18
20
|
extensions: []
|
19
21
|
extra_rdoc_files: []
|
20
22
|
files:
|
@@ -34,6 +36,7 @@ files:
|
|
34
36
|
- lib/k3cloud.rb
|
35
37
|
- lib/k3cloud/configuration.rb
|
36
38
|
- lib/k3cloud/errors/k3cloud_error.rb
|
39
|
+
- lib/k3cloud/errors/response_error.rb
|
37
40
|
- lib/k3cloud/http.rb
|
38
41
|
- lib/k3cloud/k3cloud_api.rb
|
39
42
|
- lib/k3cloud/utils/base64_utils.rb
|