Update API
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public partial class LineMessagingClient
|
||||
{
|
||||
private const string GroupProfileApiPath = "v2/bot/group/{0}/summary";
|
||||
private const string QuotaApiPath = "/v2/bot/message/quota/consumption";
|
||||
|
||||
public async Task<int> GetTotalUsage()
|
||||
{
|
||||
return Get<LineUsage>(QuotaApiPath).Result.TotalUsage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<LineGroupProfile> GetGroupProfile(string groupId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(groupId))
|
||||
{
|
||||
throw new ArgumentException($"{nameof(groupId)} is null or empty.");
|
||||
}
|
||||
return await Get<LineGroupProfile>(string.Format(GroupProfileApiPath, groupId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace LineMessaging
|
||||
{
|
||||
public class LineUsage
|
||||
{
|
||||
[JsonProperty("totalUsage")]
|
||||
public int TotalUsage { get; set; }
|
||||
}
|
||||
public class LineGroupProfile
|
||||
{
|
||||
[JsonProperty("groupName")]
|
||||
public string GroupName { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ namespace LineMessaging
|
||||
public partial class LineMessagingClient
|
||||
{
|
||||
private const string ACCESS_TOKEN = "WFAyMvMEZ86cfMJIAzE+yklUZGpeS/jFYTeL9a9O35QR83oNMmwaUJfyEe48Kegadz0BArDdBoySxs479U1pwTHtlyH+Sm4jqlz8BwukX/Hsa4D1fX03Qn4zFu7TwPFKWFXnZbWq89Yg0iNzjpfTNwdB04t89/1O/w1cDnyilFU=";
|
||||
private const string ACCESS_TOKEN_SEC = "UTRu3QsV9BjVmusqgWa30j/Vs7JJb59NvIWprv9Yb4ORUOTIIco66groSy7n8TlQbxn/OsA6FsFSQZDwaRPPlyfBYoW+lvv8g7IZhA8otuK57f+ojZbLO0RvkyEyQoy09Kmd7dnr78kHlDOcBq5ATgdB04t89/1O/w1cDnyilFU=";
|
||||
private static readonly MediaTypeHeaderValue MediaTypeJson = MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
|
||||
private static readonly MediaTypeHeaderValue MediaTypeJpeg = MediaTypeHeaderValue.Parse("image/jpeg");
|
||||
private static readonly MediaTypeHeaderValue MediaTypePng = MediaTypeHeaderValue.Parse("image/png");
|
||||
@@ -25,11 +26,21 @@ namespace LineMessaging
|
||||
Timeout = TimeSpan.FromSeconds(10)
|
||||
};
|
||||
|
||||
private readonly AuthenticationHeaderValue accessTokenHeaderValue;
|
||||
private AuthenticationHeaderValue accessTokenHeaderValue;
|
||||
private JsonSerializerSettings serializerSettings;
|
||||
public LineMessagingClient()
|
||||
{
|
||||
string accessToken = ACCESS_TOKEN;
|
||||
string accessToken = ACCESS_TOKEN_SEC;//ACCESS_TOKEN;
|
||||
Initialize(accessToken);
|
||||
}
|
||||
public LineMessagingClient(string accessToken)
|
||||
{
|
||||
Initialize(accessToken);
|
||||
}
|
||||
|
||||
private void Initialize(string accessToken)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(accessToken))
|
||||
{
|
||||
throw new ArgumentException($"{nameof(accessToken)} is null or empty.");
|
||||
@@ -38,7 +49,7 @@ namespace LineMessaging
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
Formatting=Formatting.Indented
|
||||
Formatting = Formatting.Indented
|
||||
};
|
||||
accessTokenHeaderValue = new AuthenticationHeaderValue("Bearer", accessToken);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user