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); }
public virtual void TestAttachUrl() { server.setResponseBody("../../../TestSDK/resources/attachUrl.json"); Attachment attachment = new Attachment.CreateAttachmentBuilder("http://www.google.com", AttachmentType.LINK) .SetName("Search Engine").SetDescription("A popular search engine").Build(); Attachment newAttachment = sheetAttachmentResource.AttachUrl(56545654, attachment); Assert.IsTrue(newAttachment.AttachmentType == AttachmentType.LINK); Assert.IsTrue(newAttachment.CreatedAt.Value.ToUniversalTime() == DateTime.Parse("2013-02-28T21:52:40-08:00").ToUniversalTime()); Assert.IsTrue(newAttachment.Id == 1205473673275268); Assert.IsTrue(newAttachment.Description == "A popular search engine"); Assert.IsTrue(newAttachment.Name == "Search Engine"); Assert.IsTrue(newAttachment.Url == "http://google.com"); }
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); }