boxr 1.13.1 → 1.14.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d6d520618b4c7dc7741712b37229378971bf5fa9df2a615105cc32290ed3f6a
4
- data.tar.gz: c3dc80a52abbadb66f40d1bb33688bff02d66d2e4d5a40adb2a19a7f9d350df6
3
+ metadata.gz: 40063e0f756163b9f014413b1015a540381aff4dc47fdd04d43eb0f088e852ff
4
+ data.tar.gz: 1bbf85b5274279498459666a017f2e0a3d0b6fab1a9f07fcb4dd0344785a805b
5
5
  SHA512:
6
- metadata.gz: faa073dab1a0cac78372336f602b8d4c84c31d35cf2ddc794a41764e85542f331aba21ad2073b958dd42c701d9819acc8234d547c7f6a7a1a30fe1ecb3f50cc1
7
- data.tar.gz: 0e89dbdee4405705350af41358a0c4ffcdab599937450d206ae93fc9cdda2d1edce734b163fd961ab59061949666c88321350a7ed3c16a64306a72ca687bf691
6
+ metadata.gz: 0ab3fe10d8a97c07c51124ed777facd3f57db71fc56a06ac9d031a3eb752f028b78c0309aed2e21a34510fb426c68b3226cc6d54ee13145281447fd000fc84f4
7
+ data.tar.gz: fb4306f1764b16adb8153c9a0812d20f3ce3683da0700563b05ce492d7907c68d9da5dce02361235d9bd30890152b047a22c7cb9a11665cd9526ebd80338a91d
@@ -1,21 +1,38 @@
1
1
  module Boxr
2
2
  class Client
3
3
 
4
- def folder_collaborations(folder, fields: [])
4
+ def folder_collaborations(folder, fields: [], offset: 0, limit: DEFAULT_LIMIT)
5
5
  folder_id = ensure_id(folder)
6
6
  query = build_fields_query(fields, COLLABORATION_FIELDS_QUERY)
7
7
  uri = "#{FOLDERS_URI}/#{folder_id}/collaborations"
8
+ collaborations = get_all_with_pagination(uri, query: query, offset: offset, limit: limit)
9
+ end
10
+
11
+ def file_collaborations(file, fields: [], limit: DEFAULT_LIMIT, marker: nil)
12
+ file_id = ensure_id(file)
13
+ query = build_fields_query(fields, COLLABORATION_FIELDS_QUERY)
14
+ query[:limit] = limit
15
+ query[:marker] = marker unless marker.nil?
16
+
17
+ uri = "#{FILES_URI}/#{file_id}/collaborations"
8
18
 
9
19
  collaborations, response = get(uri, query: query)
10
20
  collaborations['entries']
11
21
  end
12
22
 
13
- def add_collaboration(folder, accessible_by, role, fields: [], notify: nil)
14
- folder_id = ensure_id(folder)
23
+ def group_collaborations(group, offset: 0, limit: DEFAULT_LIMIT)
24
+ group_id = ensure_id(group)
25
+ uri = "#{GROUPS_URI}/#{group_id}/collaborations"
26
+
27
+ collaborations = get_all_with_pagination(uri, offset: offset, limit: limit)
28
+ end
29
+
30
+ def add_collaboration(item, accessible_by, role, fields: [], notify: nil, type: :folder)
31
+ item_id = ensure_id(item)
15
32
  query = build_fields_query(fields, COLLABORATION_FIELDS_QUERY)
16
33
  query[:notify] = notify unless notify.nil?
17
34
 
18
- attributes = {item: {id: folder_id, type: :folder}}
35
+ attributes = {item: {id: item_id, type: type}}
19
36
  attributes[:accessible_by] = accessible_by
20
37
  attributes[:role] = validate_role(role)
21
38
 
@@ -60,9 +77,8 @@ module Boxr
60
77
  pending_collaborations['entries']
61
78
  end
62
79
 
63
-
64
80
  private
65
-
81
+
66
82
  def validate_role(role)
67
83
  case role
68
84
  when :previewer_uploader
@@ -75,7 +91,7 @@ module Boxr
75
91
 
76
92
  role = role.to_s
77
93
  raise BoxrError.new(boxr_message: "Invalid collaboration role: '#{role}'") unless VALID_COLLABORATION_ROLES.include?(role)
78
-
94
+
79
95
  role
80
96
  end
81
97
  end
@@ -89,11 +89,5 @@ module Boxr
89
89
  result
90
90
  end
91
91
 
92
- def group_collaborations(group, offset: 0, limit: DEFAULT_LIMIT)
93
- group_id = ensure_id(group)
94
- uri = "#{GROUPS_URI}/#{group_id}/collaborations"
95
- collaborations = get_all_with_pagination(uri, offset: offset, limit: limit)
96
- end
97
-
98
92
  end
99
93
  end
@@ -1,3 +1,3 @@
1
1
  module Boxr
2
- VERSION = "1.13.1".freeze
2
+ VERSION = "1.14.0".freeze
3
3
  end
@@ -1,10 +1,22 @@
1
1
  #rake spec SPEC_OPTS="-e \"invokes collaborations operations"\"
2
2
  describe 'collaborations operations' do
3
3
  it "invokes collaborations operations" do
4
+ puts "test setup"
5
+ new_file = BOX_CLIENT.upload_file("./spec/test_files/#{TEST_FILE_NAME}", @test_folder)
6
+ test_group = BOX_CLIENT.create_group(TEST_GROUP_NAME)
7
+ second_test_user = BOX_CLIENT.create_user("Second Test User", login: "second_test_user@#{('a'..'z').to_a.shuffle[0,10].join}.com", role: 'coadmin')
8
+
4
9
  puts "add collaboration"
5
10
  collaboration = BOX_CLIENT.add_collaboration(@test_folder, {id: @test_user.id, type: :user}, :viewer_uploader)
11
+ file_collaboration = BOX_CLIENT.add_collaboration(new_file, {id: second_test_user.id, type: :user}, :viewer, type: :file)
12
+ group_collaboration = BOX_CLIENT.add_collaboration(@test_folder, {id: test_group.id, type: :group}, :editor)
6
13
  expect(collaboration.accessible_by.id).to eq(@test_user.id)
14
+ expect(file_collaboration.accessible_by.id).to eq(second_test_user.id)
15
+ expect(group_collaboration.accessible_by.id).to eq(test_group.id)
16
+
7
17
  COLLABORATION = collaboration
18
+ FILE_COLLABORATION = file_collaboration
19
+ GROUP_COLLABORATION = group_collaboration
8
20
 
9
21
  puts "inspect collaboration"
10
22
  collaboration = BOX_CLIENT.collaboration(COLLABORATION)
@@ -16,14 +28,24 @@ describe 'collaborations operations' do
16
28
 
17
29
  puts "inspect folder collaborations"
18
30
  collaborations = BOX_CLIENT.folder_collaborations(@test_folder)
19
- expect(collaborations.count).to eq(1)
31
+ expect(collaborations.count).to eq(2)
20
32
  expect(collaborations[0].id).to eq(COLLABORATION.id)
21
33
 
34
+ puts "inspect file collaborations"
35
+ collaborations = BOX_CLIENT.file_collaborations(new_file)
36
+ expect(collaborations.count).to eq(3)
37
+ expect(collaborations[0].id).to eq(FILE_COLLABORATION.id)
38
+
39
+ puts "inspect group collaborations"
40
+ collaborations = BOX_CLIENT.group_collaborations(test_group)
41
+ expect(collaborations.count).to eq(1)
42
+ expect(collaborations[0].id).to eq(GROUP_COLLABORATION.id)
43
+
22
44
  puts "remove collaboration"
23
45
  result = BOX_CLIENT.remove_collaboration(COLLABORATION)
24
46
  expect(result).to eq({})
25
47
  collaborations = BOX_CLIENT.folder_collaborations(@test_folder)
26
- expect(collaborations.count).to eq(0)
48
+ expect(collaborations.count).to eq(1)
27
49
 
28
50
  puts "inspect pending collaborations"
29
51
  pending_collaborations = BOX_CLIENT.pending_collaborations
@@ -31,5 +53,10 @@ describe 'collaborations operations' do
31
53
 
32
54
  puts "add invalid collaboration"
33
55
  expect { BOX_CLIENT.add_collaboration(@test_folder, {id: @test_user.id, type: :user}, :invalid_role)}.to raise_error{Boxr::BoxrError}
56
+
57
+ puts "test teardown"
58
+ BOX_CLIENT.delete_file(new_file)
59
+ BOX_CLIENT.delete_group(test_group)
60
+ BOX_CLIENT.delete_user(second_test_user, force: true)
34
61
  end
35
62
  end
@@ -56,10 +56,6 @@ describe 'group operations' do
56
56
  group_memberships = BOX_CLIENT.group_memberships_for_user(@test_user)
57
57
  expect(group_memberships.count).to eq(0)
58
58
 
59
- puts "inspect group collaborations"
60
- group_collaboration = BOX_CLIENT.add_collaboration(@test_folder, {id: test_group.id, type: :group}, :editor)
61
- expect(group_collaboration.accessible_by.id).to eq(test_group.id)
62
-
63
59
  puts "delete group"
64
60
  response = BOX_CLIENT.delete_group(test_group)
65
61
  expect(response).to eq({})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.1
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Burnette
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-11-17 00:00:00.000000000 Z
12
+ date: 2019-11-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler