Skip to content

Commit

Permalink
reset
Browse files Browse the repository at this point in the history
  • Loading branch information
SilkageNet committed Dec 16, 2022
1 parent a5852f3 commit 352f614
Show file tree
Hide file tree
Showing 44 changed files with 780 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 PinealCtx

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions LICENSE.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Unity RestClient

Send HTTP requests in unity through Restful.
3 changes: 3 additions & 0 deletions README.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Runtime.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Runtime/Attribute.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Runtime/Attribute/RestFormProperty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace PinealCtx.RestClient.Attribute
{
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field)]
public class RestFormProperty : System.Attribute
{
public RestFormProperty(string name) => Name = name;

public string Name { get; }
}
}
3 changes: 3 additions & 0 deletions Runtime/Attribute/RestFormProperty.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Runtime/Attribute/RestHeaderProperty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace PinealCtx.RestClient.Attribute
{
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field)]
public class RestHeaderProperty : System.Attribute
{
public RestHeaderProperty(string name) => Name = name;

public string Name { get; }
}
}
3 changes: 3 additions & 0 deletions Runtime/Attribute/RestHeaderProperty.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Runtime/Attribute/RestQueryProperty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace PinealCtx.RestClient.Attribute
{
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field)]
public class RestQueryProperty : System.Attribute
{
public RestQueryProperty(string name) => Name = name;

public string Name { get; }
}
}
3 changes: 3 additions & 0 deletions Runtime/Attribute/RestQueryProperty.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions Runtime/Enums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace PinealCtx.RestClient
{
public enum Method
{
Get,
Post
}

public static class EnumExtensions
{
public static string String(this Method enumValue)
{
return enumValue switch
{
Method.Get => "GET",
Method.Post => "POST",
_ => "GET"
};
}
}
}
3 changes: 3 additions & 0 deletions Runtime/Enums.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Runtime/KnownContentTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace PinealCtx.RestClient
{
public static class KnownContentTypes
{
public const string Json = "application/json";
}
}
3 changes: 3 additions & 0 deletions Runtime/KnownContentTypes.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions Runtime/KnownHeaders.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace PinealCtx.RestClient
{
public static class KnownHeaders
{
public const string Authorization = "Authorization";
public const string Accept = "Accept";
public const string Allow = "Allow";
public const string Expires = "Expires";
public const string ContentDisposition = "Content-Disposition";
public const string ContentEncoding = "Content-Encoding";
public const string ContentLanguage = "Content-Language";
public const string ContentLength = "Content-Length";
public const string ContentLocation = "Content-Location";
public const string ContentRange = "Content-Range";
public const string ContentType = "Content-Type";
public const string LastModified = "Last-Modified";
public const string ContentMD5 = "Content-MD5";
public const string Host = "Host";
public const string UserAgent = "User-Agent";
}
}
3 changes: 3 additions & 0 deletions Runtime/KnownHeaders.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Runtime/Param.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Runtime/Param/BodyParam.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Newtonsoft.Json;

namespace PinealCtx.RestClient.Param
{
public class BodyParam : IParam
{
public string ContentType { get; set; }
public byte[] Data { get; set; }

public BodyParam(string contentType, byte[] data)
{
ContentType = contentType;
Data = data;
}

public ParamType ParamType()
{
return Param.ParamType.Body;
}

public static BodyParam BuildJson(object obj)
{
var json = JsonConvert.SerializeObject(obj);
var bytes = new System.Text.UTF8Encoding().GetBytes(json);
return new BodyParam(KnownContentTypes.Json, bytes);
}
}
}
3 changes: 3 additions & 0 deletions Runtime/Param/BodyParam.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions Runtime/Param/FormParam.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using UnityEngine.Networking;

namespace PinealCtx.RestClient.Param
{
public class FormParam : IParam
{
public FormParam(IMultipartFormSection section) => Section = section;

public FormParam(string name, string value) : this(new MultipartFormDataSection(name, value))
{
}

public FormParam(string name, byte[] value, string fileName = "", string contentType = "") : this(
new MultipartFormFileSection(name, value, fileName, contentType))
{
}

public FormParam(string name, FormFile file) : this(name, file.Data, file.FileName, file.ContentType)
{
}

public IMultipartFormSection Section { get; set; }

public ParamType ParamType() => Param.ParamType.Form;
}

public class FormFile
{
public byte[] Data { get; set; }
public string FileName { get; set; }
public string ContentType { get; set; }
}
}
3 changes: 3 additions & 0 deletions Runtime/Param/FormParam.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions Runtime/Param/HeaderParam.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace PinealCtx.RestClient.Param
{
public class HeaderParam : IParam
{
public HeaderParam(string name, string value)
{
Name = name;
Value = value;
}

public string Name { get; set; }
public string Value { get; set; }

public ParamType ParamType() => Param.ParamType.Header;
}
}
3 changes: 3 additions & 0 deletions Runtime/Param/HeaderParam.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Runtime/Param/IParam.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace PinealCtx.RestClient.Param
{
public interface IParam
{
ParamType ParamType();
}
}
3 changes: 3 additions & 0 deletions Runtime/Param/IParam.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Runtime/Param/ParamType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace PinealCtx.RestClient.Param
{
public enum ParamType
{
Query,
Header,
Body,
Form
}
}
3 changes: 3 additions & 0 deletions Runtime/Param/ParamType.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions Runtime/Param/QueryParam.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using UnityEngine.Networking;

namespace PinealCtx.RestClient.Param
{
public class QueryParam : IParam
{
public QueryParam(string name, string value)
{
Name = name;
Value = value;
}

public string Name { get; set; }
public string Value { get; set; }

public ParamType ParamType() => Param.ParamType.Query;

public override string ToString()
{
return $"{UnityWebRequest.EscapeURL(Name)}={UnityWebRequest.EscapeURL(Value)}";
}
}
}
3 changes: 3 additions & 0 deletions Runtime/Param/QueryParam.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 352f614

Please sign in to comment.