public void SetPermissions(IPlatformPermissions attributes) { var client = new RestClient(Host.Url, Session.Cookies); client.AddParameter("permission[can_access_anonymously]", attributes.CanAccessAnonymously.ToString().ToLower()); client.AddParameter("permission[can_invite_with_link]", attributes.CanInvite.ToString().ToLower()); client.AddParameter("permission[can_download_original]", attributes.CanDownload.ToString().ToLower()); client.AddParameter("permission[can_upload_changes]", attributes.CanUploadChanges.ToString().ToLower()); client.AddParameter("permission[can_manipulate]", attributes.CanManipulate.ToString().ToLower()); client.AddParameter("permission[inherits_from_parent]", attributes.InheritsFromParent.ToString().ToLower()); client.Put(string.Format("/api/v1.2/folders/{0}/permission.json", Id)); var client2 = new RestClient(Host.Url, Session.Cookies); client2.AddParameter("folder[notify_owner]", attributes.NotifyOwner.ToString().ToLower()); if (attributes.ExpiryDate.HasValue && attributes.ExpiryDate.Value.Year < 9999 && attributes.ExpiryDate.Value.Year > 1) { // Also add this expiry date. var expiry = attributes.ExpiryDate.Value.ToString("yyyy-MM-dd HH:mm:ss UTC"); client2.AddParameter("folder[expires_at]", expiry); } else { client2.AddParameter("folder[expires_at]", ""); } client2.Put(string.Format("/api/v1.2/folders/{0}.json", Id)); }
public IPlatformFolder Create(string name, string parentId, IPlatformPermissions attributes) { var client = new RestClient(Host.Url, Session.Cookies); client.AddParameter("folder[name]", name); client.AddParameter("folder[description]", ""); client.AddParameter("folder[notify_owner]", attributes.NotifyOwner.ToString()); client.AddParameter("folder[parent_id]", parentId); client.AddParameter("rewrite_folder_ids", "false"); if (attributes.ExpiryDate.HasValue && attributes.ExpiryDate.Value.Year < 9999 && attributes.ExpiryDate.Value.Year > 1) { client.AddParameter("folder[expires_at]", attributes.ExpiryDate.Value.ToString("yyyy-MM-dd HH:mm:ss UTC")); } client.Post("/api/v1.2/folders.json"); return new PlatformFolder(Session, User, null, client.Content); }