synowebapi 0.0.3 → 0.0.4

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
- SHA1:
3
- metadata.gz: 7efe5d4e3a2c8b80405384c4cb31722b92cdaddf
4
- data.tar.gz: 50f66ce05dea62b4ac91b220d82796868955cc5e
2
+ SHA256:
3
+ metadata.gz: cd7b2c36dcab9883e6f5f5487f7d25393a3a230d4e0d5fd1d75e7c6ffd2709e3
4
+ data.tar.gz: 52b1b96765944fde24b2aa6c3ebcbbb2fd6528297879f8b57f6339b02e1d52af
5
5
  SHA512:
6
- metadata.gz: ac3b3e5a6c62ebf565e54ab38424595d089ede27a483740668bffae0f366393cdb0230ae24c0f256ab740b31de9b59aff3e30844fe71c287cf157f95f611da4f
7
- data.tar.gz: e85f6bd610ee53644febb44c473c7ea0fdd0cd7d97110530674c60d7247b8592b255cf877f2e2c2b7ca354ca474c66a53ba2c64576321afe194b895821f16765
6
+ metadata.gz: 139fde7fc431783e0f3aa22864811f5039eeac85db8e08ef0dbd5cab123f4755e66694885bb3f7af81e2ce05ed8019e92e9c5f94214d32c32dd6439366f9f370
7
+ data.tar.gz: 94a8472a89085e32e507c463c7af3523fc0954581e95024e824f01e513f63cf99108c68db8cf9f01b6c398f8cd8384a2b50ab1a915708c4adf35ece06d8feacb
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ synowebapi (0.0.3)
5
+ faraday (~> 0)
6
+ faraday_middleware (~> 0)
7
+ httpclient
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ faraday (0.17.6)
13
+ multipart-post (>= 1.2, < 3)
14
+ faraday_middleware (0.14.0)
15
+ faraday (>= 0.7.4, < 1.0)
16
+ httpclient (2.8.3)
17
+ multipart-post (2.4.0)
18
+
19
+ PLATFORMS
20
+ x86_64-linux
21
+
22
+ DEPENDENCIES
23
+ synowebapi!
24
+
25
+ BUNDLED WITH
26
+ 2.3.5
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+
2
+ http://cccheng.mit-license.org/
3
+
4
+ Copyright © 2015 Chung-Chiang Cheng <shepjeng@gmail.com>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+
data/README.md CHANGED
@@ -29,35 +29,16 @@ resp['disks'].each do |disk|
29
29
  puts "%-8s %-10s %-25s %-20s" % [disk['name'], disk['vendor'], disk['model'], disk['serial']]
30
30
  end
31
31
 
32
+ # Download file from shared folder 'public'
33
+ # https://global.download.synology.com/download/Document/DeveloperGuide/Synology_File_Station_API_Guide.pdf
34
+ client['SYNO.FileStation.Download'].download('/any/test.jpg', {method: 'download', version: 2, path: '/public/file', mode: 'open'})
35
+
32
36
  client.disconnect
33
37
  ```
34
38
 
35
39
  ## Requirements
36
40
 
41
+ * httpclient
37
42
  * faraday
38
43
  * faraday-middleware
39
44
 
40
- ## License
41
-
42
- http://cccheng.mit-license.org/
43
-
44
- Copyright © 2015 Chung-Chiang Cheng <shepjeng@gmail.com>
45
-
46
- Permission is hereby granted, free of charge, to any person obtaining a copy
47
- of this software and associated documentation files (the "Software"), to deal
48
- in the Software without restriction, including without limitation the rights
49
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
50
- copies of the Software, and to permit persons to whom the Software is
51
- furnished to do so, subject to the following conditions:
52
-
53
- The above copyright notice and this permission notice shall be included in
54
- all copies or substantial portions of the Software.
55
-
56
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
57
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
58
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
59
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
60
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
61
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
62
- THE SOFTWARE.
63
-
@@ -15,6 +15,20 @@ module SYNOWebAPI
15
15
  @request_format = params['requestFormat']
16
16
  end
17
17
 
18
+ def download(output_path, params, options = {})
19
+ @client.download(self, output_path, params, options)
20
+ end
21
+
22
+ def post(params)
23
+ resp = @client.post(self, params)
24
+
25
+ if resp['success']
26
+ resp['data']
27
+ else
28
+ error_handling(resp['error'])
29
+ end
30
+ end
31
+
18
32
  def request(params)
19
33
  resp = @client.send(self, params)
20
34
 
@@ -32,6 +32,37 @@ module SYNOWebAPI
32
32
  self['SYNO.API.Auth'].logout(:session => @session_id)
33
33
  end
34
34
 
35
+ def download(api, output_path, params = {}, options = {})
36
+ require 'httpclient'
37
+ http_client = HTTPClient.new
38
+ if options[:receive_timeout]
39
+ http_client.receive_timeout = options[:receive_timeout]
40
+ end
41
+ open(output_path, 'wb') do |file|
42
+ http_client.get_content(
43
+ URI.parse(URI.encode("#{@url}/webapi/#{api.path}")),
44
+ {
45
+ :api => api.api_name,
46
+ :version => api.max_version,
47
+ :_sid => @session_id,
48
+ }.merge(params)
49
+ ) do |chunk|
50
+ file.write chunk
51
+ end
52
+ end
53
+ end
54
+
55
+ def post(api, params = {})
56
+ @conn.post("/webapi/#{api.path}", {
57
+ :api => api.api_name,
58
+ :version => api.max_version,
59
+ :_sid => @session_id,
60
+ }.merge(params)).body
61
+
62
+ rescue Faraday::ParsingError
63
+ raise StandardError.new("Failed to parse response")
64
+ end
65
+
35
66
  def send(api, params = {})
36
67
  @conn.get("/webapi/#{api.path}", {
37
68
  :api => api.api_name,
@@ -68,4 +99,3 @@ module SYNOWebAPI
68
99
 
69
100
  end
70
101
  end
71
-
@@ -1,5 +1,5 @@
1
1
 
2
2
  module SYNOWebAPI
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
 
data/synowebapi.gemspec CHANGED
@@ -9,12 +9,13 @@ Gem::Specification.new do |s|
9
9
  s.email = ['shepjeng@gmail.com', 'cccheng@synology.com']
10
10
  s.summary = 'Ruby gem for Synology Web API'
11
11
  s.description = s.summary
12
- s.homepage = 'http://github.com/shepjeng/ruby-synowebapi'
12
+ s.homepage = 'https://github.com/Synology/ruby-synowebapi'
13
13
  s.license = 'MIT'
14
14
 
15
15
  s.files = %x[git ls-files].split($/).sort
16
16
  s.require_paths = ['lib']
17
17
 
18
- s.add_dependency 'faraday', '~> 0'
19
- s.add_dependency 'faraday_middleware', '~> 0'
18
+ s.add_dependency 'httpclient'
19
+ s.add_dependency 'faraday'
20
+ s.add_dependency 'faraday_middleware'
20
21
  end
metadata CHANGED
@@ -1,41 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synowebapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chung-Chiang Cheng
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-20 00:00:00.000000000 Z
11
+ date: 2024-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httpclient
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: faraday
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - "~>"
31
+ - - ">="
18
32
  - !ruby/object:Gem::Version
19
33
  version: '0'
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - "~>"
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: faraday_middleware
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  description: Ruby gem for Synology Web API
@@ -47,6 +61,8 @@ extensions: []
47
61
  extra_rdoc_files: []
48
62
  files:
49
63
  - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE
50
66
  - README.md
51
67
  - lib/synowebapi.rb
52
68
  - lib/synowebapi/api.rb
@@ -54,7 +70,7 @@ files:
54
70
  - lib/synowebapi/error.rb
55
71
  - lib/synowebapi/version.rb
56
72
  - synowebapi.gemspec
57
- homepage: http://github.com/shepjeng/ruby-synowebapi
73
+ homepage: https://github.com/Synology/ruby-synowebapi
58
74
  licenses:
59
75
  - MIT
60
76
  metadata: {}
@@ -73,8 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
89
  - !ruby/object:Gem::Version
74
90
  version: '0'
75
91
  requirements: []
76
- rubyforge_project:
77
- rubygems_version: 2.6.14
92
+ rubygems_version: 3.3.5
78
93
  signing_key:
79
94
  specification_version: 4
80
95
  summary: Ruby gem for Synology Web API