Skip to content

Commit

Permalink
Added final changes for 1.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dentolos19 committed Jul 19, 2021
1 parent a8465cb commit 7241faf
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 17 deletions.
6 changes: 3 additions & 3 deletions PasteMystNet.Tests/Operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace PasteMystNet.Tests
internal static class Operations
{

private static PasteMystAuth? AuthToken { get; }
private static PasteMystToken? AuthToken { get; }
private static PasteMystPasteForm TemplateForm { get; } = new()
{
Title = "PasteMyst.NET",
Expand Down Expand Up @@ -98,12 +98,12 @@ public static void DeletePasteTest()
[Test]
public static async Task LanguageDataTest()
{
var identifyPart1 = await PasteMystLanguage.IdentifyByExtensionAsync("cs");
var identifyPart1 = await PasteMystLanguage.GetLanguageByExtensionAsync("cs");
Assert.IsNotNull(identifyPart1);
Console.WriteLine("=====> IDENTITY PART 1 <=====");
Console.WriteLine(ObjectDumper.Dump(identifyPart1));
Console.WriteLine();
var identifyPart2 = await PasteMystLanguage.IdentifyByNameAsync("C#");
var identifyPart2 = await PasteMystLanguage.GetLanguageByNameAsync("C#");
Assert.IsNotNull(identifyPart2);
Console.WriteLine("=====> IDENTIFY PART 2 <=====");
Console.WriteLine(ObjectDumper.Dump(identifyPart2));
Expand Down
2 changes: 1 addition & 1 deletion PasteMystNet/PasteMystEditForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal PasteMystEditForm(PasteMystPaste paste)
[JsonProperty(PropertyName = "pasties")] public IList<PasteMystPastyForm>? Pasties { get; set; }
[JsonIgnore] public IList<string>? Tags { get; set; } = new List<string>();

public async Task<PasteMystPaste?> PatchPasteAsync(PasteMystAuth auth)
public async Task<PasteMystPaste?> PatchPasteAsync(PasteMystToken auth)
{
if (Pasties is not { Count: > 0 })
throw new Exception($"{nameof(Pasties)} must not be null or empty.");
Expand Down
9 changes: 6 additions & 3 deletions PasteMystNet/PasteMystLanguage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class PasteMystLanguage
[JsonProperty(PropertyName = "ext")] public string[] Extensions { get; private set; }
[JsonProperty(PropertyName = "color")] public string ColorHex { get; private set; }
[JsonIgnore] public Color Color => Utilities.ParseColor(ColorHex);
public static async Task<PasteMystLanguage?> IdentifyByNameAsync(string name)

public static async Task<PasteMystLanguage?> GetLanguageByNameAsync(string name)
{
var response = await Constants.HttpClient.GetAsync(string.Format(Constants.IdentifyByNameEndpoint, Uri.EscapeDataString(name)));
if (response.StatusCode != HttpStatusCode.OK)
Expand All @@ -27,14 +27,17 @@ public class PasteMystLanguage
return JsonConvert.DeserializeObject<PasteMystLanguage>(content);
}

public static async Task<PasteMystLanguage?> IdentifyByExtensionAsync(string extension)
public static async Task<PasteMystLanguage?> GetLanguageByExtensionAsync(string extension)
{
var response = await Constants.HttpClient.GetAsync(string.Format(Constants.IdentifyByExtensionEndpoint, Uri.EscapeDataString(extension)));
if (response.StatusCode != HttpStatusCode.OK)
return null;
var content = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<PasteMystLanguage>(content);
}

[Obsolete] public static async Task<PasteMystLanguage?> IdentifyByNameAsync(string name) { return await GetLanguageByNameAsync(name); }
[Obsolete] public static async Task<PasteMystLanguage?> IdentifyByExtensionAsync(string extension) { return await GetLanguageByExtensionAsync(extension); }

public override string ToString()
{
Expand Down
2 changes: 1 addition & 1 deletion PasteMystNet/PasteMystNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageIcon>Icon.png</PackageIcon>
<Product>PasteMyst.NET</Product>
<Authors>Dennise Catolos</Authors>
<Version>1.1.5</Version>
<Version>1.1.6</Version>
<Copyright>Copyright © 2021</Copyright>
<Description>A simple .NET API wrapper for PasteMyst!</Description>

Expand Down
4 changes: 2 additions & 2 deletions PasteMystNet/PasteMystPaste.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public PasteMystEditForm CreateEditForm()
return new(this);
}

public static async Task<PasteMystPaste?> GetPasteAsync(string id, PasteMystAuth? auth = null)
public static async Task<PasteMystPaste?> GetPasteAsync(string id, PasteMystToken? auth = null)
{
try
{
Expand Down Expand Up @@ -68,7 +68,7 @@ public PasteMystEditForm CreateEditForm()
}
}

public static async Task DeletePasteAsync(string id, PasteMystAuth auth)
public static async Task DeletePasteAsync(string id, PasteMystToken auth)
{
try
{
Expand Down
2 changes: 1 addition & 1 deletion PasteMystNet/PasteMystPasteForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class PasteMystPasteForm
[JsonProperty(PropertyName = "expiresIn")] public string ExpireDuration { get; set; } = PasteMystExpirations.Never;
[JsonIgnore] public IList<string>? Tags { get; set; } = new List<string>();

public async Task<PasteMystPaste?> PostPasteAsync(PasteMystAuth? auth = null)
public async Task<PasteMystPaste?> PostPasteAsync(PasteMystToken? auth = null)
{
if ((IsPrivate || IsPublic) && auth == null)
throw new ArgumentNullException(nameof(auth));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace PasteMystNet
{

public class PasteMystAuth
public class PasteMystToken
{

public PasteMystAuth(string token)
public PasteMystToken(string token)
{
Token = token;
}
Expand Down
8 changes: 4 additions & 4 deletions PasteMystNet/PasteMystUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static async Task<bool> UserExistsAsync(string name)
return JsonConvert.DeserializeObject<PasteMystUser>(content);
}

public static async Task<PasteMystUser?> GetUserAsync(PasteMystAuth auth)
public static async Task<PasteMystUser?> GetUserAsync(PasteMystToken auth)
{
try
{
Expand Down Expand Up @@ -73,7 +73,7 @@ public static async Task<bool> UserExistsAsync(string name)
}
}

public static async Task<string[]?> GetUserPastesAsync(PasteMystAuth auth)
public static async Task<string[]?> GetUserPastesAsync(PasteMystToken auth)
{
try
{
Expand Down Expand Up @@ -106,8 +106,8 @@ public static async Task<bool> UserExistsAsync(string name)
}
}

[Obsolete] public static async Task<PasteMystUser?> GetSelfAsync(PasteMystAuth auth) { return await GetUserAsync(auth); }
[Obsolete] public static async Task<string[]?> GetSelfPastesAsync(PasteMystAuth auth) { return await GetUserPastesAsync(auth); }
[Obsolete] public static async Task<PasteMystUser?> GetSelfAsync(PasteMystToken auth) { return await GetUserAsync(auth); }
[Obsolete] public static async Task<string[]?> GetSelfPastesAsync(PasteMystToken auth) { return await GetUserPastesAsync(auth); }

public override string ToString()
{
Expand Down

0 comments on commit 7241faf

Please sign in to comment.