rongcloud-server-sdk 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcb4e6f2555e86fcf2ca28b4bfdf8f2607dcf76dbcaf8f7ef0c96a60abf75954
4
- data.tar.gz: 3cf79649378bad6ffd15700496f5c7ea56837a94546c3927a6c74fdbf31aa419
3
+ metadata.gz: '0898c0d2461a0ecc981eba721cc87642bb26100b9a5af85f0a157d96cdcf9b41'
4
+ data.tar.gz: 1245cc5bf1ffeefad59cb70076a5ebcbc12726bdecb0cf9e63788155dbfa8a4b
5
5
  SHA512:
6
- metadata.gz: f960322de7803e1a16ab378937185ad0e6c775833aeeaaf34e81036b7ab4d6a9b3ddba91b1a6b2a6ffc94303e60201efa15b403405fc8adabaae66c25e414f94
7
- data.tar.gz: 00ec6b5d2256a59bd2552f83edf88bd39a6fcf72121326f4218c4ba770df22f1f9a6630d257f87859a87a0da1c4bc1a63932d8bef019d05fc0e9388decb7cc57
6
+ metadata.gz: ada95eaf38153ee31309295c2fce303efd8236ba2d3f04599541a0bad90deb7eb8fb32dab8daf1c7a85b676ec69086d954c1dc5fa1f9197dcf55ef9985135622
7
+ data.tar.gz: 34ee47d12ead0fd583f655a2f1a5b341745e3c9eb92f637e9e34a79b83743cbacf6673c1f7dcc1a83c08289e10ca1ff4597440fa62b4b9c9cfe77e9f515e515c
data/.env.defaults ADDED
@@ -0,0 +1,2 @@
1
+ RONGCLOUD_APP_KEY=""
2
+ RONGCLOUD_APP_SECRET=""
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rongcloud-server-sdk (1.0.2)
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.15.5)
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.0)
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
@@ -60,6 +60,19 @@ rongcloud = RongCloud::Client.new(
60
60
  timeout_options: {global_timeout: 5}
61
61
  }
62
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
+ })
63
76
  ```
64
77
 
65
78
  ### Logging
@@ -77,6 +90,34 @@ rongcloud = RongCloud::Client.new(
77
90
  )
78
91
  ```
79
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
+
80
121
  ### Signature Verify
81
122
 
82
123
  ```ruby
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
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module RongCloud
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.0"
3
3
  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.2
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: 2022-10-13 00:00:00.000000000 Z
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"
data/.rubocop DELETED
File without changes