diff --git a/lib/boxr/client.rb b/lib/boxr/client.rb index 2da03c8..811f9f7 100644 --- a/lib/boxr/client.rb +++ b/lib/boxr/client.rb @@ -27,6 +27,7 @@ class Client METADATA_TEMPLATES_URI = "#{API_URI}/metadata_templates" EVENTS_URI = "#{API_URI}/events" WEB_LINKS_URI = "#{API_URI}/web_links" + INTEGRATION = "#{API_URI}/app_integration_assignments" DEFAULT_LIMIT = 100 @@ -90,14 +91,15 @@ def initialize( access_token=ENV['BOX_DEVELOPER_TOKEN'], private - def get(uri, query: nil, success_codes: [200], process_response: true, if_match: nil, box_api_header: nil, follow_redirect: true) + def get(uri, query: nil, success_codes: [200], process_response: true, if_match: nil, box_api_header: nil, follow_redirect: true, x_rep_hints: nil) uri = Addressable::URI.encode(uri) res = with_auto_token_refresh do headers = standard_headers headers['If-Match'] = if_match unless if_match.nil? headers['BoxApi'] = box_api_header unless box_api_header.nil? - + headers['x-rep-hints'] = x_rep_hints unless x_rep_hints.nil? + BOX_CLIENT.get(uri, query: query, header: headers, follow_redirect: follow_redirect) end diff --git a/lib/boxr/collaborations.rb b/lib/boxr/collaborations.rb index 74a574a..cd127c2 100644 --- a/lib/boxr/collaborations.rb +++ b/lib/boxr/collaborations.rb @@ -10,7 +10,7 @@ def folder_collaborations(folder, fields: []) collaborations['entries'] end - def add_collaboration(folder, accessible_by, role, fields: [], notify: nil) + def add_collaboration(folder, accessible_by, role, can_view_path,fields: [], notify: nil) folder_id = ensure_id(folder) query = build_fields_query(fields, COLLABORATION_FIELDS_QUERY) query[:notify] = :notify unless notify.nil? @@ -18,7 +18,7 @@ def add_collaboration(folder, accessible_by, role, fields: [], notify: nil) attributes = {item: {id: folder_id, type: :folder}} attributes[:accessible_by] = accessible_by attributes[:role] = validate_role(role) - + attributes[:can_view_path] = can_view_path collaboration, response = post(COLLABORATIONS_URI, attributes, query: query) collaboration end diff --git a/lib/boxr/files.rb b/lib/boxr/files.rb index f22bc3c..7d97b1f 100644 --- a/lib/boxr/files.rb +++ b/lib/boxr/files.rb @@ -1,6 +1,15 @@ module Boxr class Client + def assign(user,id) + attributes = {} + + attributes[:assignee] = {type: "user", id: user} + attributes[:app_integration] = {type: "app_integration", id: id} + assignment_info, response = post(INTEGRATION, attributes) + assignment_info + end + def file_from_path(path) if(path.start_with?('/')) path = path.slice(1..-1) @@ -190,6 +199,13 @@ def copy_file(file, parent, name: nil) new_file, res = post(uri, attributes) new_file end + + def representations(file_id,representation) + file_id = ensure_id(file_id) + uri = "#{FILES_URI}/#{file_id}?fields=representations" + file, response = get(uri, x_rep_hints: "#{representation}") + file + end def thumbnail(file, min_height: nil, min_width: nil, max_height: nil, max_width: nil) file_id = ensure_id(file) diff --git a/lib/boxr/intergations.rb b/lib/boxr/intergations.rb new file mode 100644 index 0000000..6b8d86e --- /dev/null +++ b/lib/boxr/intergations.rb @@ -0,0 +1,12 @@ +module Boxr + class Client + + def assign(user,id) + attributes = {assignee: {type: "user", id: user},app_integration: {type: "app_integration", id: id}} + body = {JSON.dump(attributes)} + + assignment_info, response post(INTEGRATION, attributes) + assignment_info.entries[0] + end + end +end \ No newline at end of file