boxr 1.22.0 → 1.23.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 +4 -4
- data/.github/workflows/ruby-tests.yml +52 -0
- data/.gitignore +1 -0
- data/.rspec +0 -1
- data/.rubocop.yml +22 -0
- data/README.md +34 -5
- data/Rakefile +3 -4
- data/bin/boxr +5 -2
- data/boxr.gemspec +30 -25
- data/examples/enterprise_events.rb +15 -11
- data/examples/jwt_auth.rb +6 -5
- data/examples/metadata_search.rb +12 -11
- data/examples/oauth.rb +8 -11
- data/examples/remove_collaborators.rb +6 -5
- data/examples/use_events_to_send_sms.rb +35 -34
- data/examples/use_events_to_warn_about_sharing.rb +35 -31
- data/examples/user_events.rb +8 -7
- data/lib/boxr/auth.rb +41 -36
- data/lib/boxr/chunked_uploads.rb +56 -32
- data/lib/boxr/client.rb +117 -102
- data/lib/boxr/collaborations.rb +21 -14
- data/lib/boxr/collections.rb +5 -5
- data/lib/boxr/comments.rb +13 -13
- data/lib/boxr/errors.rb +25 -21
- data/lib/boxr/files.rb +87 -73
- data/lib/boxr/folders.rb +32 -29
- data/lib/boxr/groups.rb +22 -22
- data/lib/boxr/metadata.rb +23 -22
- data/lib/boxr/search.rb +34 -28
- data/lib/boxr/shared_items.rb +7 -5
- data/lib/boxr/tasks.rb +18 -18
- data/lib/boxr/users.rb +63 -38
- data/lib/boxr/version.rb +3 -1
- data/lib/boxr/watermarking.rb +10 -17
- data/lib/boxr/web_links.rb +14 -17
- data/lib/boxr/webhooks.rb +8 -7
- data/lib/boxr.rb +13 -11
- metadata +86 -28
data/lib/boxr/metadata.rb
CHANGED
@@ -1,45 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Boxr
|
2
4
|
class Client
|
3
|
-
|
4
5
|
def create_metadata(file, metadata, scope: :global, template: :properties)
|
5
6
|
file_id = ensure_id(file)
|
6
7
|
uri = "#{FILE_METADATA_URI}/#{file_id}/metadata/#{scope}/#{template}"
|
7
|
-
metadata,
|
8
|
+
metadata, = post(uri, metadata, content_type: 'application/json')
|
8
9
|
metadata
|
9
10
|
end
|
10
11
|
|
11
12
|
def create_folder_metadata(folder, metadata, scope, template)
|
12
13
|
folder_id = ensure_id(folder)
|
13
14
|
uri = "#{FOLDER_METADATA_URI}/#{folder_id}/metadata/#{scope}/#{template}"
|
14
|
-
metadata,
|
15
|
+
metadata, = post(uri, metadata, content_type: 'application/json')
|
15
16
|
metadata
|
16
17
|
end
|
17
18
|
|
18
19
|
def metadata(file, scope: :global, template: :properties)
|
19
20
|
file_id = ensure_id(file)
|
20
21
|
uri = "#{FILE_METADATA_URI}/#{file_id}/metadata/#{scope}/#{template}"
|
21
|
-
metadata,
|
22
|
+
metadata, = get(uri)
|
22
23
|
metadata
|
23
24
|
end
|
24
25
|
|
25
26
|
def folder_metadata(folder, scope, template)
|
26
27
|
folder_id = ensure_id(folder)
|
27
28
|
uri = "#{FOLDER_METADATA_URI}/#{folder_id}/metadata/#{scope}/#{template}"
|
28
|
-
metadata,
|
29
|
+
metadata, = get(uri)
|
29
30
|
metadata
|
30
31
|
end
|
31
32
|
|
32
33
|
def all_folder_metadata(folder)
|
33
34
|
folder_id = ensure_id(folder)
|
34
35
|
uri = "#{FOLDER_METADATA_URI}/#{folder_id}/metadata"
|
35
|
-
all_metadata,
|
36
|
+
all_metadata, = get(uri)
|
36
37
|
all_metadata
|
37
38
|
end
|
38
39
|
|
39
40
|
def all_metadata(file)
|
40
41
|
file_id = ensure_id(file)
|
41
42
|
uri = "#{FILE_METADATA_URI}/#{file_id}/metadata"
|
42
|
-
all_metadata,
|
43
|
+
all_metadata, = get(uri)
|
43
44
|
all_metadata
|
44
45
|
end
|
45
46
|
|
@@ -47,10 +48,10 @@ module Boxr
|
|
47
48
|
file_id = ensure_id(file)
|
48
49
|
uri = "#{FILE_METADATA_URI}/#{file_id}/metadata/#{scope}/#{template}"
|
49
50
|
|
50
|
-
#in the event just one update is specified ensure that it is packaged inside an array
|
51
|
+
# in the event just one update is specified ensure that it is packaged inside an array
|
51
52
|
updates = [updates] unless updates.is_a? Array
|
52
53
|
|
53
|
-
metadata,
|
54
|
+
metadata, = put(uri, updates, content_type: 'application/json-patch+json')
|
54
55
|
metadata
|
55
56
|
end
|
56
57
|
|
@@ -58,65 +59,65 @@ module Boxr
|
|
58
59
|
folder_id = ensure_id(folder)
|
59
60
|
uri = "#{FOLDER_METADATA_URI}/#{folder_id}/metadata/#{scope}/#{template}"
|
60
61
|
|
61
|
-
#in the event just one update is specified ensure that it is packaged inside an array
|
62
|
+
# in the event just one update is specified ensure that it is packaged inside an array
|
62
63
|
updates = [updates] unless updates.is_a? Array
|
63
64
|
|
64
|
-
metadata,
|
65
|
+
metadata, = put(uri, updates, content_type: 'application/json-patch+json')
|
65
66
|
metadata
|
66
67
|
end
|
67
68
|
|
68
69
|
def delete_metadata(file, scope: :global, template: :properties)
|
69
70
|
file_id = ensure_id(file)
|
70
71
|
uri = "#{FILE_METADATA_URI}/#{file_id}/metadata/#{scope}/#{template}"
|
71
|
-
result,
|
72
|
+
result, = delete(uri)
|
72
73
|
result
|
73
74
|
end
|
74
75
|
|
75
76
|
def delete_folder_metadata(folder, scope, template)
|
76
77
|
folder_id = ensure_id(folder)
|
77
78
|
uri = "#{FOLDER_METADATA_URI}/#{folder_id}/metadata/#{scope}/#{template}"
|
78
|
-
result,
|
79
|
+
result, = delete(uri)
|
79
80
|
result
|
80
81
|
end
|
81
82
|
|
82
83
|
def enterprise_metadata
|
83
84
|
uri = "#{METADATA_TEMPLATES_URI}/enterprise"
|
84
|
-
ent_metadata,
|
85
|
+
ent_metadata, = get(uri)
|
85
86
|
ent_metadata
|
86
87
|
end
|
87
|
-
alias
|
88
|
+
alias get_enterprise_templates enterprise_metadata
|
88
89
|
|
89
90
|
def metadata_schema(scope, template_key)
|
90
91
|
uri = "#{METADATA_TEMPLATES_URI}/#{scope}/#{template_key}/schema"
|
91
|
-
schema,
|
92
|
+
schema, = get(uri)
|
92
93
|
schema
|
93
94
|
end
|
94
|
-
alias
|
95
|
+
alias get_metadata_template_by_name metadata_schema
|
95
96
|
|
96
97
|
def get_metadata_template_by_id(template_id)
|
97
98
|
template_id = ensure_id(template_id)
|
98
99
|
uri = "#{METADATA_TEMPLATES_URI}/#{template_id}"
|
99
|
-
schema,
|
100
|
+
schema, = get(uri)
|
100
101
|
schema
|
101
102
|
end
|
102
103
|
|
103
104
|
def create_metadata_template(display_name, template_key: nil, fields: [], hidden: nil)
|
104
105
|
uri = "#{METADATA_TEMPLATES_URI}/schema"
|
105
106
|
schema = {
|
106
|
-
scope:
|
107
|
-
displayName: display_name
|
107
|
+
scope: 'enterprise',
|
108
|
+
displayName: display_name
|
108
109
|
}
|
109
110
|
schema[:templateKey] = template_key unless template_key.nil?
|
110
111
|
schema[:hidden] = hidden unless hidden.nil?
|
111
112
|
schema[:fields] = fields unless fields.empty?
|
112
113
|
|
113
|
-
metadata_template,
|
114
|
+
metadata_template, = post(uri, schema, content_type: 'application/json')
|
114
115
|
metadata_template
|
115
116
|
end
|
116
117
|
|
117
118
|
def delete_metadata_template(scope, template_key)
|
118
119
|
uri = "#{METADATA_TEMPLATES_URI}/#{scope}/#{template_key}/schema"
|
119
|
-
result,
|
120
|
+
result, = delete(uri)
|
120
121
|
result
|
121
122
|
end
|
122
123
|
end
|
data/lib/boxr/search.rb
CHANGED
@@ -1,43 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Boxr
|
2
4
|
class Client
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
unless mdfilters.is_a? Array
|
15
|
-
mdfilters = [mdfilters] #if just one mdfilter is specified ensure that it is packaged inside an array
|
16
|
-
end
|
17
|
-
mdfilters = JSON.dump(mdfilters)
|
5
|
+
def search(query = nil, scope: nil, file_extensions: [], fields: [],
|
6
|
+
created_at_range_from_date: nil, created_at_range_to_date: nil,
|
7
|
+
updated_at_range_from_date: nil, updated_at_range_to_date: nil,
|
8
|
+
size_range_lower_bound_bytes: nil, size_range_upper_bound_bytes: nil,
|
9
|
+
owner_user_ids: [], ancestor_folder_ids: [], content_types: [], trash_content: nil,
|
10
|
+
mdfilters: nil, type: nil, limit: 30, offset: 0)
|
11
|
+
# if a string is passed in assume it is already formatted correctly
|
12
|
+
if !mdfilters.nil? && !mdfilters.is_a?(String)
|
13
|
+
unless mdfilters.is_a? Array
|
14
|
+
# if just one mdfilter is specified ensure that it is packaged inside an array
|
15
|
+
mdfilters = [mdfilters]
|
18
16
|
end
|
17
|
+
mdfilters = JSON.dump(mdfilters)
|
19
18
|
end
|
20
19
|
|
21
|
-
#build range strings
|
22
|
-
created_at_range_string = build_date_range_field(created_at_range_from_date,
|
23
|
-
|
24
|
-
|
20
|
+
# build range strings
|
21
|
+
created_at_range_string = build_date_range_field(created_at_range_from_date,
|
22
|
+
created_at_range_to_date)
|
23
|
+
updated_at_range_string = build_date_range_field(updated_at_range_from_date,
|
24
|
+
updated_at_range_to_date)
|
25
|
+
size_range_string = build_size_range_field(size_range_lower_bound_bytes,
|
26
|
+
size_range_upper_bound_bytes)
|
25
27
|
|
26
|
-
#build comma separated strings
|
28
|
+
# build comma separated strings
|
27
29
|
file_extensions_string = to_comma_separated_string(file_extensions)
|
28
30
|
owner_user_ids_string = to_comma_separated_string(owner_user_ids)
|
29
31
|
ancestor_folder_ids_string = to_comma_separated_string(ancestor_folder_ids)
|
30
32
|
content_types_string = to_comma_separated_string(content_types)
|
33
|
+
fields_string = to_comma_separated_string(fields)
|
31
34
|
|
32
35
|
search_query = {}
|
33
36
|
search_query[:query] = query unless query.nil?
|
34
37
|
search_query[:scope] = scope unless scope.nil?
|
35
38
|
search_query[:file_extensions] = file_extensions_string unless file_extensions_string.nil?
|
39
|
+
search_query[:fields] = fields_string unless fields_string.nil?
|
36
40
|
search_query[:created_at_range] = created_at_range_string unless created_at_range_string.nil?
|
37
41
|
search_query[:updated_at_range] = updated_at_range_string unless updated_at_range_string.nil?
|
38
42
|
search_query[:size_range] = size_range_string unless size_range_string.nil?
|
39
43
|
search_query[:owner_user_ids] = owner_user_ids_string unless owner_user_ids_string.nil?
|
40
|
-
|
44
|
+
unless ancestor_folder_ids_string.nil?
|
45
|
+
search_query[:ancestor_folder_ids] =
|
46
|
+
ancestor_folder_ids_string
|
47
|
+
end
|
41
48
|
search_query[:content_types] = content_types_string unless content_types_string.nil?
|
42
49
|
search_query[:trash_content] = trash_content unless trash_content.nil?
|
43
50
|
search_query[:mdfilters] = mdfilters unless mdfilters.nil?
|
@@ -45,23 +52,22 @@ module Boxr
|
|
45
52
|
search_query[:limit] = limit unless limit.nil?
|
46
53
|
search_query[:offset] = offset unless offset.nil?
|
47
54
|
|
48
|
-
results,
|
55
|
+
results, = get(SEARCH_URI, query: search_query)
|
49
56
|
results.entries
|
50
57
|
end
|
51
58
|
|
52
59
|
private
|
53
60
|
|
54
61
|
def build_date_range_field(from, to)
|
55
|
-
from_string = from.nil? ?
|
56
|
-
to_string = to.nil? ?
|
62
|
+
from_string = from.nil? ? '' : from.to_datetime.rfc3339
|
63
|
+
to_string = to.nil? ? '' : to.to_datetime.rfc3339
|
57
64
|
build_range_string(from_string, to_string)
|
58
65
|
end
|
59
66
|
|
60
67
|
def build_size_range_field(lower, upper)
|
61
|
-
lower_string = lower.nil? ?
|
62
|
-
upper_string = upper.nil? ?
|
68
|
+
lower_string = lower.nil? ? '' : lower.to_i
|
69
|
+
upper_string = upper.nil? ? '' : upper.to_i
|
63
70
|
build_range_string(lower_string, upper_string)
|
64
71
|
end
|
65
|
-
|
66
72
|
end
|
67
|
-
end
|
73
|
+
end
|
data/lib/boxr/shared_items.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Boxr
|
2
4
|
class Client
|
3
|
-
|
4
5
|
def shared_item(shared_link, shared_link_password: nil)
|
5
6
|
box_api_header = "shared_link=#{shared_link}"
|
6
|
-
|
7
|
+
unless shared_link_password.nil?
|
8
|
+
box_api_header += "&shared_link_password=#{shared_link_password}"
|
9
|
+
end
|
7
10
|
|
8
|
-
file_or_folder,
|
11
|
+
file_or_folder, = get(SHARED_ITEMS_URI, box_api_header: box_api_header)
|
9
12
|
file_or_folder
|
10
13
|
end
|
11
|
-
|
12
14
|
end
|
13
|
-
end
|
15
|
+
end
|
data/lib/boxr/tasks.rb
CHANGED
@@ -1,33 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Boxr
|
2
4
|
class Client
|
3
|
-
|
4
5
|
def file_tasks(file, fields: [])
|
5
6
|
file_id = ensure_id(file)
|
6
7
|
uri = "#{FILES_URI}/#{file_id}/tasks"
|
7
8
|
query = build_fields_query(fields, TASK_FIELDS_QUERY)
|
8
9
|
|
9
|
-
tasks,
|
10
|
+
tasks, = get(uri, query: query)
|
10
11
|
tasks.entries
|
11
12
|
end
|
12
13
|
|
13
14
|
def create_task(file, action: :review, message: nil, due_at: nil)
|
14
15
|
file_id = ensure_id(file)
|
15
|
-
attributes = {item: {type: :file, id: file_id}}
|
16
|
+
attributes = { item: { type: :file, id: file_id } }
|
16
17
|
attributes[:action] = action unless action.nil?
|
17
18
|
attributes[:message] = message unless message.nil?
|
18
19
|
attributes[:due_at] = due_at.to_datetime.rfc3339 unless due_at.nil?
|
19
20
|
|
20
|
-
new_task,
|
21
|
+
new_task, = post(TASKS_URI, attributes)
|
21
22
|
new_task
|
22
23
|
end
|
23
24
|
|
24
25
|
def task_from_id(task_id)
|
25
26
|
task_id = ensure_id(task_id)
|
26
27
|
uri = "#{TASKS_URI}/#{task_id}"
|
27
|
-
task,
|
28
|
+
task, = get(uri)
|
28
29
|
task
|
29
30
|
end
|
30
|
-
alias
|
31
|
+
alias task task_from_id
|
31
32
|
|
32
33
|
def update_task(task, action: :review, message: nil, due_at: nil)
|
33
34
|
task_id = ensure_id(task)
|
@@ -37,48 +38,48 @@ module Boxr
|
|
37
38
|
attributes[:message] = message unless message.nil?
|
38
39
|
attributes[:due_at] = due_at.to_datetime.rfc3339 unless due_at.nil?
|
39
40
|
|
40
|
-
task,
|
41
|
+
task, = put(uri, attributes)
|
41
42
|
task
|
42
43
|
end
|
43
44
|
|
44
45
|
def delete_task(task)
|
45
46
|
task_id = ensure_id(task)
|
46
47
|
uri = "#{TASKS_URI}/#{task_id}"
|
47
|
-
result,
|
48
|
+
result, = delete(uri)
|
48
49
|
result
|
49
50
|
end
|
50
51
|
|
51
52
|
def task_assignments(task)
|
52
53
|
task_id = ensure_id(task)
|
53
54
|
uri = "#{TASKS_URI}/#{task_id}/assignments"
|
54
|
-
assignments,
|
55
|
+
assignments, = get(uri)
|
55
56
|
assignments['entries']
|
56
57
|
end
|
57
58
|
|
58
59
|
def create_task_assignment(task, assign_to: nil, assign_to_login: nil)
|
59
60
|
task_id = ensure_id(task)
|
60
61
|
assign_to_id = ensure_id(assign_to)
|
61
|
-
attributes = {task: {type: :task, id:
|
62
|
-
|
63
|
-
attributes[:assign_to] = {}
|
62
|
+
attributes = { task: { type: :task, id: task_id.to_s } }
|
63
|
+
|
64
|
+
attributes[:assign_to] = {}
|
64
65
|
attributes[:assign_to][:login] = assign_to_login unless assign_to_login.nil?
|
65
66
|
attributes[:assign_to][:id] = assign_to_id unless assign_to_id.nil?
|
66
67
|
|
67
|
-
new_task_assignment,
|
68
|
+
new_task_assignment, = post(TASK_ASSIGNMENTS_URI, attributes)
|
68
69
|
new_task_assignment
|
69
70
|
end
|
70
71
|
|
71
72
|
def task_assignment(task)
|
72
73
|
task_id = ensure_id(task)
|
73
74
|
uri = "#{TASK_ASSIGNMENTS_URI}/#{task_id}"
|
74
|
-
task_assignment,
|
75
|
+
task_assignment, = get(uri)
|
75
76
|
task_assignment
|
76
77
|
end
|
77
78
|
|
78
79
|
def delete_task_assignment(task)
|
79
80
|
task_id = ensure_id(task)
|
80
81
|
uri = "#{TASK_ASSIGNMENTS_URI}/#{task_id}"
|
81
|
-
result,
|
82
|
+
result, = delete(uri)
|
82
83
|
result
|
83
84
|
end
|
84
85
|
|
@@ -89,9 +90,8 @@ module Boxr
|
|
89
90
|
attributes[:message] = message unless message.nil?
|
90
91
|
attributes[:resolution_state] = resolution_state unless resolution_state.nil?
|
91
92
|
|
92
|
-
updated_task,
|
93
|
+
updated_task, = put(uri, attributes)
|
93
94
|
updated_task
|
94
95
|
end
|
95
|
-
|
96
96
|
end
|
97
|
-
end
|
97
|
+
end
|
data/lib/boxr/users.rb
CHANGED
@@ -1,24 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Boxr
|
2
4
|
class Client
|
3
|
-
|
4
5
|
def current_user(fields: [])
|
5
6
|
uri = "#{USERS_URI}/me"
|
6
7
|
query = build_fields_query(fields, USER_FIELDS_QUERY)
|
7
8
|
|
8
|
-
user,
|
9
|
+
user, = get(uri, query: query)
|
9
10
|
user
|
10
11
|
end
|
11
|
-
alias
|
12
|
+
alias me current_user
|
12
13
|
|
13
14
|
def user_from_id(user_id, fields: [])
|
14
15
|
user_id = ensure_id(user_id)
|
15
16
|
uri = "#{USERS_URI}/#{user_id}"
|
16
17
|
query = build_fields_query(fields, USER_FIELDS_QUERY)
|
17
18
|
|
18
|
-
user,
|
19
|
+
user, = get(uri, query: query)
|
19
20
|
user
|
20
21
|
end
|
21
|
-
alias
|
22
|
+
alias user user_from_id
|
22
23
|
|
23
24
|
def all_users(filter_term: nil, fields: [], offset: nil, limit: nil)
|
24
25
|
uri = USERS_URI
|
@@ -26,25 +27,25 @@ module Boxr
|
|
26
27
|
query[:filter_term] = filter_term unless filter_term.nil?
|
27
28
|
|
28
29
|
if offset.nil? || limit.nil?
|
29
|
-
|
30
|
+
get_all_with_pagination(uri, query: query, offset: 0, limit: DEFAULT_LIMIT)
|
30
31
|
else
|
31
32
|
query[:offset] = offset
|
32
33
|
query[:limit] = limit
|
33
34
|
|
34
|
-
users,
|
35
|
+
users, = get(uri, query: query)
|
35
36
|
users['entries']
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
40
|
def create_user(name, login: nil, role: nil, language: nil, is_sync_enabled: nil, job_title: nil,
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
phone: nil, address: nil, space_amount: nil, tracking_codes: nil,
|
42
|
+
can_see_managed_users: nil, is_external_collab_restricted: nil, status: nil, timezone: nil,
|
43
|
+
is_exempt_from_device_limits: nil, is_exempt_from_login_verification: nil,
|
44
|
+
is_platform_access_only: nil)
|
45
45
|
uri = USERS_URI
|
46
|
-
attributes = {name: name}
|
47
|
-
|
46
|
+
attributes = { name: name }
|
47
|
+
# login is not required for platform users, so needed to make this optional
|
48
|
+
attributes[:login] = login unless login.nil?
|
48
49
|
attributes[:role] = role unless role.nil?
|
49
50
|
attributes[:language] = language unless language.nil?
|
50
51
|
attributes[:is_sync_enabled] = is_sync_enabled unless is_sync_enabled.nil?
|
@@ -54,28 +55,41 @@ module Boxr
|
|
54
55
|
attributes[:space_amount] = space_amount unless space_amount.nil?
|
55
56
|
attributes[:tracking_codes] = tracking_codes unless tracking_codes.nil?
|
56
57
|
attributes[:can_see_managed_users] = can_see_managed_users unless can_see_managed_users.nil?
|
57
|
-
|
58
|
+
unless is_external_collab_restricted.nil?
|
59
|
+
attributes[:is_external_collab_restricted] =
|
60
|
+
is_external_collab_restricted
|
61
|
+
end
|
58
62
|
attributes[:status] = status unless status.nil?
|
59
63
|
attributes[:timezone] = timezone unless timezone.nil?
|
60
|
-
|
61
|
-
|
62
|
-
|
64
|
+
unless is_exempt_from_device_limits.nil?
|
65
|
+
attributes[:is_exempt_from_device_limits] =
|
66
|
+
is_exempt_from_device_limits
|
67
|
+
end
|
68
|
+
unless is_exempt_from_login_verification.nil?
|
69
|
+
attributes[:is_exempt_from_login_verification] =
|
70
|
+
is_exempt_from_login_verification
|
71
|
+
end
|
72
|
+
unless is_platform_access_only.nil?
|
73
|
+
attributes[:is_platform_access_only] =
|
74
|
+
is_platform_access_only
|
75
|
+
end
|
63
76
|
|
64
|
-
new_user,
|
77
|
+
new_user, = post(uri, attributes)
|
65
78
|
new_user
|
66
79
|
end
|
67
80
|
|
68
81
|
def update_user(user, notify: nil, enterprise: true, name: nil, role: nil, language: nil, is_sync_enabled: nil,
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
82
|
+
job_title: nil, phone: nil, address: nil, space_amount: nil, tracking_codes: nil,
|
83
|
+
can_see_managed_users: nil, status: nil, timezone: nil, is_exempt_from_device_limits: nil,
|
84
|
+
is_exempt_from_login_verification: nil, is_exempt_from_reset_required: nil, is_external_collab_restricted: nil)
|
73
85
|
user_id = ensure_id(user)
|
74
86
|
uri = "#{USERS_URI}/#{user_id}"
|
75
|
-
query = {
|
87
|
+
query = {}
|
88
|
+
query[:notify] = notify unless notify.nil?
|
76
89
|
|
77
90
|
attributes = {}
|
78
|
-
|
91
|
+
# this is a special condition where setting this to nil means to roll this user out of the enterprise
|
92
|
+
attributes[:enterprise] = nil if enterprise.nil?
|
79
93
|
attributes[:name] = name unless name.nil?
|
80
94
|
attributes[:role] = role unless role.nil?
|
81
95
|
attributes[:language] = language unless language.nil?
|
@@ -88,12 +102,24 @@ module Boxr
|
|
88
102
|
attributes[:can_see_managed_users] = can_see_managed_users unless can_see_managed_users.nil?
|
89
103
|
attributes[:status] = status unless status.nil?
|
90
104
|
attributes[:timezone] = timezone unless timezone.nil?
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
105
|
+
unless is_exempt_from_device_limits.nil?
|
106
|
+
attributes[:is_exempt_from_device_limits] =
|
107
|
+
is_exempt_from_device_limits
|
108
|
+
end
|
109
|
+
unless is_exempt_from_login_verification.nil?
|
110
|
+
attributes[:is_exempt_from_login_verification] =
|
111
|
+
is_exempt_from_login_verification
|
112
|
+
end
|
113
|
+
unless is_exempt_from_reset_required.nil?
|
114
|
+
attributes[:is_exempt_from_reset_required] =
|
115
|
+
is_exempt_from_reset_required
|
116
|
+
end
|
117
|
+
unless is_external_collab_restricted.nil?
|
118
|
+
attributes[:is_external_collab_restricted] =
|
119
|
+
is_external_collab_restricted
|
120
|
+
end
|
95
121
|
|
96
|
-
updated_user,
|
122
|
+
updated_user, = put(uri, attributes, query: query)
|
97
123
|
updated_user
|
98
124
|
end
|
99
125
|
|
@@ -104,7 +130,7 @@ module Boxr
|
|
104
130
|
query[:notify] = notify unless notify.nil?
|
105
131
|
query[:force] = force unless force.nil?
|
106
132
|
|
107
|
-
result,
|
133
|
+
result, = delete(uri, query: query)
|
108
134
|
result
|
109
135
|
end
|
110
136
|
|
@@ -114,9 +140,9 @@ module Boxr
|
|
114
140
|
destination_user_id = ensure_id(destination_user)
|
115
141
|
source_folder_id = ensure_id(source_folder)
|
116
142
|
uri = "#{USERS_URI}/#{user_id}/folders/#{source_folder_id}"
|
117
|
-
attributes = {owned_by: {id: destination_user_id}}
|
143
|
+
attributes = { owned_by: { id: destination_user_id } }
|
118
144
|
|
119
|
-
folder,
|
145
|
+
folder, = put(uri, attributes)
|
120
146
|
folder
|
121
147
|
end
|
122
148
|
|
@@ -124,16 +150,16 @@ module Boxr
|
|
124
150
|
user_id = ensure_id(user)
|
125
151
|
uri = "#{USERS_URI}/#{user_id}/email_aliases"
|
126
152
|
|
127
|
-
aliases,
|
153
|
+
aliases, = get(uri)
|
128
154
|
aliases['entries']
|
129
155
|
end
|
130
156
|
|
131
157
|
def add_email_alias_for_user(user, email)
|
132
158
|
user_id = ensure_id(user)
|
133
159
|
uri = "#{USERS_URI}/#{user_id}/email_aliases"
|
134
|
-
attributes = {email: email}
|
160
|
+
attributes = { email: email }
|
135
161
|
|
136
|
-
updated_user,
|
162
|
+
updated_user, = post(uri, attributes)
|
137
163
|
updated_user
|
138
164
|
end
|
139
165
|
|
@@ -142,9 +168,8 @@ module Boxr
|
|
142
168
|
email_alias_id = ensure_id(email_alias)
|
143
169
|
uri = "#{USERS_URI}/#{user_id}/email_aliases/#{email_alias_id}"
|
144
170
|
|
145
|
-
result,
|
171
|
+
result, = delete(uri)
|
146
172
|
result
|
147
173
|
end
|
148
|
-
|
149
174
|
end
|
150
175
|
end
|
data/lib/boxr/version.rb
CHANGED
data/lib/boxr/watermarking.rb
CHANGED
@@ -1,66 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Boxr
|
2
4
|
class Client
|
3
|
-
|
4
5
|
def get_watermark_on_file(file)
|
5
|
-
|
6
6
|
file_id = ensure_id(file)
|
7
7
|
uri = "#{FILES_URI}/#{file_id}/watermark"
|
8
8
|
|
9
|
-
file,
|
9
|
+
file, = get(uri)
|
10
10
|
file
|
11
11
|
end
|
12
12
|
|
13
13
|
def apply_watermark_on_file(file)
|
14
|
-
|
15
14
|
file_id = ensure_id(file)
|
16
15
|
uri = "#{FILES_URI}/#{file_id}/watermark"
|
17
16
|
|
18
17
|
attributes = {}
|
19
|
-
attributes[:watermark] = {:
|
18
|
+
attributes[:watermark] = { imprint: 'default' }
|
20
19
|
|
21
|
-
file,
|
20
|
+
file, = put(uri, attributes, content_type: 'application/json')
|
22
21
|
file
|
23
22
|
end
|
24
23
|
|
25
24
|
def remove_watermark_on_file(file)
|
26
|
-
|
27
25
|
file_id = ensure_id(file)
|
28
26
|
uri = "#{FILES_URI}/#{file_id}/watermark"
|
29
27
|
|
30
|
-
result,
|
28
|
+
result, = delete(uri)
|
31
29
|
result
|
32
30
|
end
|
33
31
|
|
34
32
|
def get_watermark_on_folder(folder)
|
35
|
-
|
36
33
|
folder_id = ensure_id(folder)
|
37
34
|
uri = "#{FOLDERS_URI}/#{folder_id}/watermark"
|
38
35
|
|
39
|
-
folder,
|
36
|
+
folder, = get(uri)
|
40
37
|
folder
|
41
38
|
end
|
42
39
|
|
43
40
|
def apply_watermark_on_folder(folder)
|
44
|
-
|
45
41
|
folder_id = ensure_id(folder)
|
46
42
|
uri = "#{FOLDERS_URI}/#{folder_id}/watermark"
|
47
43
|
|
48
44
|
attributes = {}
|
49
|
-
attributes[:watermark] = {:
|
45
|
+
attributes[:watermark] = { imprint: 'default' }
|
50
46
|
|
51
|
-
folder,
|
47
|
+
folder, = put(uri, attributes, content_type: 'application/json')
|
52
48
|
folder
|
53
49
|
end
|
54
50
|
|
55
51
|
def remove_watermark_on_folder(folder)
|
56
|
-
|
57
52
|
folder_id = ensure_id(folder)
|
58
53
|
uri = "#{FOLDERS_URI}/#{folder_id}/watermark"
|
59
54
|
|
60
|
-
result,
|
55
|
+
result, = delete(uri)
|
61
56
|
result
|
62
57
|
end
|
63
|
-
|
64
|
-
|
65
58
|
end
|
66
59
|
end
|