File tree Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -34,4 +34,14 @@ def initialize(attrs={})
34
34
super ( attrs )
35
35
end
36
36
end
37
+
38
+ class SpaceUsage
39
+ attr_reader :used , :allocation , :allocated
40
+
41
+ def initialize ( attrs = { } )
42
+ @used = attrs [ 'used' ] # Space used in bytes
43
+ @allocation = attrs [ 'allocation' ] [ '.tag' ] # The type of allocation
44
+ @allocated = attrs [ 'allocation' ] [ 'allocated' ] # Space allocated in bytes
45
+ end
46
+ end
37
47
end
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ def get_account(id)
37
37
parse_tagged_response ( resp , 'basic_account' )
38
38
end
39
39
40
+ # Takes an array of account IDs and returns an array of BasicAccounts
40
41
def get_account_batch ( ids )
41
42
resp = request ( '/users/get_account_batch' , account_ids : ids )
42
43
resp . map { |a | parse_tagged_response ( a , 'basic_account' ) }
@@ -57,6 +58,11 @@ def get_preview(path)
57
58
return parse_tagged_response ( resp , 'file' ) , body
58
59
end
59
60
61
+ def get_space_usage
62
+ resp = request ( '/users/get_space_usage' )
63
+ SpaceUsage . new ( resp )
64
+ end
65
+
60
66
def get_temporary_link ( path )
61
67
resp = request ( '/files/get_temporary_link' , path : path )
62
68
return parse_tagged_response ( resp [ 'metadata' ] , 'file' ) , resp [ 'link' ]
Original file line number Diff line number Diff line change @@ -35,4 +35,15 @@ def test_full_account_initialize
35
35
assert_equal false , account . disabled
36
36
assert_equal true , account . is_paired
37
37
end
38
+
39
+ def test_space_usage_initialize
40
+ usage = Dropbox ::SpaceUsage . new ( {
41
+ 'used' => 1 ,
42
+ 'allocation' => { '.tag' => 'team' , 'allocated' => 2 }
43
+ } )
44
+
45
+ assert_equal 1 , usage . used
46
+ assert_equal 'team' , usage . allocation
47
+ assert_equal 2 , usage . allocated
48
+ end
38
49
end
Original file line number Diff line number Diff line change @@ -45,4 +45,12 @@ def test_get_current_account
45
45
assert_equal false , account . disabled
46
46
end
47
47
48
+ def test_get_space_usage
49
+ usage = @client . get_space_usage
50
+
51
+ assert usage . used . is_a? ( Integer )
52
+ assert_equal 'individual' , usage . allocation
53
+ assert usage . allocated . is_a? ( Integer )
54
+ end
55
+
48
56
end
You can’t perform that action at this time.
0 commit comments