-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
181 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
source/src/Slackbot.Net.SlackClients.Http/Models/Requests/FileUpload/FileUploadRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace Slackbot.Net.SlackClients.Http.Models.Requests.FileUpload; | ||
|
||
public class FileUploadRequest | ||
{ | ||
public string Channels { get; set; } | ||
public string Content { get; set; } | ||
public string Filename { get; set; } | ||
public string Filetype { get; set; } | ||
public string Initial_Comment { get; set; } | ||
public string Thread_Ts { get; set; } | ||
public string Title { get; set; } | ||
} | ||
|
||
public class FileUploadMultiPartRequest | ||
{ | ||
public string Channels { get; set; } | ||
public Byte[] File { get; set; } | ||
public string Filename { get; set; } | ||
public string Filetype { get; set; } | ||
public string Initial_Comment { get; set; } | ||
public string Thread_Ts { get; set; } | ||
public string Title { get; set; } | ||
} |
18 changes: 18 additions & 0 deletions
18
source/src/Slackbot.Net.SlackClients.Http/Models/Responses/FileUpload/FileUploadResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace Slackbot.Net.SlackClients.Http.Models.Responses.FileUpload; | ||
|
||
public class FileUploadResponse : Response | ||
{ | ||
public FileUploadFile File { get; set; } | ||
} | ||
|
||
public class FileUploadFile | ||
{ | ||
public string Id { get; set; } | ||
public int Created { get; set; } | ||
public string Name { get; set; } | ||
public string Title { get; set; } | ||
public string FileType { get; set; } | ||
public string Pretty_Type { get; set; } | ||
public string User { get; set; } | ||
public bool Is_Public { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
source/test/Slackbot.Net.SlackClients.Http.Tests/FileUploadTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Slackbot.Net.SlackClients.Http.Models.Requests.FileUpload; | ||
using Slackbot.Net.Tests.Helpers; | ||
|
||
namespace Slackbot.Net.Tests | ||
{ | ||
public class FileUploadTests : Setup | ||
{ | ||
public FileUploadTests(ITestOutputHelper helper) : base(helper) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task FilesUploadTests() | ||
{ | ||
var response = await SlackClient.FilesUpload(new FileUploadRequest | ||
{ | ||
Channels = $"{Channel}", | ||
Title = "Man in field", | ||
Initial_Comment = "My initial comment!", | ||
Content = "https://assets3.thrillist.com/v1/image/1682388/size/tl-horizontal_main.jpg", | ||
Filename = "heisann.jpg", | ||
Filetype = "jpg" | ||
}); | ||
|
||
Assert.True(response.Ok); | ||
} | ||
|
||
[Fact] | ||
public async Task FilesUploadFileTests() | ||
{ | ||
var bytes = Convert.FromBase64String(File.ReadAllText("./Helpers/ImageBase64Encoded.txt")); | ||
var response = await SlackClient.FilesUpload(new FileUploadMultiPartRequest | ||
{ | ||
Channels = $"{Channel}", | ||
Title = "Man holding beer", | ||
File = bytes, | ||
Filename = "beer.png", | ||
Filetype = "png" | ||
}); | ||
|
||
Assert.True(response.Ok); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
source/test/Slackbot.Net.SlackClients.Http.Tests/Helpers/ImageBase64Encoded.txt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters