Class: Boxr::Client
- Inherits:
-
Object
- Object
- Boxr::Client
- Defined in:
- lib/boxr/files.rb,
lib/boxr/tasks.rb,
lib/boxr/users.rb,
lib/boxr/client.rb,
lib/boxr/events.rb,
lib/boxr/groups.rb,
lib/boxr/search.rb,
lib/boxr/folders.rb,
lib/boxr/comments.rb,
lib/boxr/metadata.rb,
lib/boxr/shared_items.rb,
lib/boxr/collaborations.rb
Constant Summary collapse
- API_URI =
"https://api.box.com/2.0"- UPLOAD_URI =
"https://upload.box.com/api/2.0"- FILES_URI =
"#{API_URI}/files"- FILES_UPLOAD_URI =
"#{UPLOAD_URI}/files/content"- FOLDERS_URI =
"#{API_URI}/folders"- USERS_URI =
"#{API_URI}/users"- GROUPS_URI =
"#{API_URI}/groups"- GROUP_MEMBERSHIPS_URI =
"#{API_URI}/group_memberships"- COLLABORATIONS_URI =
"#{API_URI}/collaborations"- COMMENTS_URI =
"#{API_URI}/comments"- SEARCH_URI =
"#{API_URI}/search"- TASKS_URI =
"#{API_URI}/tasks"- TASK_ASSIGNMENTS_URI =
"#{API_URI}/task_assignments"- SHARED_ITEMS_URI =
"#{API_URI}/shared_items"- METADATA_URI =
"#{API_URI}/files"- EVENTS_URI =
"#{API_URI}/events"- DEFAULT_LIMIT =
100- FOLDER_ITEMS_LIMIT =
1000- FOLDER_AND_FILE_FIELDS =
[:type,:id,:sequence_id,:etag,:name,:created_at,:modified_at,:description, :size,:path_collection,:created_by,:modified_by,:trashed_at,:purged_at, :content_created_at,:content_modified_at,:owned_by,:shared_link,:folder_upload_email, :parent,:item_status,:item_collection,:sync_state,:has_collaborations,:permissions,:tags, :sha1,:shared_link,:version_number,:comment_count,:lock,:extension,:is_package,:can_non_owners_invite]
- FOLDER_AND_FILE_FIELDS_QUERY =
FOLDER_AND_FILE_FIELDS.join(',')
- COMMENT_FIELDS =
[:type,:id,:is_reply_comment,:message,:tagged_message,:created_by,:created_at,:item,:modified_at]
- COMMENT_FIELDS_QUERY =
COMMENT_FIELDS.join(',')
- TASK_FIELDS =
[:type,:id,:item,:due_at,:action,:message,:task_assignment_collection,:is_completed,:created_by,:created_at]
- TASK_FIELDS_QUERY =
TASK_FIELDS.join(',')
- COLLABORATION_FIELDS =
[:type,:id,:created_by,:created_at,:modified_at,:expires_at,:status,:accessible_by,:role,:acknowledged_at,:item]
- COLLABORATION_FIELDS_QUERY =
COLLABORATION_FIELDS.join(',')
- USER_FIELDS =
[:type,:id,:name,:login,:created_at,:modified_at,:role,:language,:timezone,:space_amount,:space_used, :max_upload_size,:tracking_codes,:can_see_managed_users,:is_sync_enabled,:is_external_collab_restricted, :status,:job_title,:phone,:address,:avatar_uri,:is_exempt_from_device_limits,:is_exempt_from_login_verification, :enterprise,:my_tags]
- USER_FIELDS_QUERY =
USER_FIELDS.join(',')
- GROUP_FIELDS =
[:type, :id, :name, :created_at, :modified_at]
- GROUP_FIELDS_QUERY =
GROUP_FIELDS.join(',')
- BOX_CLIENT =
Read this to see why the httpclient gem was chosen: bibwild.wordpress.com/2012/04/30/ruby-http-performance-shootout-redux/ All instances of Boxr::Client will use this one class instance of HTTPClient; that way persistent HTTPS connections work. Plus, httpclient is thread-safe so we can use the same class instance with multiple instances of Boxr::Client
HTTPClient.new
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#as_user_id ⇒ Object
readonly
Returns the value of attribute as_user_id.
-
#box_client_id ⇒ Object
readonly
Returns the value of attribute box_client_id.
-
#box_client_secret ⇒ Object
readonly
Returns the value of attribute box_client_secret.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
Class Method Summary collapse
Instance Method Summary collapse
-
#add_collaboration(folder_id, accessible_by, role, fields: [], notify: nil) ⇒ Object
make sure ‘role’ value is a string as Box has role values with spaces and dashes; e.g.
- #add_comment_to_file(file_id, message: nil, tagged_message: nil) ⇒ Object
- #add_user_to_group(user_id, group_id, role: nil) ⇒ Object
- #all_users(filter_term: nil, fields: []) ⇒ Object
- #change_comment(comment_id, message) ⇒ Object
- #collaboration(collaboration_id, fields: [], status: nil) ⇒ Object
- #comment(comment_id, fields: []) ⇒ Object
- #copy_file(file_id, parent_id, name: nil) ⇒ Object
- #copy_folder(folder_id, dest_folder_id, name: nil) ⇒ Object
- #create_folder(name, parent_id) ⇒ Object
- #create_group(name) ⇒ Object
- #create_metadata(file_id, metadata, type: :properties) ⇒ Object
- #create_shared_link_for_file(file_id, access: nil, unshared_at: nil, can_download: nil, can_preview: nil) ⇒ Object
- #create_shared_link_for_folder(folder_id, access: nil, unshared_at: nil, can_download: nil, can_preview: nil) ⇒ Object
- #create_task(file_id, action: :review, message: nil, due_at: nil) ⇒ Object
- #create_task_assignment(task_id, assign_to_id: nil, assign_to_login: nil) ⇒ Object
- #create_user(login, name, role: nil, language: nil, is_sync_enabled: nil, job_title: nil, phone: nil, address: nil, space_amount: nil, tracking_codes: nil, can_see_managed_users: nil, is_external_collab_restricted: nil, status: nil, timezone: nil, is_exempt_from_device_limits: nil, is_exempt_from_login_verification: nil) ⇒ Object
- #current_user(fields: []) ⇒ Object (also: #me)
- #delete_comment(comment_id) ⇒ Object
- #delete_file(file_id, if_match: nil) ⇒ Object
- #delete_folder(folder_id, recursive: false, if_match: nil) ⇒ Object
- #delete_group(group_id) ⇒ Object
- #delete_group_membership(membership_id) ⇒ Object
- #delete_metadata(file_id, type: :properties) ⇒ Object
- #delete_old_version_of_file(file_id, file_version_id, if_match: nil) ⇒ Object
- #delete_task(task_id) ⇒ Object
- #delete_task_assignment(task_id) ⇒ Object
- #delete_trashed_file(file_id) ⇒ Object
- #delete_trashed_folder(folder_id) ⇒ Object
- #delete_user(user_id, notify: nil, force: nil) ⇒ Object
- #disable_shared_link_for_file(file_id) ⇒ Object
- #disable_shared_link_for_folder(folder_id) ⇒ Object
- #download_file(file_id, version: nil, follow_redirect: true) ⇒ Object
- #download_url(file_id, version: nil) ⇒ Object
- #edit_collaboration(collaboration_id, role: nil, status: nil) ⇒ Object
- #enterprise_events(stream_position: 0, limit: 100, event_type: nil, created_after: nil, created_before: nil) ⇒ Object
- #file(file_id, fields: []) ⇒ Object
- #file_comments(file_id, fields: []) ⇒ Object
- #file_from_path(path) ⇒ Object
- #file_tasks(file_id, fields: []) ⇒ Object
- #folder(folder_id, fields: []) ⇒ Object
- #folder_collaborations(folder_id) ⇒ Object
- #folder_from_path(path) ⇒ Object
- #folder_items(folder_id, fields: []) ⇒ Object
- #group_collaborations(group_id) ⇒ Object
- #group_membership(membership_id) ⇒ Object
- #group_memberships(group_id) ⇒ Object
- #group_memberships_for_me ⇒ Object
- #group_memberships_for_user(user_id) ⇒ Object
- #groups(fields: []) ⇒ Object
-
#initialize(access_token, refresh_token: nil, box_client_id: , box_client_secret: , identifier: nil, as_user_id: nil, &token_refresh_listener) ⇒ Client
constructor
A new instance of Client.
- #metadata(file_id, type: :properties) ⇒ Object
-
#pending_collaborations ⇒ Object
these are pending collaborations for the current user; use the As-User Header to request for different users.
- #promote_old_version_of_file(file_id, file_version_id) ⇒ Object
- #remove_collaboration(collaboration_id) ⇒ Object
- #reply_to_comment(comment_id, message: nil, tagged_message: nil) ⇒ Object
- #restore_trashed_file(file_id, name: nil, parent_id: nil) ⇒ Object
- #restore_trashed_folder(folder_id, name: nil, parent_id: nil) ⇒ Object
- #root_folder_items(fields: []) ⇒ Object
- #search(query, scope: nil, file_extensions: nil, created_at_range: nil, updated_at_range: nil, size_range: nil, owner_user_ids: nil, ancestor_folder_ids: nil, content_types: nil, type: nil, limit: 30, offset: 0) ⇒ Object
- #shared_item(shared_link, shared_link_password: nil) ⇒ Object
- #task(task_id) ⇒ Object
- #task_assignment(task_id) ⇒ Object
- #task_assignments(task_id) ⇒ Object
- #thumbnail(file_id, min_height: nil, min_width: nil, max_height: nil, max_width: nil) ⇒ Object
- #trash(fields: []) ⇒ Object
- #trashed_file(file_id, fields: []) ⇒ Object
- #trashed_folder(folder_id, fields: []) ⇒ Object
- #update_file(file_id, name: nil, description: nil, parent_id: nil, shared_link: nil, tags: nil, if_match: nil) ⇒ Object
- #update_folder(folder_id, name: nil, description: nil, parent_id: nil, shared_link: nil, folder_upload_email_access: nil, owned_by_id: nil, sync_state: nil, tags: nil, can_non_owners_invite: nil, if_match: nil) ⇒ Object
- #update_group(group_id, name) ⇒ Object (also: #rename_group)
- #update_group_membership(membership_id, role) ⇒ Object
- #update_metadata(file_id, updates, type: :properties) ⇒ Object
- #update_task(task_id, action: :review, message: nil, due_at: nil) ⇒ Object
- #update_task_assignment(task_id, message: nil, resolution_state: nil) ⇒ Object
- #update_user(user_id, notify: nil, enterprise: true, name: nil, role: nil, language: nil, is_sync_enabled: nil, job_title: nil, phone: nil, address: nil, space_amount: nil, tracking_codes: nil, can_see_managed_users: nil, status: nil, timezone: nil, is_exempt_from_device_limits: nil, is_exempt_from_login_verification: nil, is_exempt_from_reset_required: nil, is_external_collab_restricted: nil) ⇒ Object
- #upload_file(path_to_file, parent_id, content_created_at: nil, content_modified_at: nil, preflight_check: true, send_content_md5: true) ⇒ Object
- #upload_new_version_of_file(path_to_file, file_id, content_modified_at: nil, send_content_md5: true, preflight_check: true, if_match: nil) ⇒ Object
- #user(user_id, fields: []) ⇒ Object
- #user_events(stream_position: 0, stream_type: :all, limit: 100) ⇒ Object
- #versions_of_file(file_id) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token: nil, box_client_id: , box_client_secret: , identifier: nil, as_user_id: nil, &token_refresh_listener) ⇒ Client
Returns a new instance of Client.
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/boxr/client.rb', line 69 def initialize(access_token, refresh_token: nil, box_client_id: ENV['BOX_CLIENT_ID'], box_client_secret: ENV['BOX_CLIENT_SECRET'], identifier: nil, as_user_id: nil, &token_refresh_listener) @access_token = access_token @refresh_token = refresh_token @box_client_id = box_client_id @box_client_secret = box_client_secret @identifier = identifier @as_user_id = as_user_id @token_refresh_listener = token_refresh_listener end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/boxr/client.rb', line 5 def access_token @access_token end |
#as_user_id ⇒ Object (readonly)
Returns the value of attribute as_user_id.
5 6 7 |
# File 'lib/boxr/client.rb', line 5 def as_user_id @as_user_id end |
#box_client_id ⇒ Object (readonly)
Returns the value of attribute box_client_id.
5 6 7 |
# File 'lib/boxr/client.rb', line 5 def box_client_id @box_client_id end |
#box_client_secret ⇒ Object (readonly)
Returns the value of attribute box_client_secret.
5 6 7 |
# File 'lib/boxr/client.rb', line 5 def box_client_secret @box_client_secret end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
5 6 7 |
# File 'lib/boxr/client.rb', line 5 def identifier @identifier end |
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token.
5 6 7 |
# File 'lib/boxr/client.rb', line 5 def refresh_token @refresh_token end |
Class Method Details
.turn_off_debugging ⇒ Object
64 65 66 67 |
# File 'lib/boxr/client.rb', line 64 def self.turn_off_debugging BOX_CLIENT.debug_dev = nil BOX_CLIENT.transparent_gzip_decompression = true end |
.turn_on_debugging(device = STDOUT) ⇒ Object
59 60 61 62 |
# File 'lib/boxr/client.rb', line 59 def self.turn_on_debugging(device=STDOUT) BOX_CLIENT.debug_dev = device BOX_CLIENT.transparent_gzip_decompression = false end |
Instance Method Details
#add_collaboration(folder_id, accessible_by, role, fields: [], notify: nil) ⇒ Object
make sure ‘role’ value is a string as Box has role values with spaces and dashes; e.g. ‘previewer uploader’
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/boxr/collaborations.rb', line 11 def add_collaboration(folder_id, accessible_by, role, fields: [], notify: nil) query = build_fields_query(fields, COLLABORATION_FIELDS_QUERY) query[:notify] = :notify unless notify.nil? attributes = {item: {id: folder_id, type: :folder}} attributes[:accessible_by] = accessible_by attributes[:role] = role collaboration, response = post(COLLABORATIONS_URI, attributes, query: query) collaboration end |
#add_comment_to_file(file_id, message: nil, tagged_message: nil) ⇒ Object
11 12 13 |
# File 'lib/boxr/comments.rb', line 11 def add_comment_to_file(file_id, message: nil, tagged_message: nil) add_comment(:file, file_id, , ) end |
#add_user_to_group(user_id, group_id, role: nil) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/boxr/groups.rb', line 52 def add_user_to_group(user_id, group_id, role: nil) attributes = {user: {id: user_id}, group: {id: group_id}} attributes[:role] = role unless role.nil? membership, response = post(GROUP_MEMBERSHIPS_URI, attributes) membership end |
#all_users(filter_term: nil, fields: []) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/boxr/users.rb', line 20 def all_users(filter_term: nil, fields: []) uri = USERS_URI query = build_fields_query(fields, USER_FIELDS_QUERY) query[:filter_term] = filter_term unless filter_term.nil? users = get_with_pagination(uri, query: query) end |
#change_comment(comment_id, message) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/boxr/comments.rb', line 19 def change_comment(comment_id, ) uri = "#{COMMENTS_URI}/#{comment_id}" attributes = {message: } updated_comment, response = put uri, attributes updated_comment end |
#collaboration(collaboration_id, fields: [], status: nil) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/boxr/collaborations.rb', line 39 def collaboration(collaboration_id, fields: [], status: nil) uri = "#{COLLABORATIONS_URI}/#{collaboration_id}" query = build_fields_query(fields, COLLABORATION_FIELDS_QUERY) query[:status] = status unless status.nil? collaboration, response = get(uri, query: query) collaboration end |
#comment(comment_id, fields: []) ⇒ Object
26 27 28 29 30 |
# File 'lib/boxr/comments.rb', line 26 def comment(comment_id, fields: []) uri ="#{COMMENTS_URI}/#{comment_id}" comment, response = get uri comment end |
#copy_file(file_id, parent_id, name: nil) ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/boxr/files.rb', line 132 def copy_file(file_id, parent_id, name: nil) uri = "#{FILES_URI}/#{file_id}/copy" attributes = {:parent => {:id => parent_id}} attributes[:name] = name unless name.nil? new_file, res = post uri, attributes new_file end |
#copy_folder(folder_id, dest_folder_id, name: nil) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/boxr/folders.rb', line 75 def copy_folder(folder_id, dest_folder_id, name: nil) uri = "#{FOLDERS_URI}/#{folder_id}/copy" attributes = {:parent => {:id => dest_folder_id}} attributes[:name] = name unless name.nil? new_folder, response = post uri, attributes new_folder end |
#create_folder(name, parent_id) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/boxr/folders.rb', line 31 def create_folder(name, parent_id) uri = "#{FOLDERS_URI}" attributes = {:name => name, :parent => {:id => parent_id}} created_folder, response = post uri, attributes created_folder end |
#create_group(name) ⇒ Object
9 10 11 12 13 |
# File 'lib/boxr/groups.rb', line 9 def create_group(name) attributes = {name: name} new_group, response = post(GROUPS_URI, attributes) new_group end |
#create_metadata(file_id, metadata, type: :properties) ⇒ Object
4 5 6 7 8 |
# File 'lib/boxr/metadata.rb', line 4 def (file_id, , type: :properties) uri = "#{METADATA_URI}/#{file_id}/metadata/#{type}" , response = post uri, , content_type: "application/json" end |
#create_shared_link_for_file(file_id, access: nil, unshared_at: nil, can_download: nil, can_preview: nil) ⇒ Object
159 160 161 162 |
# File 'lib/boxr/files.rb', line 159 def create_shared_link_for_file(file_id, access: nil, unshared_at: nil, can_download: nil, can_preview: nil) uri = "#{FILES_URI}/#{file_id}" create_shared_link(uri, file_id, access, unshared_at, can_download, can_preview) end |
#create_shared_link_for_folder(folder_id, access: nil, unshared_at: nil, can_download: nil, can_preview: nil) ⇒ Object
84 85 86 87 |
# File 'lib/boxr/folders.rb', line 84 def create_shared_link_for_folder(folder_id, access: nil, unshared_at: nil, can_download: nil, can_preview: nil) uri = "#{FOLDERS_URI}/#{folder_id}" create_shared_link(uri, folder_id, access, unshared_at, can_download, can_preview) end |
#create_task(file_id, action: :review, message: nil, due_at: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/boxr/tasks.rb', line 12 def create_task(file_id, action: :review, message: nil, due_at: nil) attributes = {item: {type: :file, id: file_id}} attributes[:action] = action unless action.nil? attributes[:message] = unless .nil? attributes[:due_at] = due_at.to_datetime.rfc3339 unless due_at.nil? new_task, response = post TASKS_URI, attributes new_task end |
#create_task_assignment(task_id, assign_to_id: nil, assign_to_login: nil) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/boxr/tasks.rb', line 51 def create_task_assignment(task_id, assign_to_id: nil, assign_to_login: nil) attributes = {task: {type: :task, id: "#{task_id}"}} attributes[:assign_to] = {} attributes[:assign_to][:login] = assign_to_login unless assign_to_login.nil? attributes[:assign_to][:id] = assign_to_id unless assign_to_id.nil? new_task_assignment, response = post TASK_ASSIGNMENTS_URI, attributes new_task_assignment end |
#create_user(login, name, role: nil, language: nil, is_sync_enabled: nil, job_title: nil, phone: nil, address: nil, space_amount: nil, tracking_codes: nil, can_see_managed_users: nil, is_external_collab_restricted: nil, status: nil, timezone: nil, is_exempt_from_device_limits: nil, is_exempt_from_login_verification: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/boxr/users.rb', line 27 def create_user(login, name, role: nil, language: nil, is_sync_enabled: nil, job_title: nil, phone: nil, address: nil, space_amount: nil, tracking_codes: nil, can_see_managed_users: nil, is_external_collab_restricted: nil, status: nil, timezone: nil, is_exempt_from_device_limits: nil, is_exempt_from_login_verification: nil) uri = USERS_URI attributes = {login: login, name: name} attributes[:role] = role unless role.nil? attributes[:language] = language unless language.nil? attributes[:is_sync_enabled] = is_sync_enabled unless is_sync_enabled.nil? attributes[:job_title] = job_title unless job_title.nil? attributes[:phone] = phone unless phone.nil? attributes[:address] = address unless address.nil? attributes[:space_amount] = space_amount unless space_amount.nil? attributes[:tracking_codes] = tracking_codes unless tracking_codes.nil? attributes[:can_see_managed_users] = can_see_managed_users unless can_see_managed_users.nil? attributes[:is_external_collab_restricted] = is_external_collab_restricted unless is_external_collab_restricted.nil? attributes[:status] = status unless status.nil? attributes[:timezone] = timezone unless timezone.nil? attributes[:is_exempt_from_device_limits] = is_exempt_from_device_limits unless is_exempt_from_device_limits.nil? attributes[:is_exempt_from_login_verification] = is_exempt_from_login_verification unless is_exempt_from_login_verification.nil? new_user, response = post(uri, attributes) new_user end |
#current_user(fields: []) ⇒ Object Also known as: me
4 5 6 7 8 9 |
# File 'lib/boxr/users.rb', line 4 def current_user(fields: []) uri = "#{USERS_URI}/me" query = build_fields_query(fields, USER_FIELDS_QUERY) user, response = get(uri, query: query) user end |
#delete_comment(comment_id) ⇒ Object
32 33 34 35 36 |
# File 'lib/boxr/comments.rb', line 32 def delete_comment(comment_id) uri = "#{COMMENTS_URI}/#{comment_id}" result, response = delete uri result end |
#delete_file(file_id, if_match: nil) ⇒ Object
88 89 90 91 92 |
# File 'lib/boxr/files.rb', line 88 def delete_file(file_id, if_match: nil) uri = "#{FILES_URI}/#{file_id}" result, response = delete uri, if_match: if_match result end |
#delete_folder(folder_id, recursive: false, if_match: nil) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/boxr/folders.rb', line 67 def delete_folder(folder_id, recursive: false, if_match: nil) uri = "#{FOLDERS_URI}/#{folder_id}" query = {:recursive => recursive} result, response = delete uri, query: query, if_match: if_match result end |
#delete_group(group_id) ⇒ Object
25 26 27 28 29 |
# File 'lib/boxr/groups.rb', line 25 def delete_group(group_id) uri = "#{GROUPS_URI}/#{group_id}" result, response = delete(uri) result end |
#delete_group_membership(membership_id) ⇒ Object
66 67 68 69 70 |
# File 'lib/boxr/groups.rb', line 66 def delete_group_membership(membership_id) uri = "#{GROUP_MEMBERSHIPS_URI}/#{membership_id}" result, response = delete(uri) result end |
#delete_metadata(file_id, type: :properties) ⇒ Object
22 23 24 25 26 |
# File 'lib/boxr/metadata.rb', line 22 def (file_id, type: :properties) uri = "#{METADATA_URI}/#{file_id}/metadata/#{type}" result, response = delete uri result end |
#delete_old_version_of_file(file_id, file_version_id, if_match: nil) ⇒ Object
126 127 128 129 130 |
# File 'lib/boxr/files.rb', line 126 def delete_old_version_of_file(file_id, file_version_id, if_match: nil) uri = "#{FILES_URI}/#{file_id}/versions/#{file_version_id}" result, response = delete uri, if_match: if_match result end |
#delete_task(task_id) ⇒ Object
39 40 41 42 43 |
# File 'lib/boxr/tasks.rb', line 39 def delete_task(task_id) uri = "#{TASKS_URI}/#{task_id}" result, response = delete uri result end |
#delete_task_assignment(task_id) ⇒ Object
68 69 70 71 72 |
# File 'lib/boxr/tasks.rb', line 68 def delete_task_assignment(task_id) uri = "#{TASK_ASSIGNMENTS_URI}/#{task_id}" result, response = delete uri result end |
#delete_trashed_file(file_id) ⇒ Object
177 178 179 180 181 182 |
# File 'lib/boxr/files.rb', line 177 def delete_trashed_file(file_id) uri = "#{FILES_URI}/#{file_id}/trash" result, response = delete uri result end |
#delete_trashed_folder(folder_id) ⇒ Object
109 110 111 112 113 |
# File 'lib/boxr/folders.rb', line 109 def delete_trashed_folder(folder_id) uri = "#{FOLDERS_URI}/#{folder_id}/trash" result, response = delete uri result end |
#delete_user(user_id, notify: nil, force: nil) ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/boxr/users.rb', line 84 def delete_user(user_id, notify: nil, force: nil) uri = "#{USERS_URI}/#{user_id}" query = {} query[:notify] = notify unless notify.nil? query[:force] = force unless force.nil? result, response = delete(uri, query: query) result end |
#disable_shared_link_for_file(file_id) ⇒ Object
164 165 166 167 |
# File 'lib/boxr/files.rb', line 164 def disable_shared_link_for_file(file_id) uri = "#{FILES_URI}/#{file_id}" disable_shared_link(uri, file_id) end |
#disable_shared_link_for_folder(folder_id) ⇒ Object
89 90 91 92 |
# File 'lib/boxr/folders.rb', line 89 def disable_shared_link_for_folder(folder_id) uri = "#{FOLDERS_URI}/#{folder_id}" disable_shared_link(uri, folder_id) end |
#download_file(file_id, version: nil, follow_redirect: true) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/boxr/files.rb', line 41 def download_file(file_id, version: nil, follow_redirect: true) begin uri = "#{FILES_URI}/#{file_id}/content" query = {} query[:version] = version unless version.nil? body_json, response = get uri, query: query, success_codes: [302,202] if(response.status==302) location = response.header['Location'][0] if(follow_redirect) file, response = get location, process_response: false else return location #simply return the url end elsif(response.status==202) retry_after_seconds = response.header['Retry-After'][0] sleep retry_after_seconds.to_i end end until file file end |
#download_url(file_id, version: nil) ⇒ Object
65 66 67 |
# File 'lib/boxr/files.rb', line 65 def download_url(file_id, version: nil) download_file(file_id, version: version, follow_redirect: false) end |
#edit_collaboration(collaboration_id, role: nil, status: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/boxr/collaborations.rb', line 23 def edit_collaboration(collaboration_id, role: nil, status: nil) uri = "#{COLLABORATIONS_URI}/#{collaboration_id}" attributes = {} attributes[:role] = role unless role.nil? attributes[:status] = status unless status.nil? updated_collaboration, response = put(uri, attributes) updated_collaboration end |
#enterprise_events(stream_position: 0, limit: 100, event_type: nil, created_after: nil, created_before: nil) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/boxr/events.rb', line 11 def enterprise_events(stream_position: 0, limit: 100, event_type: nil, created_after: nil, created_before: nil) query = {stream_position: stream_position, stream_type: :admin_logs, limit: limit} query['event_type'] = event_type unless event_type.nil? query['created_after'] = created_after.to_datetime.rfc3339 unless created_after.nil? query['created_before'] = created_before.to_datetime.rfc3339 unless created_before.nil? events, response = get(EVENTS_URI, query: query) Hashie::Mash.new({events: events["entries"], chunk_size: events["chunk_size"], next_stream_position: events["next_stream_position"]}) end |
#file(file_id, fields: []) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/boxr/files.rb', line 20 def file(file_id, fields: []) uri = "#{FILES_URI}/#{file_id}" query = build_fields_query(fields, FOLDER_AND_FILE_FIELDS_QUERY) file, response = get uri, query: query file end |
#file_comments(file_id, fields: []) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/boxr/comments.rb', line 4 def file_comments(file_id, fields: []) uri = "#{FILES_URI}/#{file_id}/comments" query = build_fields_query(fields, COMMENT_FIELDS_QUERY) comments = get_with_pagination uri, query: query end |
#file_from_path(path) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/boxr/files.rb', line 4 def file_from_path(path) if(path.start_with?('/')) path = path.slice(1..-1) end path_items = path.split('/') file_name = path_items.slice!(-1) folder = folder_from_path(path_items.join('/')) files = folder_items(folder.id, fields: [:id, :name]).files file = files.select{|f| f.name == file_name}.first raise BoxrException.new(boxr_message: "File not found: '#{file_name}'") if file.nil? file end |
#file_tasks(file_id, fields: []) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/boxr/tasks.rb', line 4 def file_tasks(file_id, fields: []) uri = "#{FILES_URI}/#{file_id}/tasks" query = build_fields_query(fields, TASK_FIELDS_QUERY) tasks, response = get uri, query: query tasks["entries"] end |
#folder(folder_id, fields: []) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/boxr/folders.rb', line 39 def folder(folder_id, fields: []) query = build_fields_query(fields, FOLDER_AND_FILE_FIELDS_QUERY) uri = "#{FOLDERS_URI}/#{folder_id}" folder, response = get uri, query: query folder end |
#folder_collaborations(folder_id) ⇒ Object
4 5 6 7 8 |
# File 'lib/boxr/collaborations.rb', line 4 def folder_collaborations(folder_id) uri = "#{FOLDERS_URI}/#{folder_id}/collaborations" collaborations, response = get(uri) collaborations['entries'] end |
#folder_from_path(path) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/boxr/folders.rb', line 4 def folder_from_path(path) if(path.start_with?('/')) path = path.slice(1..-1) end path_folders = path.split('/') root_folder = Hashie::Mash.new({id: Boxr::ROOT}) folder = path_folders.inject(root_folder) do |parent_folder, folder_name| folders = folder_items(parent_folder.id, fields: [:id, :name]).folders folder = folders.select{|f| f.name == folder_name}.first raise BoxrException.new(boxr_message: "Folder not found: '#{folder_name}'") if folder.nil? folder end end |
#folder_items(folder_id, fields: []) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/boxr/folders.rb', line 20 def folder_items(folder_id, fields: []) query = build_fields_query(fields, FOLDER_AND_FILE_FIELDS_QUERY) uri = "#{FOLDERS_URI}/#{folder_id}/items" items = get_with_pagination uri, query: query, limit: FOLDER_ITEMS_LIMIT end |
#group_collaborations(group_id) ⇒ Object
72 73 74 75 |
# File 'lib/boxr/groups.rb', line 72 def group_collaborations(group_id) uri = "#{GROUPS_URI}/#{group_id}/collaborations" collaborations = get_with_pagination(uri) end |
#group_membership(membership_id) ⇒ Object
46 47 48 49 50 |
# File 'lib/boxr/groups.rb', line 46 def group_membership(membership_id) uri = "#{GROUP_MEMBERSHIPS_URI}/#{membership_id}" membership, response = get(uri) membership end |
#group_memberships(group_id) ⇒ Object
31 32 33 34 |
# File 'lib/boxr/groups.rb', line 31 def group_memberships(group_id) uri = "#{GROUPS_URI}/#{group_id}/memberships" memberships = get_with_pagination(uri) end |
#group_memberships_for_me ⇒ Object
41 42 43 44 |
# File 'lib/boxr/groups.rb', line 41 def group_memberships_for_me uri = "#{USERS_URI}/me/memberships" memberships = get_with_pagination(uri) end |
#group_memberships_for_user(user_id) ⇒ Object
36 37 38 39 |
# File 'lib/boxr/groups.rb', line 36 def group_memberships_for_user(user_id) uri = "#{USERS_URI}/#{user_id}/memberships" memberships = get_with_pagination(uri) end |
#groups(fields: []) ⇒ Object
4 5 6 7 |
# File 'lib/boxr/groups.rb', line 4 def groups(fields: []) query = build_fields_query(fields, GROUP_FIELDS_QUERY) groups = get_with_pagination(GROUPS_URI, query: query) end |
#metadata(file_id, type: :properties) ⇒ Object
10 11 12 13 14 |
# File 'lib/boxr/metadata.rb', line 10 def (file_id, type: :properties) uri = "#{METADATA_URI}/#{file_id}/metadata/#{type}" , response = get uri end |
#pending_collaborations ⇒ Object
these are pending collaborations for the current user; use the As-User Header to request for different users
50 51 52 53 54 |
# File 'lib/boxr/collaborations.rb', line 50 def pending_collaborations query = {status: :pending} pending_collaborations, response = get(COLLABORATIONS_URI, query: query) pending_collaborations['entries'] end |
#promote_old_version_of_file(file_id, file_version_id) ⇒ Object
119 120 121 122 123 124 |
# File 'lib/boxr/files.rb', line 119 def promote_old_version_of_file(file_id, file_version_id) uri = "#{FILES_URI}/#{file_id}/versions/current" attributes = {:type => 'file_version', :id => file_version_id} new_version, res = post uri, attributes new_version end |
#remove_collaboration(collaboration_id) ⇒ Object
33 34 35 36 37 |
# File 'lib/boxr/collaborations.rb', line 33 def remove_collaboration(collaboration_id) uri = "#{COLLABORATIONS_URI}/#{collaboration_id}" result, response = delete(uri) result end |
#reply_to_comment(comment_id, message: nil, tagged_message: nil) ⇒ Object
15 16 17 |
# File 'lib/boxr/comments.rb', line 15 def reply_to_comment(comment_id, message: nil, tagged_message: nil) add_comment(:comment, comment_id, , ) end |
#restore_trashed_file(file_id, name: nil, parent_id: nil) ⇒ Object
184 185 186 187 |
# File 'lib/boxr/files.rb', line 184 def restore_trashed_file(file_id, name: nil, parent_id: nil) uri = "#{FILES_URI}/#{file_id}" restore_trashed_item(uri, name, parent_id) end |
#restore_trashed_folder(folder_id, name: nil, parent_id: nil) ⇒ Object
115 116 117 118 |
# File 'lib/boxr/folders.rb', line 115 def restore_trashed_folder(folder_id, name: nil, parent_id: nil) uri = "#{FOLDERS_URI}/#{folder_id}" restore_trashed_item(uri, name, parent_id) end |
#root_folder_items(fields: []) ⇒ Object
27 28 29 |
# File 'lib/boxr/folders.rb', line 27 def root_folder_items(fields: []) folder_items(Boxr::ROOT, fields: fields) end |
#search(query, scope: nil, file_extensions: nil, created_at_range: nil, updated_at_range: nil, size_range: nil, owner_user_ids: nil, ancestor_folder_ids: nil, content_types: nil, type: nil, limit: 30, offset: 0) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/boxr/search.rb', line 4 def search(query, scope: nil, file_extensions: nil, created_at_range: nil, updated_at_range: nil, size_range: nil, owner_user_ids: nil, ancestor_folder_ids: nil, content_types: nil, type: nil, limit: 30, offset: 0) query = {query: query} query[:scope] = scope unless scope.nil? query[:file_extensions] = file_extensions unless file_extensions.nil? query[:created_at_range] = created_at_range unless created_at_range.nil? query[:updated_at_range] = updated_at_range unless updated_at_range.nil? query[:size_range] = size_range unless size_range.nil? query[:owner_user_ids] = owner_user_ids unless owner_user_ids.nil? query[:ancestor_folder_ids] = ancestor_folder_ids unless ancestor_folder_ids.nil? query[:content_types] = content_types unless content_types.nil? query[:type] = type unless type.nil? query[:limit] = limit unless limit.nil? query[:offset] = offset unless offset.nil? results, response = get SEARCH_URI, query: query results["entries"] end |
#shared_item(shared_link, shared_link_password: nil) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/boxr/shared_items.rb', line 4 def shared_item(shared_link, shared_link_password: nil) box_api_header = "shared_link=#{shared_link}" box_api_header += "&shared_link_password=#{shared_link_password}" unless shared_link_password.nil? file_or_folder, response = get(SHARED_ITEMS_URI, box_api_header: box_api_header) file_or_folder end |
#task(task_id) ⇒ Object
22 23 24 25 26 |
# File 'lib/boxr/tasks.rb', line 22 def task(task_id) uri = "#{TASKS_URI}/#{task_id}" task, response = get uri task end |
#task_assignment(task_id) ⇒ Object
62 63 64 65 66 |
# File 'lib/boxr/tasks.rb', line 62 def task_assignment(task_id) uri = "#{TASK_ASSIGNMENTS_URI}/#{task_id}" task_assignment, response = get uri task_assignment end |
#task_assignments(task_id) ⇒ Object
45 46 47 48 49 |
# File 'lib/boxr/tasks.rb', line 45 def task_assignments(task_id) uri = "#{TASKS_URI}/#{task_id}/assignments" assignments, response = get uri assignments['entries'] end |
#thumbnail(file_id, min_height: nil, min_width: nil, max_height: nil, max_width: nil) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/boxr/files.rb', line 140 def thumbnail(file_id, min_height: nil, min_width: nil, max_height: nil, max_width: nil) uri = "#{FILES_URI}/#{file_id}/thumbnail.png" query = {} query[:min_height] = min_height unless min_height.nil? query[:min_width] = min_width unless min_width.nil? query[:max_height] = max_height unless max_height.nil? query[:max_width] = max_width unless max_width.nil? body, response = get uri, query: query, success_codes: [302,202,200], process_response: false if(response.status==202 || response.status==302) location = response.header['Location'][0] thumbnail, response = get location, process_response: false else #200 thumbnail = body end thumbnail end |
#trash(fields: []) ⇒ Object
94 95 96 97 98 99 |
# File 'lib/boxr/folders.rb', line 94 def trash(fields: []) uri = "#{FOLDERS_URI}/trash/items" query = build_fields_query(fields, FOLDER_AND_FILE_FIELDS_QUERY) items = get_with_pagination uri, query: query, limit: FOLDER_ITEMS_LIMIT end |
#trashed_file(file_id, fields: []) ⇒ Object
169 170 171 172 173 174 175 |
# File 'lib/boxr/files.rb', line 169 def trashed_file(file_id, fields: []) uri = "#{FILES_URI}/#{file_id}/trash" query = build_fields_query(fields, FOLDER_AND_FILE_FIELDS_QUERY) trashed_file, response = get uri, query: query trashed_file end |
#trashed_folder(folder_id, fields: []) ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/boxr/folders.rb', line 101 def trashed_folder(folder_id, fields: []) uri = "#{FOLDERS_URI}/#{folder_id}/trash" query = build_fields_query(fields, FOLDER_AND_FILE_FIELDS_QUERY) folder, response = get uri, query: query folder end |
#update_file(file_id, name: nil, description: nil, parent_id: nil, shared_link: nil, tags: nil, if_match: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/boxr/files.rb', line 27 def update_file(file_id, name: nil, description: nil, parent_id: nil, shared_link: nil, tags: nil, if_match: nil) uri = "#{FILES_URI}/#{file_id}" attributes = {} attributes[:name] = name unless name.nil? attributes[:description] = description unless description.nil? attributes[:parent_id] = {id: parent_id} unless parent_id.nil? attributes[:shared_link] = shared_link unless shared_link.nil? attributes[:tags] = unless .nil? updated_file, response = put uri, attributes, if_match: if_match updated_file end |
#update_folder(folder_id, name: nil, description: nil, parent_id: nil, shared_link: nil, folder_upload_email_access: nil, owned_by_id: nil, sync_state: nil, tags: nil, can_non_owners_invite: nil, if_match: nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/boxr/folders.rb', line 47 def update_folder(folder_id, name: nil, description: nil, parent_id: nil, shared_link: nil, folder_upload_email_access: nil, owned_by_id: nil, sync_state: nil, tags: nil, can_non_owners_invite: nil, if_match: nil) uri = "#{FOLDERS_URI}/#{folder_id}" attributes = {} attributes[:name] = name unless name.nil? attributes[:description] = description unless description.nil? attributes[:parent_id] = {id: parent_id} unless parent_id.nil? attributes[:shared_link] = shared_link unless shared_link.nil? attributes[:folder_upload_email] = {access: folder_upload_email_access} unless folder_upload_email_access.nil? attributes[:owned_by_id] = {owned_by: owned_by_id} unless owned_by_id.nil? attributes[:sync_state] = sync_state unless sync_state.nil? attributes[:tags] = unless .nil? attributes[:can_non_owners_invite] = can_non_owners_invite unless can_non_owners_invite.nil? updated_folder, response = put uri, attributes, if_match: if_match updated_folder end |
#update_group(group_id, name) ⇒ Object Also known as: rename_group
15 16 17 18 19 20 21 |
# File 'lib/boxr/groups.rb', line 15 def update_group(group_id, name) uri = "#{GROUPS_URI}/#{group_id}" attributes = {name: name} updated_group, response = put(uri, attributes) updated_group end |
#update_group_membership(membership_id, role) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/boxr/groups.rb', line 59 def update_group_membership(membership_id, role) uri = "#{GROUP_MEMBERSHIPS_URI}/#{membership_id}" attributes = {role: role} updated_membership, response = put(uri, attributes) updated_membership end |
#update_metadata(file_id, updates, type: :properties) ⇒ Object
16 17 18 19 20 |
# File 'lib/boxr/metadata.rb', line 16 def (file_id, updates, type: :properties) uri = "#{METADATA_URI}/#{file_id}/metadata/#{type}" , response = put uri, updates, content_type: "application/json-patch+json" end |
#update_task(task_id, action: :review, message: nil, due_at: nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/boxr/tasks.rb', line 28 def update_task(task_id, action: :review, message: nil, due_at: nil) uri = "#{TASKS_URI}/#{task_id}" attributes = {} attributes[:action] = action unless action.nil? attributes[:message] = unless .nil? attributes[:due_at] = due_at.to_datetime.rfc3339 unless due_at.nil? task, response = put uri, attributes task end |
#update_task_assignment(task_id, message: nil, resolution_state: nil) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/boxr/tasks.rb', line 74 def update_task_assignment(task_id, message: nil, resolution_state: nil) uri = "#{TASK_ASSIGNMENTS_URI}/#{task_id}" attributes = {} attributes[:message] = unless .nil? attributes[:resolution_state] = resolution_state unless resolution_state.nil? updated_task, response = put uri, attributes updated_task end |
#update_user(user_id, notify: nil, enterprise: true, name: nil, role: nil, language: nil, is_sync_enabled: nil, job_title: nil, phone: nil, address: nil, space_amount: nil, tracking_codes: nil, can_see_managed_users: nil, status: nil, timezone: nil, is_exempt_from_device_limits: nil, is_exempt_from_login_verification: nil, is_exempt_from_reset_required: nil, is_external_collab_restricted: nil) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/boxr/users.rb', line 53 def update_user(user_id, notify: nil, enterprise: true, name: nil, role: nil, language: nil, is_sync_enabled: nil, job_title: nil, phone: nil, address: nil, space_amount: nil, tracking_codes: nil, can_see_managed_users: nil, status: nil, timezone: nil, is_exempt_from_device_limits: nil, is_exempt_from_login_verification: nil, is_exempt_from_reset_required: nil, is_external_collab_restricted: nil) uri = "#{USERS_URI}/#{user_id}" query = {notify: notify} unless notify.nil? attributes = {} attributes[:enterprise] = nil if enterprise.nil? #this is a special condition where setting this to nil means to roll this user out of the enterprise attributes[:name] = name unless name.nil? attributes[:role] = role unless role.nil? attributes[:language] = language unless language.nil? attributes[:is_sync_enabled] = is_sync_enabled unless is_sync_enabled.nil? attributes[:job_title] = job_title unless job_title.nil? attributes[:phone] = phone unless phone.nil? attributes[:address] = address unless address.nil? attributes[:space_amount] = space_amount unless space_amount.nil? attributes[:tracking_codes] = tracking_codes unless tracking_codes.nil? attributes[:can_see_managed_users] = can_see_managed_users unless can_see_managed_users.nil? attributes[:status] = status unless status.nil? attributes[:timezone] = timezone unless timezone.nil? attributes[:is_exempt_from_device_limits] = is_exempt_from_device_limits unless is_exempt_from_device_limits.nil? attributes[:is_exempt_from_login_verification] = is_exempt_from_login_verification unless is_exempt_from_login_verification.nil? attributes[:is_exempt_from_reset_required] = is_exempt_from_reset_required unless is_exempt_from_reset_required.nil? attributes[:is_external_collab_restricted] = is_external_collab_restricted unless is_external_collab_restricted.nil? updated_user, response = put(uri, attributes, query: query) updated_user end |
#upload_file(path_to_file, parent_id, content_created_at: nil, content_modified_at: nil, preflight_check: true, send_content_md5: true) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/boxr/files.rb', line 69 def upload_file(path_to_file, parent_id, content_created_at: nil, content_modified_at: nil, preflight_check: true, send_content_md5: true) preflight_check(path_to_file, parent_id) if preflight_check file_info = nil response = nil File.open(path_to_file) do |file| content_md5 = send_content_md5 ? Digest::SHA1.file(file).hexdigest : nil attributes = {filename: file, parent_id: parent_id} attributes[:content_created_at] = content_created_at.to_datetime.rfc3339 unless content_created_at.nil? attributes[:content_modified_at] = content_modified_at.to_datetime.rfc3339 unless content_modified_at.nil? file_info, response = post FILES_UPLOAD_URI, attributes, process_body: false, content_md5: content_md5 end file_info["entries"][0] end |
#upload_new_version_of_file(path_to_file, file_id, content_modified_at: nil, send_content_md5: true, preflight_check: true, if_match: nil) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/boxr/files.rb', line 94 def upload_new_version_of_file(path_to_file, file_id, content_modified_at: nil, send_content_md5: true, preflight_check: true, if_match: nil) preflight_check_new_version_of_file(path_to_file, file_id) if preflight_check uri = "#{UPLOAD_URI}/files/#{file_id}/content" file_info = nil response = nil File.open(path_to_file) do |file| content_md5 = send_content_md5 ? Digest::SHA1.file(file).hexdigest : nil attributes = {filename: file} attributes[:content_modified_at] = content_modified_at.to_datetime.rfc3339 unless content_modified_at.nil? file_info, response = post uri, attributes, process_body: false, content_md5: content_md5, if_match: if_match end file_info["entries"][0] end |
#user(user_id, fields: []) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/boxr/users.rb', line 13 def user(user_id, fields: []) uri = "#{USERS_URI}/#{user_id}" query = build_fields_query(fields, USER_FIELDS_QUERY) user, response = get(uri, query: query) user end |
#user_events(stream_position: 0, stream_type: :all, limit: 100) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/boxr/events.rb', line 4 def user_events(stream_position: 0, stream_type: :all, limit: 100) query = {stream_position: stream_position, stream_type: stream_type, limit: limit} events, response = get(EVENTS_URI, query: query) Hashie::Mash.new({events: events["entries"], chunk_size: events["chunk_size"], next_stream_position: events["next_stream_position"]}) end |
#versions_of_file(file_id) ⇒ Object
113 114 115 116 117 |
# File 'lib/boxr/files.rb', line 113 def versions_of_file(file_id) uri = "#{FILES_URI}/#{file_id}/versions" versions, response = get uri versions["entries"] end |