private long AttachFileAndUrlToSheet(SmartsheetClient smartsheet, long sheetId) { Attachment attachToResource = new Attachment.CreateAttachmentBuilder("http://www.smartsheet.com", AttachmentType.LINK).Build(); Attachment attachment = smartsheet.SheetResources.AttachmentResources.AttachUrl(sheetId, attachToResource); Assert.IsTrue(attachment.Url == "http://www.smartsheet.com"); attachment = smartsheet.SheetResources.AttachmentResources.AttachFile(sheetId, path, null); Assert.IsTrue(attachment.AttachmentType == AttachmentType.FILE); Assert.IsTrue(attachment.Name == "TestFile.txt"); return attachment.Id.Value; }
private long AttachFileAndUrlToComment(SmartsheetClient smartsheet, long sheetId) { Discussion discussionToCreate = new Discussion.CreateDiscussionBuilder("A Disc", new Comment.AddCommentBuilder("A comm").Build()).Build(); Discussion discussionCreated = smartsheet.SheetResources.DiscussionResources.CreateDiscussion(sheetId, discussionToCreate); long commentId = discussionCreated.Comments[0].Id.Value; Attachment attachment = smartsheet.SheetResources.CommentResources.AttachmentResources.AttachFile(sheetId, commentId, path, "text/plain"); Assert.IsTrue(attachment.AttachmentType == AttachmentType.FILE); Assert.IsTrue(attachment.Name == "TestFile.txt"); Attachment attachToResource = new Attachment.CreateAttachmentBuilder("http://www.google.com", AttachmentType.LINK).Build(); attachment = smartsheet.SheetResources.CommentResources.AttachmentResources.AttachUrl(sheetId, commentId, attachToResource); Assert.IsTrue(attachment.Url == "http://www.google.com"); return discussionCreated.Id.Value; }
private long AttachFileAndUrlToRow(SmartsheetClient smartsheet, long sheetId) { Row[] rows = new Row[] { new Row.AddRowBuilder(true, null, null, null, null).Build() }; smartsheet.SheetResources.RowResources.AddRows(sheetId, rows); Sheet sheet = smartsheet.SheetResources.GetSheet(sheetId, null, null, null, null, null, null, null); long rowId = sheet.Rows[0].Id.Value; Attachment attachment = smartsheet.SheetResources.RowResources.AttachmentResources.AttachFile(sheetId, rowId, path, null); Assert.IsTrue(attachment.AttachmentType == AttachmentType.FILE); Assert.IsTrue(attachment.Name == "TestFile.txt"); Attachment attachToResource = new Attachment.CreateAttachmentBuilder("http://www.bing.com", AttachmentType.LINK).Build(); attachment = smartsheet.SheetResources.RowResources.AttachmentResources.AttachUrl(sheetId, rowId, attachToResource); Assert.IsTrue(attachment.Url == "http://www.bing.com"); return rowId; }