Skip to content

Commit 0ac349c

Browse files
Add package
1 parent 4fdf57e commit 0ac349c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1575
-0
lines changed

Runtime.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Abstraction.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace UAPIModule.Abstraction
2+
{
3+
public interface INetworkLoadingHandler
4+
{
5+
void ShowLoading();
6+
void HideLoading();
7+
}
8+
}

Runtime/Abstraction/INetworkLoadingHandler.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Assets.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Assets/APIConfig.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using UAPIModule.SharedTypes;
2+
using UnityEngine;
3+
4+
namespace UAPIModule.Assets
5+
{
6+
[CreateAssetMenu(fileName = nameof(APIConfig), menuName = "UAPIModule/" + nameof(APIConfig), order = 1)]
7+
public class APIConfig : ScriptableObject
8+
{
9+
[field: SerializeField, Tooltip("The base URL configuration for the API request.")]
10+
public BaseURLConfig BaseURLConfig { get; private set; }
11+
12+
[field: SerializeField, Tooltip("The endpoint of the API request.")]
13+
public string Endpoint { get; private set; }
14+
15+
[field: SerializeField, Tooltip("The HTTP method type (GET, POST, PUT, etc.) for the API request.")]
16+
public HTTPRequestMethod MethodType { get; private set; }
17+
18+
[field: SerializeField, Tooltip("The headers for the API request.")]
19+
public HttpRequestParams Headers { get; private set; }
20+
21+
[field: SerializeField, Tooltip("Indicates whether the API request needs an authorization header.")]
22+
public bool NeedsAuthHeader { get; private set; }
23+
24+
[field: SerializeField, Tooltip("The timeout duration for the API request in milliseconds.")]
25+
public int Timeout { get; private set; } = 10000;
26+
27+
[field: SerializeField, Tooltip("Indicates whether to use the 'Bearer' prefix in the authorization header.")]
28+
public bool UseBearerPrefix { get; private set; } = true;
29+
30+
public APIConfigData CreateConfigData() =>
31+
new(BaseURLConfig, Endpoint, MethodType, Headers, NeedsAuthHeader, Timeout, UseBearerPrefix);
32+
}
33+
}

Runtime/Assets/APIConfig.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Assets/BaseURLConfig.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using UnityEngine;
2+
3+
namespace UAPIModule.Assets
4+
{
5+
[CreateAssetMenu(fileName = nameof(BaseURLConfig), menuName = "UAPIModule/" + nameof(BaseURLConfig))]
6+
public class BaseURLConfig : ScriptableObject
7+
{
8+
[field: SerializeField] public string BaseURL { get; private set; }
9+
}
10+
}

Runtime/Assets/BaseURLConfig.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace UAPIModule.Assets
6+
{
7+
[CreateAssetMenu(fileName = nameof(HttpRequestParams), menuName = "UAPIModule/" + nameof(HttpRequestParams))]
8+
public class HttpRequestParams : ScriptableObject
9+
{
10+
[field: SerializeField] public List<KeyValueItem> Parameters { private set; get; }
11+
12+
public bool HasEmptyParams() =>
13+
Parameters.Exists(keyValueItems =>
14+
string.IsNullOrEmpty(keyValueItems.key) || string.IsNullOrEmpty(keyValueItems.value));
15+
16+
public void AddParam(string key, string value)
17+
{
18+
if (Parameters.Exists(keyValueItems => keyValueItems.key == key)) return;
19+
Parameters.Add(new KeyValueItem() { key = key, value = value });
20+
}
21+
22+
[ContextMenu("Add Default Header Params")]
23+
public void AddDefaultHeaderParams()
24+
{
25+
AddParam("Content-Type", "application/json");
26+
AddParam("Accept", "application/json");
27+
}
28+
29+
[Serializable]
30+
public class KeyValueItem
31+
{
32+
public string key;
33+
public string value;
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)