Skip to content

Commit f1416c1

Browse files
committed
refac corporation
1 parent c62e809 commit f1416c1

6 files changed

Lines changed: 56 additions & 12 deletions

File tree

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Install-Package
1212
# 2. Library introduction
1313

1414
## 2-1. LineChannelAccessTokenClient class
15+
* [Channel access token](https://developers.line.biz/en/reference/messaging-api/#channel-access-token)
1516

1617
```csharp
1718
using Line;
@@ -32,7 +33,7 @@ catch (LineCredentialException ex)
3233
}
3334
```
3435

35-
* [Channel access token](https://developers.line.biz/en/reference/messaging-api/#channel-access-token)
36+
3637

3738
|LINE Developers|Methods|Tested|
3839
|---|---|---|
@@ -171,10 +172,35 @@ catch (LineCredentialException ex)
171172
|[Test webhook endpoint](https://developers.line.biz/en/reference/messaging-api/#test-webhook-endpoint)|TestEndpointAsync|✔|
172173
173174
## 2-3 LineLiffClient class
175+
* [LIFF Server API](https://developers.line.biz/en/reference/liff-server/)
176+
174177
```csharp
178+
using Line;
179+
using Line.Liff;
180+
181+
try
182+
{
183+
using (var client = new LineLiffClient("access token"))
184+
{
185+
var liffs = await client.GetAllLiffAppsAsync();
186+
187+
foreach (var liff in liffs)
188+
{
189+
await client.DeleteLiffAppsFromChannelAsync(liff.LiffId);
190+
}
191+
}
192+
}
193+
catch (LineException ex)
194+
{
195+
Console.WriteLine(ex.Message);
175196

197+
foreach (var detail in ex.Details ?? Enumerable.Empty<Detail>())
198+
{
199+
Console.WriteLine(detail.Message);
200+
Console.WriteLine(detail.Property);
201+
}
202+
}
176203
```
177-
* [LIFF Server API](https://developers.line.biz/en/reference/liff-server/)
178204

179205
|LINE Developers|Methods|Tested|
180206
|---|---|---|

Src/LineDevelopers.Tests/EtcTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Line.Message.Corporation;
1+
using Line.Corporation;
22

33
namespace LineDevelopers.Tests
44
{

Src/LineDevelopers.Tests/LineChannelAccessTokenClientTest.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,14 @@ public void VerifyTheChannelAccessTokenAsyncTest()
4848
var result = await _lineChannelAccessTokenClient.VerifyChannelAccessTokenAsync(_token.AccessToken);
4949
});
5050
}
51+
52+
[Test, Order(6)]
53+
public void RevokeChannelAccessTokenAsyncTest()
54+
{
55+
DoesNotThrowAsync(async () => {
56+
await _lineChannelAccessTokenClient.RevokeChannelAccessTokenAsync(CHANNEL_ID, CHANNEL_SECRET,_token.AccessToken);
57+
});
58+
59+
}
5160
}
5261
}

Src/LineDevelopers/ChannelAccessToken/LineChannelAccessTokenClient.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,24 @@ public async Task<IList<string>> GetAllValidChannelAccessTokenKeyIDsAsync(string
6363
return result.Kids;
6464
}
6565

66-
public async Task RevokeChannelAccessTokenAsync(string clientId, string client_secret, string channelAccessToken)
66+
public async Task RevokeChannelAccessTokenAsync(string channelId, string client_secret, string channelAccessToken)
6767
{
6868
var request = new List<KeyValuePair<string, string>>
6969
{
70-
new KeyValuePair<string, string>("client_id", clientId),
70+
new KeyValuePair<string, string>("client_id", channelId),
7171
new KeyValuePair<string, string>("client_secret", client_secret),
7272
new KeyValuePair<string, string>("access_token", channelAccessToken)
7373
};
7474

7575
await base.PostAsync($"oauth2/v2.1/revoke", new FormUrlEncodedContent(request)).ConfigureAwait(false);
7676
}
7777

78-
public async Task<ChannelAccessToken> IssueShortLivedChannelAccessTokenAsync(string clientId, string clientSecret)
78+
public async Task<ChannelAccessToken> IssueShortLivedChannelAccessTokenAsync(string channelId, string clientSecret)
7979
{
8080
var request = new List<KeyValuePair<string, string>>()
8181
{
8282
new KeyValuePair<string, string>("grant_type", "client_credentials"),
83-
new KeyValuePair<string, string>("client_id", clientId),
83+
new KeyValuePair<string, string>("client_id", channelId),
8484
new KeyValuePair<string, string>("client_secret", clientSecret)
8585
};
8686

Src/LineDevelopers/Message/Corporation/LineMessageForCorporationClient.cs renamed to Src/LineDevelopers/Corporation/LineMessageForCorporationClient.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Line.Message.Corporation
1+
using Line.Message;
2+
3+
namespace Line.Corporation
24
{
35
public class LineMessageForCorporationClient : LineHttpClient
46
{
@@ -25,11 +27,18 @@ protected override async Task EnsureSuccessStatusCodeAsync(HttpResponseMessage?
2527
/// The default value is false.
2628
/// </param>
2729
/// <returns></returns>
28-
public async Task SendMulticastMessageUsingPhoneNumberAsync(string[] to, IList<IMessage> messages, bool? notificationDisabled = null)
30+
public async Task SendMulticastMessageUsingPhoneNumberAsync(IList<string> to, IList<IMessage> messages, bool? notificationDisabled = null)
2931
{
32+
var encTo = new List<string>();
33+
34+
foreach (var phoneNumber in to)
35+
{
36+
encTo.Add(await PhoneNumber.EncryptSHA256Async(phoneNumber).ConfigureAwait(false));
37+
}
38+
3039
var request = new MulticastMessage()
3140
{
32-
To = to,
41+
To = encTo,
3342
Messages = messages,
3443
NotificationDisabled = notificationDisabled
3544
};
@@ -57,7 +66,7 @@ public async Task SendNotificationMessageUsingPhoneNumberAsync(string to, IList<
5766
{
5867
var request = new NotificationMessage()
5968
{
60-
To = to,
69+
To = await PhoneNumber.EncryptSHA256Async(to).ConfigureAwait(false),
6170
Messages = messages
6271
};
6372

Src/LineDevelopers/Message/Corporation/PhoneNumber.cs renamed to Src/LineDevelopers/Corporation/PhoneNumber.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Security.Cryptography;
22
using System.Text;
33

4-
namespace Line.Message.Corporation
4+
namespace Line.Corporation
55
{
66
public class PhoneNumber
77
{

0 commit comments

Comments
 (0)