kloudless 0.2.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -3
- data/README.md +1 -1
- data/lib/kloudless.rb +1 -2
- data/lib/kloudless/collection.rb +4 -0
- data/lib/kloudless/file.rb +11 -11
- data/lib/kloudless/folder.rb +6 -6
- data/lib/kloudless/link.rb +5 -5
- data/lib/kloudless/model.rb +1 -1
- data/lib/kloudless/multipart_upload.rb +5 -5
- data/lib/kloudless/version.rb +1 -1
- data/test/kloudless/file_test.rb +10 -10
- data/test/kloudless/folder_test.rb +6 -6
- data/test/kloudless/http_test.rb +3 -3
- data/test/kloudless/link_test.rb +5 -5
- data/test/kloudless/multipart_upload_test.rb +5 -5
- metadata +2 -5
- data/lib/kloudless/team.rb +0 -9
- data/test/kloudless/team_test.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 109e660b95c9f88306552b57c0d3509699eb0a95
|
4
|
+
data.tar.gz: 049eeb392d32e6c2813a4c7099a9c595f3971cbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48e8d7383331578e2712d4f02f7476512d52530d73b376760cb67086748e08169dba64a10d9303b3710bc548c82b420965d7748978b464dc0bb5345813ed1101
|
7
|
+
data.tar.gz: d67815cb4fdf9d37c4a8efc272e6dde4aee9c47292e3321c630c8b6b6e65ca3c565547797dce6a33763cb99d266014704caf5fce0ba0f61d4dee798ad58716f8
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,19 @@
|
|
1
|
-
#
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## 1.0.0
|
4
|
+
|
5
|
+
- The API version has been updated to `v1`. This introduces backwards
|
6
|
+
incompatible changes. Please review the
|
7
|
+
[migration guide](https://developers.kloudless.com/docs/v1/migration)
|
8
|
+
for more information on migrating from `v0` to `v1`.
|
9
|
+
- Deprecated Team endpoint removed till newer Team endpoints are introduced
|
10
|
+
in this SDK.
|
11
|
+
|
12
|
+
## 0.2.1
|
2
13
|
|
3
14
|
- Convert ID endpoint for file/folders. Listed under files. @kuinak
|
4
15
|
|
5
|
-
|
16
|
+
## 0.2.0
|
6
17
|
|
7
18
|
- Query parameters for POST/PUT/PATCH requests.
|
8
19
|
- Bearer Tokens instead of Account Keys.
|
@@ -10,6 +21,6 @@
|
|
10
21
|
- Fixed gemspec warnings
|
11
22
|
- Fixed gemspec homepage. @tyrust
|
12
23
|
|
13
|
-
|
24
|
+
## 0.1.0
|
14
25
|
|
15
26
|
Initial release
|
data/README.md
CHANGED
@@ -46,7 +46,7 @@ v major.minor.patch
|
|
46
46
|
```
|
47
47
|
|
48
48
|
The major version tracks the version of the Kloudless API. For example, all
|
49
|
-
versions that start with `
|
49
|
+
versions that start with `v1.x.y` are compatible with Kloudless API `v1`.
|
50
50
|
|
51
51
|
## Release
|
52
52
|
|
data/lib/kloudless.rb
CHANGED
@@ -3,7 +3,6 @@ require_relative "kloudless/error"
|
|
3
3
|
require_relative "kloudless/http"
|
4
4
|
require_relative "kloudless/model"
|
5
5
|
require_relative "kloudless/account"
|
6
|
-
require_relative "kloudless/team"
|
7
6
|
require_relative "kloudless/file"
|
8
7
|
require_relative "kloudless/multipart_upload"
|
9
8
|
require_relative "kloudless/folder"
|
@@ -14,7 +13,7 @@ require "json"
|
|
14
13
|
require "uri"
|
15
14
|
|
16
15
|
module Kloudless
|
17
|
-
API_VERSION = "
|
16
|
+
API_VERSION = "v1".freeze
|
18
17
|
API_URL = "https://api.kloudless.com/#{API_VERSION}".freeze
|
19
18
|
|
20
19
|
# Public: Authorize with API Key or Bearer Token. Returns nothing.
|
data/lib/kloudless/collection.rb
CHANGED
data/lib/kloudless/file.rb
CHANGED
@@ -8,60 +8,60 @@ module Kloudless
|
|
8
8
|
'X-Kloudless-Metadata' => {parent_id: parent_id, name: file_name}.to_json,
|
9
9
|
'Content-Type' => 'application/octet-stream'
|
10
10
|
}
|
11
|
-
path = "/accounts/#{account_id}/files"
|
11
|
+
path = "/accounts/#{account_id}/storage/files"
|
12
12
|
new(http.post(path, params: params, data: data, headers: headers,
|
13
13
|
parse_request: false))
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.upload_from_url(account_id:, params: {}, **data)
|
17
|
-
path = "/accounts/#{account_id}/files"
|
17
|
+
path = "/accounts/#{account_id}/storage/files"
|
18
18
|
new(http.post(path, params: params, data: data))
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.metadata(account_id:, file_id:, **params)
|
22
|
-
path = "/accounts/#{account_id}/files/#{file_id}"
|
22
|
+
path = "/accounts/#{account_id}/storage/files/#{file_id}"
|
23
23
|
new(http.get(path, params: params))
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.rename(account_id:, file_id:, params: {}, **data)
|
27
|
-
path = "/accounts/#{account_id}/files/#{file_id}"
|
27
|
+
path = "/accounts/#{account_id}/storage/files/#{file_id}"
|
28
28
|
new(http.patch(path, params: params, data: data))
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.update(account_id:, file_id:, data:)
|
32
|
-
path = "/accounts/#{account_id}/files/#{file_id}"
|
32
|
+
path = "/accounts/#{account_id}/storage/files/#{file_id}"
|
33
33
|
new(http.put(path, data: data, parse_request: false,
|
34
34
|
headers: {'Content-Type' => 'application/octet-stream'}))
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.download(account_id:, file_id:, **params)
|
38
|
-
path = "/accounts/#{account_id}/files/#{file_id}/contents"
|
38
|
+
path = "/accounts/#{account_id}/storage/files/#{file_id}/contents"
|
39
39
|
http.get(path, params: params, parse_response: false)
|
40
40
|
end
|
41
41
|
|
42
42
|
def self.copy(account_id:, file_id:, parent_id:, params: {}, **data)
|
43
|
-
path = "/accounts/#{account_id}/files/#{file_id}/copy"
|
43
|
+
path = "/accounts/#{account_id}/storage/files/#{file_id}/copy"
|
44
44
|
data[:parent_id] = parent_id
|
45
45
|
new(http.post(path, params: params, data: data))
|
46
46
|
end
|
47
47
|
|
48
48
|
def self.delete(account_id:, file_id:, **params)
|
49
|
-
path = "/accounts/#{account_id}/files/#{file_id}"
|
49
|
+
path = "/accounts/#{account_id}/storage/files/#{file_id}"
|
50
50
|
new(http.delete(path, params: params))
|
51
51
|
end
|
52
52
|
|
53
53
|
def self.recent(account_ids:, **params)
|
54
|
-
path = "/accounts/#{account_ids.join(',')}/recent"
|
54
|
+
path = "/accounts/#{account_ids.join(',')}/storage/recent"
|
55
55
|
Kloudless::Collection.new(self, http.get(path, params: params))
|
56
56
|
end
|
57
57
|
|
58
58
|
def self.search(account_ids:, **params)
|
59
|
-
path = "/accounts/#{account_ids.join(',')}/search"
|
59
|
+
path = "/accounts/#{account_ids.join(',')}/storage/search"
|
60
60
|
Kloudless::Collection.new(self, http.get(path, params: params))
|
61
61
|
end
|
62
62
|
|
63
63
|
def self.convert_id(account_id:, raw_id:, type:, params: {}, **data)
|
64
|
-
path = "/accounts/#{account_id}/convert_id"
|
64
|
+
path = "/accounts/#{account_id}/storage/convert_id"
|
65
65
|
data[:raw_id] = raw_id
|
66
66
|
data[:type] = type
|
67
67
|
http.post(path, params: params, data: data)
|
data/lib/kloudless/folder.rb
CHANGED
@@ -3,38 +3,38 @@ module Kloudless
|
|
3
3
|
class Folder < Model
|
4
4
|
# https://developers.kloudless.com/docs#folders-create-a-folder
|
5
5
|
def self.create(account_id:, params: {}, **data)
|
6
|
-
path = "/accounts/#{account_id}/folders"
|
6
|
+
path = "/accounts/#{account_id}/storage/folders"
|
7
7
|
new(http.post(path, params: params, data: data))
|
8
8
|
end
|
9
9
|
|
10
10
|
# https://developers.kloudless.com/docs#folders-retrieve-folder-metadata
|
11
11
|
def self.metadata(account_id:, folder_id:, **params)
|
12
|
-
path = "/accounts/#{account_id}/folders/#{folder_id}"
|
12
|
+
path = "/accounts/#{account_id}/storage/folders/#{folder_id}"
|
13
13
|
new(http.get(path, params: params))
|
14
14
|
end
|
15
15
|
|
16
16
|
# https://developers.kloudless.com/docs#folders-retrieve-folder-contents
|
17
17
|
def self.retrieve(account_id:, folder_id:, **params)
|
18
|
-
path = "/accounts/#{account_id}/folders/#{folder_id}/contents"
|
18
|
+
path = "/accounts/#{account_id}/storage/folders/#{folder_id}/contents"
|
19
19
|
Kloudless::Collection.new(self, http.get(path, params: params))
|
20
20
|
end
|
21
21
|
|
22
22
|
# https://developers.kloudless.com/docs#folders-rename/move-a-folder
|
23
23
|
def self.rename(account_id:, folder_id:, params: {}, **data)
|
24
|
-
path = "/accounts/#{account_id}/folders/#{folder_id}"
|
24
|
+
path = "/accounts/#{account_id}/storage/folders/#{folder_id}"
|
25
25
|
new(http.patch(path, params: params, data: data))
|
26
26
|
end
|
27
27
|
|
28
28
|
# https://developers.kloudless.com/docs#folders-copy-a-folder
|
29
29
|
def self.copy(account_id:, folder_id:, parent_id:, params: {}, **data)
|
30
|
-
path = "/accounts/#{account_id}/folders/#{folder_id}/copy"
|
30
|
+
path = "/accounts/#{account_id}/storage/folders/#{folder_id}/copy"
|
31
31
|
data[:parent_id] = parent_id
|
32
32
|
new(http.post(path, params: params, data: data))
|
33
33
|
end
|
34
34
|
|
35
35
|
# https://developers.kloudless.com/docs#folders-delete-a-folder
|
36
36
|
def self.delete(account_id:, folder_id:, **params)
|
37
|
-
path = "/accounts/#{account_id}/folders/#{folder_id}"
|
37
|
+
path = "/accounts/#{account_id}/storage/folders/#{folder_id}"
|
38
38
|
new(http.delete(path, params: params))
|
39
39
|
end
|
40
40
|
end
|
data/lib/kloudless/link.rb
CHANGED
@@ -2,32 +2,32 @@ module Kloudless
|
|
2
2
|
# https://developers.kloudless.com/docs#links
|
3
3
|
class Link < Model
|
4
4
|
def self.list(account_ids:, **params)
|
5
|
-
path = "/accounts/#{account_ids.join(',')}/links"
|
5
|
+
path = "/accounts/#{account_ids.join(',')}/storage/links"
|
6
6
|
Kloudless::Collection.new(self, http.get(path, params: params))
|
7
7
|
end
|
8
8
|
|
9
9
|
# https://developers.kloudless.com/docs#links-create-a-link
|
10
10
|
def self.create(account_id:, file_id:, params: {}, **data)
|
11
11
|
data[:file_id] = file_id
|
12
|
-
path = "/accounts/#{account_id}/links"
|
12
|
+
path = "/accounts/#{account_id}/storage/links"
|
13
13
|
new(http.post(path, params: params, data: data))
|
14
14
|
end
|
15
15
|
|
16
16
|
# https://developers.kloudless.com/docs#links-retrieve-a-link
|
17
17
|
def self.retrieve(account_id:, link_id:, **params)
|
18
|
-
path = "/accounts/#{account_id}/links/#{link_id}"
|
18
|
+
path = "/accounts/#{account_id}/storage/links/#{link_id}"
|
19
19
|
new(http.get(path, params: params))
|
20
20
|
end
|
21
21
|
|
22
22
|
# https://developers.kloudless.com/docs#links-update-a-link
|
23
23
|
def self.update(account_id:, link_id:, params: {}, **data)
|
24
|
-
path = "/accounts/#{account_id}/links/#{link_id}"
|
24
|
+
path = "/accounts/#{account_id}/storage/links/#{link_id}"
|
25
25
|
new(http.patch(path, params: params, data: data))
|
26
26
|
end
|
27
27
|
|
28
28
|
# https://developers.kloudless.com/docs#links-delete-a-link
|
29
29
|
def self.delete(account_id:, link_id:, **params)
|
30
|
-
path = "/accounts/#{account_id}/links/#{link_id}"
|
30
|
+
path = "/accounts/#{account_id}/storage/links/#{link_id}"
|
31
31
|
new(http.delete(path, params: params))
|
32
32
|
end
|
33
33
|
end
|
data/lib/kloudless/model.rb
CHANGED
@@ -2,18 +2,18 @@ module Kloudless
|
|
2
2
|
# https://developers.kloudless.com/docs#multipart-upload
|
3
3
|
class MultipartUpload < Model
|
4
4
|
def self.init(account_id:, params: {}, **data)
|
5
|
-
path = "/accounts/#{account_id}/multipart"
|
5
|
+
path = "/accounts/#{account_id}/storage/multipart"
|
6
6
|
new(http.post(path, params: params, data: data))
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.retrieve(account_id:, multipart_id:)
|
10
|
-
path = "/accounts/#{account_id}/multipart/#{multipart_id}"
|
10
|
+
path = "/accounts/#{account_id}/storage/multipart/#{multipart_id}"
|
11
11
|
new(http.get(path))
|
12
12
|
end
|
13
13
|
|
14
14
|
# https://developers.kloudless.com/docs#multipart-upload-upload-part
|
15
15
|
def self.upload(account_id:, multipart_id:, data:, part_number:, **params)
|
16
|
-
path = "/accounts/#{account_id}/multipart/#{multipart_id}"
|
16
|
+
path = "/accounts/#{account_id}/storage/multipart/#{multipart_id}"
|
17
17
|
params[:part_number] = part_number
|
18
18
|
headers = {'Content-Type' => 'application/octet-stream'}
|
19
19
|
new(http.put(path, params: params, data: data, headers: headers,
|
@@ -22,13 +22,13 @@ module Kloudless
|
|
22
22
|
|
23
23
|
# https://developers.kloudless.com/docs#multipart-upload-finalize-multipart-session
|
24
24
|
def self.finalize(account_id:, multipart_id:, params: {}, **data)
|
25
|
-
path = "/accounts/#{account_id}/multipart/#{multipart_id}/complete"
|
25
|
+
path = "/accounts/#{account_id}/storage/multipart/#{multipart_id}/complete"
|
26
26
|
new(http.post(path, params: params, data: data))
|
27
27
|
end
|
28
28
|
|
29
29
|
# https://developers.kloudless.com/docs#multipart-upload-abort-multipart-session
|
30
30
|
def self.abort(account_id:, multipart_id:, **params)
|
31
|
-
path = "/accounts/#{account_id}/multipart/#{multipart_id}"
|
31
|
+
path = "/accounts/#{account_id}/storage/multipart/#{multipart_id}"
|
32
32
|
new(http.delete(path, params: params))
|
33
33
|
end
|
34
34
|
|
data/lib/kloudless/version.rb
CHANGED
data/test/kloudless/file_test.rb
CHANGED
@@ -4,7 +4,7 @@ class Kloudless::FileTest < Minitest::Test
|
|
4
4
|
def test_upload_file
|
5
5
|
metadata = {parent_id: "parent", name: "foo.txt"}
|
6
6
|
Kloudless.http.expect(:post, returns: {"id" => "foo"}, args: [
|
7
|
-
"/accounts/1/files", data: "FILE CONTENTS",
|
7
|
+
"/accounts/1/storage/files", data: "FILE CONTENTS",
|
8
8
|
headers: {'X-Kloudless-Metadata' => metadata.to_json,
|
9
9
|
"Content-Type" => 'application/octet-stream'},
|
10
10
|
params: {}, parse_request: false]) do
|
@@ -16,14 +16,14 @@ class Kloudless::FileTest < Minitest::Test
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_retrieve_file_metadata
|
19
|
-
Kloudless.http.expect(:get, returns: {"id" => "foo"}, args:["/accounts/1/files/2", params: {}]) do
|
19
|
+
Kloudless.http.expect(:get, returns: {"id" => "foo"}, args:["/accounts/1/storage/files/2", params: {}]) do
|
20
20
|
metadata = Kloudless::File.metadata(account_id: 1, file_id: 2)
|
21
21
|
assert_kind_of Kloudless::File, metadata # TODO: not really a type
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_rename_file
|
26
|
-
Kloudless.http.expect(:patch, returns: {"id" => "foo"}, args:["/accounts/1/files/2", params: {}, data: {name: "new-name.txt"}]) do
|
26
|
+
Kloudless.http.expect(:patch, returns: {"id" => "foo"}, args:["/accounts/1/storage/files/2", params: {}, data: {name: "new-name.txt"}]) do
|
27
27
|
file = Kloudless::File.rename(account_id: 1, file_id: 2, name: "new-name.txt")
|
28
28
|
assert_kind_of Kloudless::File, file
|
29
29
|
end
|
@@ -31,7 +31,7 @@ class Kloudless::FileTest < Minitest::Test
|
|
31
31
|
|
32
32
|
def test_update
|
33
33
|
Kloudless.http.expect(:put, returns: {"id" => "foo"}, args: [
|
34
|
-
"/accounts/1/files/2", data: "FILE CONTENTS", parse_request: false,
|
34
|
+
"/accounts/1/storage/files/2", data: "FILE CONTENTS", parse_request: false,
|
35
35
|
headers: {'Content-Type' => 'application/octet-stream'}]) do
|
36
36
|
file = Kloudless::File.update(account_id: 1, file_id: 2, data: "FILE CONTENTS")
|
37
37
|
assert_kind_of Kloudless::File, file
|
@@ -39,21 +39,21 @@ class Kloudless::FileTest < Minitest::Test
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_download
|
42
|
-
Kloudless.http.expect(:get, returns: "FILE CONTENTS", args:["/accounts/1/files/2/contents", params: {}, parse_response: false]) do
|
42
|
+
Kloudless.http.expect(:get, returns: "FILE CONTENTS", args:["/accounts/1/storage/files/2/contents", params: {}, parse_response: false]) do
|
43
43
|
contents = Kloudless::File.download(account_id: 1, file_id: 2)
|
44
44
|
assert_equal "FILE CONTENTS", contents
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_copy
|
49
|
-
Kloudless.http.expect(:post, returns: {"id" => "foo"}, args:["/accounts/1/files/2/copy", params: {}, data: {parent_id: "parent-id"}]) do
|
49
|
+
Kloudless.http.expect(:post, returns: {"id" => "foo"}, args:["/accounts/1/storage/files/2/copy", params: {}, data: {parent_id: "parent-id"}]) do
|
50
50
|
file = Kloudless::File.copy(account_id: 1, file_id: 2, parent_id: "parent-id")
|
51
51
|
assert_kind_of Kloudless::File, file
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_delete
|
56
|
-
Kloudless.http.expect(:delete, returns: {"id" => "foo"}, args:["/accounts/1/files/2", params: {permanent: true}]) do
|
56
|
+
Kloudless.http.expect(:delete, returns: {"id" => "foo"}, args:["/accounts/1/storage/files/2", params: {permanent: true}]) do
|
57
57
|
file = Kloudless::File.delete(account_id: 1, file_id: 2, permanent: true)
|
58
58
|
assert_kind_of Kloudless::File, file
|
59
59
|
end
|
@@ -61,7 +61,7 @@ class Kloudless::FileTest < Minitest::Test
|
|
61
61
|
|
62
62
|
def test_recent
|
63
63
|
response = {"objects" => [{"id" => "foo"}]}
|
64
|
-
Kloudless.http.expect(:get, returns: response, args:["/accounts/1,2/recent", params: {}]) do
|
64
|
+
Kloudless.http.expect(:get, returns: response, args:["/accounts/1,2/storage/recent", params: {}]) do
|
65
65
|
files = Kloudless::File.recent(account_ids: [1,2])
|
66
66
|
assert_kind_of Kloudless::Collection, files
|
67
67
|
assert_kind_of Kloudless::File, files.first
|
@@ -70,7 +70,7 @@ class Kloudless::FileTest < Minitest::Test
|
|
70
70
|
|
71
71
|
def test_search
|
72
72
|
response = {"objects" => [{"id" => "foo"}]}
|
73
|
-
Kloudless.http.expect(:get, returns: response, args:["/accounts/1,2/search", params: {dropbox: "foo"}]) do
|
73
|
+
Kloudless.http.expect(:get, returns: response, args:["/accounts/1,2/storage/search", params: {dropbox: "foo"}]) do
|
74
74
|
files = Kloudless::File.search(account_ids: [1,2], dropbox: "foo")
|
75
75
|
assert_kind_of Kloudless::Collection, files
|
76
76
|
assert_kind_of Kloudless::File, files.first
|
@@ -80,7 +80,7 @@ class Kloudless::FileTest < Minitest::Test
|
|
80
80
|
def test_convert_id
|
81
81
|
response = {"id" => "foo"}
|
82
82
|
data = {raw_id: "bar", type: "file"}
|
83
|
-
Kloudless.http.expect(:post, returns: response, args:["/accounts/1/convert_id", params: {}, data: data ]) do
|
83
|
+
Kloudless.http.expect(:post, returns: response, args:["/accounts/1/storage/convert_id", params: {}, data: data ]) do
|
84
84
|
new_id_data = Kloudless::File.convert_id(account_id: 1, raw_id: data[:raw_id], type: data[:type])
|
85
85
|
assert_equal "foo", new_id_data["id"]
|
86
86
|
end
|
@@ -2,14 +2,14 @@ require_relative "../test_helper"
|
|
2
2
|
|
3
3
|
class Kloudless::FolderTest < Minitest::Test
|
4
4
|
def test_create
|
5
|
-
Kloudless.http.expect(:post, args: ["/accounts/1/folders", params: {}, data: {name: "foo"}]) do
|
5
|
+
Kloudless.http.expect(:post, args: ["/accounts/1/storage/folders", params: {}, data: {name: "foo"}]) do
|
6
6
|
folder = Kloudless::Folder.create(account_id: 1, name: "foo")
|
7
7
|
assert_kind_of Kloudless::Folder, folder
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_metadata
|
12
|
-
Kloudless.http.expect(:get, args: ["/accounts/1/folders/2", params: {}]) do
|
12
|
+
Kloudless.http.expect(:get, args: ["/accounts/1/storage/folders/2", params: {}]) do
|
13
13
|
folder = Kloudless::Folder.metadata(account_id: 1, folder_id: 2)
|
14
14
|
assert_kind_of Kloudless::Folder, folder
|
15
15
|
end
|
@@ -17,7 +17,7 @@ class Kloudless::FolderTest < Minitest::Test
|
|
17
17
|
|
18
18
|
def test_retrieve
|
19
19
|
response = {"objects" => [{"id" => "1"}]}
|
20
|
-
Kloudless.http.expect(:get, returns: response, args: ["/accounts/1/folders/2/contents", params: {page_number: 1, page_size: 1}]) do
|
20
|
+
Kloudless.http.expect(:get, returns: response, args: ["/accounts/1/storage/folders/2/contents", params: {page_number: 1, page_size: 1}]) do
|
21
21
|
folders = Kloudless::Folder.retrieve(account_id: 1, folder_id: 2, page_number: 1, page_size: 1)
|
22
22
|
assert_kind_of Kloudless::Collection, folders
|
23
23
|
assert_kind_of Kloudless::Folder, folders.first
|
@@ -25,21 +25,21 @@ class Kloudless::FolderTest < Minitest::Test
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_rename
|
28
|
-
Kloudless.http.expect(:patch, args: ["/accounts/1/folders/2", params: {}, data: {name: "foo.md"}]) do
|
28
|
+
Kloudless.http.expect(:patch, args: ["/accounts/1/storage/folders/2", params: {}, data: {name: "foo.md"}]) do
|
29
29
|
folder = Kloudless::Folder.rename(account_id: 1, folder_id: 2, name: "foo.md")
|
30
30
|
assert_kind_of Kloudless::Folder, folder
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_copy
|
35
|
-
Kloudless.http.expect(:post, args: ["/accounts/1/folders/2/copy", params: {}, data: {parent_id: "parent-id"}]) do
|
35
|
+
Kloudless.http.expect(:post, args: ["/accounts/1/storage/folders/2/copy", params: {}, data: {parent_id: "parent-id"}]) do
|
36
36
|
folder = Kloudless::Folder.copy(account_id: 1, folder_id: 2, parent_id: "parent-id")
|
37
37
|
assert_kind_of Kloudless::Folder, folder
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_delete
|
42
|
-
Kloudless.http.expect(:delete, args: ["/accounts/1/folders/2", params: {recursive: true, permanent: true}]) do
|
42
|
+
Kloudless.http.expect(:delete, args: ["/accounts/1/storage/folders/2", params: {recursive: true, permanent: true}]) do
|
43
43
|
folder = Kloudless::Folder.delete(account_id: 1, folder_id: 2, recursive: true, permanent: true)
|
44
44
|
assert_kind_of Kloudless::Folder, folder
|
45
45
|
end
|
data/test/kloudless/http_test.rb
CHANGED
@@ -13,7 +13,7 @@ class Kloudless::HTTPTest < Minitest::Test
|
|
13
13
|
http.mock_response(Struct.new(:body).new('{"foo": "bar"}')) do
|
14
14
|
json = http.get("/foo")
|
15
15
|
|
16
|
-
assert_equal URI.parse("https://api.kloudless.com/
|
16
|
+
assert_equal URI.parse("https://api.kloudless.com/v1/foo"), last_request.uri
|
17
17
|
assert_kind_of Net::HTTP::Get, last_request
|
18
18
|
|
19
19
|
expected = {"foo" => "bar"}
|
@@ -25,7 +25,7 @@ class Kloudless::HTTPTest < Minitest::Test
|
|
25
25
|
http.mock_response(Struct.new(:body).new('{}')) do
|
26
26
|
json = http.delete("/foo/1")
|
27
27
|
|
28
|
-
assert_equal URI.parse("https://api.kloudless.com/
|
28
|
+
assert_equal URI.parse("https://api.kloudless.com/v1/foo/1"), last_request.uri
|
29
29
|
assert_kind_of Net::HTTP::Delete, last_request
|
30
30
|
end
|
31
31
|
end
|
@@ -33,7 +33,7 @@ class Kloudless::HTTPTest < Minitest::Test
|
|
33
33
|
def test_params
|
34
34
|
http.mock_response(Struct.new(:body).new('{"foo": "bar"}')) do
|
35
35
|
http.get("/foo", params: {page: 2})
|
36
|
-
assert_equal URI.parse("https://api.kloudless.com/
|
36
|
+
assert_equal URI.parse("https://api.kloudless.com/v1/foo?page=2"), last_request.uri
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
data/test/kloudless/link_test.rb
CHANGED
@@ -3,7 +3,7 @@ require_relative "../test_helper"
|
|
3
3
|
class Kloudless::LinkTest < Minitest::Test
|
4
4
|
def test_list_links
|
5
5
|
response = {"objects" => [{"id" => 1}]}
|
6
|
-
Kloudless.http.expect(:get, returns: response, args: ["/accounts/1,2/links", params: {active: false}]) do
|
6
|
+
Kloudless.http.expect(:get, returns: response, args: ["/accounts/1,2/storage/links", params: {active: false}]) do
|
7
7
|
links = Kloudless::Link.list(account_ids: [1,2], active: false)
|
8
8
|
assert_kind_of Kloudless::Collection, links
|
9
9
|
assert_kind_of Kloudless::Link, links.first
|
@@ -11,28 +11,28 @@ class Kloudless::LinkTest < Minitest::Test
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_create_link
|
14
|
-
Kloudless.http.expect(:post, args: ["/accounts/1/links", params: {}, data: {file_id: "file-id"}]) do
|
14
|
+
Kloudless.http.expect(:post, args: ["/accounts/1/storage/links", params: {}, data: {file_id: "file-id"}]) do
|
15
15
|
link = Kloudless::Link.create(account_id: 1, file_id: "file-id")
|
16
16
|
assert_kind_of Kloudless::Link, link
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_retrieve_link
|
21
|
-
Kloudless.http.expect(:get, args: ["/accounts/1/links/2", params: {active: true}]) do
|
21
|
+
Kloudless.http.expect(:get, args: ["/accounts/1/storage/links/2", params: {active: true}]) do
|
22
22
|
link = Kloudless::Link.retrieve(account_id: 1, link_id: 2, active: true)
|
23
23
|
assert_kind_of Kloudless::Link, link
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_update_link
|
28
|
-
Kloudless.http.expect(:patch, args: ["/accounts/1/links/2", params: {}, data: {password: "foo"}]) do
|
28
|
+
Kloudless.http.expect(:patch, args: ["/accounts/1/storage/links/2", params: {}, data: {password: "foo"}]) do
|
29
29
|
link = Kloudless::Link.update(account_id: 1, link_id: 2, password: "foo")
|
30
30
|
assert_kind_of Kloudless::Link, link
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_delete_link
|
35
|
-
Kloudless.http.expect(:delete, args: ["/accounts/1/links/2", params: {}]) do
|
35
|
+
Kloudless.http.expect(:delete, args: ["/accounts/1/storage/links/2", params: {}]) do
|
36
36
|
link = Kloudless::Link.delete(account_id: 1, link_id: 2)
|
37
37
|
assert_kind_of Kloudless::Link, link
|
38
38
|
end
|
@@ -3,21 +3,21 @@ require_relative "../test_helper"
|
|
3
3
|
class Kloudless::MultipartUploadTest < Minitest::Test
|
4
4
|
def test_init_multipart_upload
|
5
5
|
Kloudless.http.expect(:post, returns: {"id" => "foo"}, args:[
|
6
|
-
"/accounts/1/multipart", params: {overwrite: true}, data: {parent_id: "foo"}]) do
|
6
|
+
"/accounts/1/storage/multipart", params: {overwrite: true}, data: {parent_id: "foo"}]) do
|
7
7
|
upload = Kloudless::MultipartUpload.create(account_id: 1, params: {overwrite: true}, parent_id: "foo")
|
8
8
|
assert_kind_of Kloudless::MultipartUpload, upload
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_retrieve_multipart_upload
|
13
|
-
Kloudless.http.expect(:get, returns: {"id" => "foo"}, args:["/accounts/1/multipart/2"]) do
|
13
|
+
Kloudless.http.expect(:get, returns: {"id" => "foo"}, args:["/accounts/1/storage/multipart/2"]) do
|
14
14
|
upload = Kloudless::MultipartUpload.retrieve(account_id: 1, multipart_id: 2)
|
15
15
|
assert_kind_of Kloudless::MultipartUpload, upload
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_upload_multipart_upload
|
20
|
-
Kloudless.http.expect(:put, args: ["/accounts/1/multipart/2", data: "FILE CONTENTS",
|
20
|
+
Kloudless.http.expect(:put, args: ["/accounts/1/storage/multipart/2", data: "FILE CONTENTS",
|
21
21
|
headers: {'Content-Type' => 'application/octet-stream'},
|
22
22
|
params: {part_number: 1},
|
23
23
|
parse_request: false]) do
|
@@ -28,14 +28,14 @@ class Kloudless::MultipartUploadTest < Minitest::Test
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_finalize_multipart_upload
|
31
|
-
Kloudless.http.expect(:post, args: ["/accounts/1/multipart/2/complete", params: {}, data: {}]) do
|
31
|
+
Kloudless.http.expect(:post, args: ["/accounts/1/storage/multipart/2/complete", params: {}, data: {}]) do
|
32
32
|
upload = Kloudless::MultipartUpload.finalize(account_id: 1, multipart_id: 2)
|
33
33
|
assert_kind_of Kloudless::MultipartUpload, upload
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_abort_multipart_upload
|
38
|
-
Kloudless.http.expect(:delete, args: ["/accounts/1/multipart/2", params: {}]) do
|
38
|
+
Kloudless.http.expect(:delete, args: ["/accounts/1/storage/multipart/2", params: {}]) do
|
39
39
|
upload = Kloudless::MultipartUpload.abort(account_id: 1, multipart_id: 2)
|
40
40
|
assert_kind_of Kloudless::MultipartUpload, upload
|
41
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kloudless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jerry Cheung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,7 +92,6 @@ files:
|
|
92
92
|
- lib/kloudless/link.rb
|
93
93
|
- lib/kloudless/model.rb
|
94
94
|
- lib/kloudless/multipart_upload.rb
|
95
|
-
- lib/kloudless/team.rb
|
96
95
|
- lib/kloudless/version.rb
|
97
96
|
- script/changelog
|
98
97
|
- script/package
|
@@ -106,7 +105,6 @@ files:
|
|
106
105
|
- test/kloudless/http_test.rb
|
107
106
|
- test/kloudless/link_test.rb
|
108
107
|
- test/kloudless/multipart_upload_test.rb
|
109
|
-
- test/kloudless/team_test.rb
|
110
108
|
- test/kloudless_test.rb
|
111
109
|
- test/test_helper.rb
|
112
110
|
homepage: https://github.com/jch/kloudless-ruby
|
@@ -143,6 +141,5 @@ test_files:
|
|
143
141
|
- test/kloudless/http_test.rb
|
144
142
|
- test/kloudless/link_test.rb
|
145
143
|
- test/kloudless/multipart_upload_test.rb
|
146
|
-
- test/kloudless/team_test.rb
|
147
144
|
- test/kloudless_test.rb
|
148
145
|
- test/test_helper.rb
|
data/lib/kloudless/team.rb
DELETED
data/test/kloudless/team_test.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class Kloudless::TeamTest < Minitest::Test
|
4
|
-
def test_list_teams
|
5
|
-
Kloudless.http.expect(:get, returns: {"objects" => [{}]}, args: ["/accounts/1/team", params: {}]) do
|
6
|
-
teams = Kloudless::Team.list(account_id: 1)
|
7
|
-
assert_kind_of Kloudless::Collection, teams
|
8
|
-
assert_kind_of Kloudless::Team, teams.first
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|