rongcloud-server-sdk 1.0.1 → 1.1.0
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/.env.defaults +2 -0
- data/.overcommit.yml +4 -0
- data/Gemfile.lock +3 -3
- data/README.md +58 -4
- data/lib/rongcloud/api/user.rb +3 -0
- data/lib/rongcloud/api.rb +2 -2
- data/lib/rongcloud/http.rb +2 -2
- data/lib/rongcloud/version.rb +1 -1
- data/rongcloud-server-sdk.gemspec +38 -0
- metadata +4 -3
- data/.rubocop +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0898c0d2461a0ecc981eba721cc87642bb26100b9a5af85f0a157d96cdcf9b41'
|
4
|
+
data.tar.gz: 1245cc5bf1ffeefad59cb70076a5ebcbc12726bdecb0cf9e63788155dbfa8a4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ada95eaf38153ee31309295c2fce303efd8236ba2d3f04599541a0bad90deb7eb8fb32dab8daf1c7a85b676ec69086d954c1dc5fa1f9197dcf55ef9985135622
|
7
|
+
data.tar.gz: 34ee47d12ead0fd583f655a2f1a5b341745e3c9eb92f637e9e34a79b83743cbacf6673c1f7dcc1a83c08289e10ca1ff4597440fa62b4b9c9cfe77e9f515e515c
|
data/.env.defaults
ADDED
data/.overcommit.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rongcloud-server-sdk (1.0
|
4
|
+
rongcloud-server-sdk (1.1.0)
|
5
5
|
http (~> 5.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -17,12 +17,12 @@ GEM
|
|
17
17
|
domain_name (0.5.20190701)
|
18
18
|
unf (>= 0.0.5, < 1.0.0)
|
19
19
|
dotenv (2.8.1)
|
20
|
-
ffi (1.
|
20
|
+
ffi (1.16.3)
|
21
21
|
ffi-compiler (1.0.1)
|
22
22
|
ffi (>= 1.0.0)
|
23
23
|
rake
|
24
24
|
hashdiff (1.0.1)
|
25
|
-
http (5.1.
|
25
|
+
http (5.1.1)
|
26
26
|
addressable (~> 2.8)
|
27
27
|
http-cookie (~> 1.0)
|
28
28
|
http-form_data (~> 2.2)
|
data/README.md
CHANGED
@@ -23,7 +23,9 @@ Or install it yourself as:
|
|
23
23
|
## Usage
|
24
24
|
|
25
25
|
```ruby
|
26
|
-
rongcloud
|
26
|
+
require "rongcloud"
|
27
|
+
|
28
|
+
rongcloud = RongCloud::Client.new(
|
27
29
|
app_key: ENV["RONGCLOUD_APP_KEY"],
|
28
30
|
app_secret: ENV["RONGCLOUD_APP_SECRET"],
|
29
31
|
host: "api-cn.ronghub.com"
|
@@ -49,21 +51,34 @@ The API name is converted from the corresponding URI, E.g.
|
|
49
51
|
### Timeout
|
50
52
|
|
51
53
|
```ruby
|
52
|
-
rongcloud = RongCloud::Client
|
54
|
+
rongcloud = RongCloud::Client.new(
|
53
55
|
app_key: ENV["RONGCLOUD_APP_KEY"],
|
54
56
|
app_secret: ENV["RONGCLOUD_APP_SECRET"],
|
55
57
|
host: "api-cn.ronghub.com",
|
56
58
|
http: {
|
57
59
|
timeout_class: HTTP::Timeout::Global,
|
58
|
-
timeout_options: {global_timeout:
|
60
|
+
timeout_options: {global_timeout: 5}
|
59
61
|
}
|
60
62
|
)
|
63
|
+
|
64
|
+
# Use the global HTTP timeout options.
|
65
|
+
rongcloud.api.user.gettoken({
|
66
|
+
userId: "nutzer", name: "John Doe"
|
67
|
+
})
|
68
|
+
|
69
|
+
# Override global HTTP timeout options in a specific HTTP request.
|
70
|
+
rongcloud.api.user.gettoken({
|
71
|
+
userId: "nutzer", name: "John Doe"
|
72
|
+
}, {
|
73
|
+
timeout_class: HTTP::Timeout::Global,
|
74
|
+
timeout_options: {global_timeout: 10}
|
75
|
+
})
|
61
76
|
```
|
62
77
|
|
63
78
|
### Logging
|
64
79
|
|
65
80
|
```ruby
|
66
|
-
rongcloud = RongCloud::Client
|
81
|
+
rongcloud = RongCloud::Client.new(
|
67
82
|
app_key: ENV["RONGCLOUD_APP_KEY"],
|
68
83
|
app_secret: ENV["RONGCLOUD_APP_SECRET"],
|
69
84
|
host: "api-cn.ronghub.com",
|
@@ -75,6 +90,45 @@ rongcloud = RongCloud::Client::new(
|
|
75
90
|
)
|
76
91
|
```
|
77
92
|
|
93
|
+
### Request ID
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
class RequestID < HTTP::Feature
|
97
|
+
def wrap_request(req)
|
98
|
+
req.headers["X-Request-ID"] = make_request_id
|
99
|
+
req
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def make_request_id
|
105
|
+
Thread.current[:request_id] || SecureRandom.uuid
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
rongcloud = RongCloud::Client.new(
|
110
|
+
app_key: ENV["RONGCLOUD_APP_KEY"],
|
111
|
+
app_secret: ENV["RONGCLOUD_APP_SECRET"],
|
112
|
+
host: "api-cn.ronghub.com",
|
113
|
+
http: {
|
114
|
+
features: {
|
115
|
+
request_id: RequestID.new
|
116
|
+
}
|
117
|
+
}
|
118
|
+
)
|
119
|
+
```
|
120
|
+
|
121
|
+
### Signature Verify
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
verified = RongCloud::Signer.verify?(
|
125
|
+
app_secret: ENV["RONGCLOUD_APP_SECRET"],
|
126
|
+
nonce: params["nonce"],
|
127
|
+
timestamp: params["timestamp"],
|
128
|
+
signature: params["signature"]
|
129
|
+
)
|
130
|
+
```
|
131
|
+
|
78
132
|
|
79
133
|
## Development
|
80
134
|
|
data/lib/rongcloud/api/user.rb
CHANGED
@@ -7,6 +7,9 @@ module RongCloud
|
|
7
7
|
member "/user/token/expire.json"
|
8
8
|
member "/user/info.json"
|
9
9
|
member "/user/refresh.json"
|
10
|
+
member "/user/tag/set.json", format: :json
|
11
|
+
member "/user/tag/batch/set.json", format: :json
|
12
|
+
member "/user/tags/get.json"
|
10
13
|
|
11
14
|
member "/user/block.json"
|
12
15
|
member "/user/block/query.json"
|
data/lib/rongcloud/api.rb
CHANGED
@@ -32,8 +32,8 @@ module RongCloud
|
|
32
32
|
end
|
33
33
|
|
34
34
|
format = options[:format] || :form
|
35
|
-
define_method(meth) do |payload|
|
36
|
-
client.post(url, format => payload)
|
35
|
+
define_method(meth) do |payload, opts = {}|
|
36
|
+
client.post(url, opts.merge(format => payload))
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/lib/rongcloud/http.rb
CHANGED
@@ -17,7 +17,7 @@ module RongCloud
|
|
17
17
|
|
18
18
|
nonce = random_str(16)
|
19
19
|
timestamp = (Time.now.to_f * 1000).to_i.to_s
|
20
|
-
options[:headers] = {
|
20
|
+
options[:headers] = (options[:headers] || {}).merge({
|
21
21
|
"RC-App-Key" => @client.app_key,
|
22
22
|
"RC-Nonce" => nonce,
|
23
23
|
"RC-Timestamp" => timestamp,
|
@@ -26,7 +26,7 @@ module RongCloud
|
|
26
26
|
nonce: nonce,
|
27
27
|
timestamp: timestamp
|
28
28
|
})
|
29
|
-
}
|
29
|
+
})
|
30
30
|
|
31
31
|
begin
|
32
32
|
response = http(@options).request(verb, uri, options)
|
data/lib/rongcloud/version.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/rongcloud/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "rongcloud-server-sdk"
|
7
|
+
spec.version = RongCloud::VERSION
|
8
|
+
spec.authors = ["John Doe"]
|
9
|
+
spec.email = ["johndoe@example.com"]
|
10
|
+
|
11
|
+
spec.summary = "RongCloud Server SDK in Ruby."
|
12
|
+
spec.description = "RongCloud Server SDK in Ruby."
|
13
|
+
spec.homepage = "https://github.com/souk4711/rongcloud-server-sdk-ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.7.0"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/souk4711/rongcloud-server-sdk-ruby"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/souk4711/rongcloud-server-sdk-ruby"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
# Uncomment to register a new dependency of your gem
|
33
|
+
spec.add_dependency "http", "~> 5.0"
|
34
|
+
|
35
|
+
# For more information and examples about making a new gem, check out our
|
36
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
37
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rongcloud-server-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Doe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -32,9 +32,9 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- ".editorconfig"
|
35
|
+
- ".env.defaults"
|
35
36
|
- ".overcommit.yml"
|
36
37
|
- ".rspec"
|
37
|
-
- ".rubocop"
|
38
38
|
- ".rubocop.yml"
|
39
39
|
- ".ruby-version"
|
40
40
|
- ".yardopts"
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/rongcloud/http.rb
|
63
63
|
- lib/rongcloud/signer.rb
|
64
64
|
- lib/rongcloud/version.rb
|
65
|
+
- rongcloud-server-sdk.gemspec
|
65
66
|
homepage: https://github.com/souk4711/rongcloud-server-sdk-ruby
|
66
67
|
licenses:
|
67
68
|
- MIT
|
data/.rubocop
DELETED
File without changes
|