-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// Copyright (c) 2024 Sendbird, Inc. | ||
// | ||
|
||
namespace Sendbird.Chat | ||
{ | ||
public partial class SbGroupChannel | ||
{ | ||
private void GetMyPushTriggerOptionInternal(SbGroupChannelGetMyPushTriggerOptionHandler inCompletionHandler) | ||
{ | ||
if (inCompletionHandler == null) | ||
return; | ||
|
||
void OnCompletionHandler(ApiCommandAbstract.Response inResponse, SbError inError, bool inIsCanceled) | ||
{ | ||
if (inResponse is GetMyPushTriggerOptionApiCommand.Response response) | ||
{ | ||
inCompletionHandler.Invoke(response.GroupChannelPushTriggerOption, inError); | ||
return; | ||
} | ||
|
||
inCompletionHandler.Invoke(inMyPushTriggerOption: null, inError); | ||
} | ||
|
||
GetMyPushTriggerOptionApiCommand.Request apiCommand = new GetMyPushTriggerOptionApiCommand.Request( | ||
chatMainContextRef.CurrentUserId, Url, OnCompletionHandler); | ||
|
||
chatMainContextRef.CommandRouter.RequestApiCommand(apiCommand); | ||
} | ||
|
||
private void SetMyPushTriggerOptionInternal(SbGroupChannelPushTriggerOption inGroupChannelPushTriggerOption, SbErrorHandler inCompletionHandler) | ||
{ | ||
if (inCompletionHandler == null) | ||
return; | ||
|
||
void OnCompletionHandler(ApiCommandAbstract.Response inResponse, SbError inError, bool inIsCanceled) | ||
{ | ||
if (inResponse is SetMyPushTriggerOptionApiCommand.Response response) | ||
{ | ||
_myPushTriggerOption = response.GroupChannelPushTriggerOption; | ||
} | ||
|
||
inCompletionHandler.Invoke(inError); | ||
} | ||
|
||
SetMyPushTriggerOptionApiCommand.Request apiCommand = new SetMyPushTriggerOptionApiCommand.Request( | ||
chatMainContextRef.CurrentUserId, Url, inGroupChannelPushTriggerOption, OnCompletionHandler); | ||
|
||
chatMainContextRef.CommandRouter.RequestApiCommand(apiCommand); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Copyright (c) 2023 Sendbird, Inc. | ||
// | ||
|
||
using System; | ||
|
||
namespace Sendbird.Chat | ||
{ | ||
internal static class SbPushTriggerOptionExtension | ||
{ | ||
private static int _enumCount = 0; | ||
|
||
internal static SbPushTriggerOption? JsonNameToType(string inJsonName) | ||
{ | ||
if (string.IsNullOrEmpty(inJsonName) == false) | ||
{ | ||
if (_enumCount <= 0) | ||
_enumCount = Enum.GetValues(typeof(SbPushTriggerOption)).Length; | ||
|
||
for (SbPushTriggerOption enumType = 0; enumType < (SbPushTriggerOption)_enumCount; enumType++) | ||
{ | ||
if (enumType.ToJsonName().Equals(inJsonName, StringComparison.OrdinalIgnoreCase)) | ||
return enumType; | ||
} | ||
|
||
Logger.Warning(Logger.CategoryType.Command, $"SbPushTriggerOption::ToJsonName Invalid type name:{inJsonName}"); | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// Copyright (c) 2022 Sendbird, Inc. | ||
// | ||
|
||
using System; | ||
using System.Net; | ||
using Newtonsoft.Json; | ||
|
||
namespace Sendbird.Chat | ||
{ | ||
internal sealed class GetMyPushTriggerOptionApiCommand | ||
{ | ||
internal sealed class Request : ApiCommandAbstract.GetRequest | ||
{ | ||
internal Request(string inUserId, string inChannelUrl, ResultHandler inResultHandler) | ||
{ | ||
string encodedUserId = WebUtility.UrlEncode(inUserId); | ||
string encodedChannelUrl = WebUtility.UrlEncode(inChannelUrl); | ||
Url = $"{USERS_PREFIX_URL}/{encodedUserId}/push_preference/{encodedChannelUrl}"; | ||
ResponseType = typeof(Response); | ||
resultHandler = inResultHandler; | ||
} | ||
} | ||
|
||
[Serializable] | ||
internal sealed class Response : ApiCommandAbstract.Response | ||
{ | ||
[JsonProperty("push_trigger_option")] internal readonly string pushTriggerOption; | ||
|
||
internal SbGroupChannelPushTriggerOption? GroupChannelPushTriggerOption { get; private set; } = null; | ||
|
||
internal override void OnResponseAfterDeserialize(string inJsonString) | ||
{ | ||
if (string.IsNullOrEmpty(pushTriggerOption) == false) | ||
{ | ||
GroupChannelPushTriggerOption = SbGroupChannelPushTriggerOptionExtension.JsonNameToType(pushTriggerOption); | ||
} | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// Copyright (c) 2022 Sendbird, Inc. | ||
// | ||
|
||
using System; | ||
using System.Net; | ||
using Newtonsoft.Json; | ||
|
||
namespace Sendbird.Chat | ||
{ | ||
internal sealed class SetMyPushTriggerOptionApiCommand | ||
{ | ||
internal sealed class Request : ApiCommandAbstract.PutRequest | ||
{ | ||
[Serializable] | ||
private struct Payload | ||
{ | ||
#pragma warning disable CS0649 | ||
[JsonProperty("push_trigger_option")] internal string pushTriggerOption; | ||
#pragma warning restore CS0649 | ||
} | ||
|
||
internal Request(string inUserId, string inChannelUrl, SbGroupChannelPushTriggerOption inGroupChannelPushTriggerOption, ResultHandler inResultHandler) | ||
{ | ||
string encodedUserId = WebUtility.UrlEncode(inUserId); | ||
string encodedChannelUrl = WebUtility.UrlEncode(inChannelUrl); | ||
Url = $"{USERS_PREFIX_URL}/{encodedUserId}/push_preference/{encodedChannelUrl}"; | ||
ResponseType = typeof(Response); | ||
resultHandler = inResultHandler; | ||
|
||
Payload tempPayload = new Payload | ||
{ | ||
pushTriggerOption = inGroupChannelPushTriggerOption.ToJsonName() | ||
}; | ||
|
||
ContentBody = NewtonsoftJsonExtension.SerializeObjectIgnoreException(tempPayload); | ||
} | ||
} | ||
|
||
[Serializable] | ||
internal sealed class Response : ApiCommandAbstract.Response | ||
{ | ||
[JsonProperty("push_trigger_option")] internal readonly string pushTriggerOption; | ||
|
||
internal SbGroupChannelPushTriggerOption GroupChannelPushTriggerOption { get; private set; } | ||
|
||
internal override void OnResponseAfterDeserialize(string inJsonString) | ||
{ | ||
if (string.IsNullOrEmpty(pushTriggerOption) == false) | ||
{ | ||
GroupChannelPushTriggerOption = SbGroupChannelPushTriggerOptionExtension.JsonNameToType(pushTriggerOption); | ||
} | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// Copyright (c) 2022 Sendbird, Inc. | ||
// | ||
|
||
using System; | ||
using System.Net; | ||
using Newtonsoft.Json; | ||
|
||
namespace Sendbird.Chat | ||
{ | ||
internal sealed class GetPushTriggerOptionApiCommand | ||
{ | ||
internal sealed class Request : ApiCommandAbstract.GetRequest | ||
{ | ||
internal Request(string inUserId, ResultHandler inResultHandler) | ||
{ | ||
string encodedUserId = WebUtility.UrlEncode(inUserId); | ||
Url = $"{USERS_PREFIX_URL}/{encodedUserId}/push_preference"; | ||
ResponseType = typeof(Response); | ||
resultHandler = inResultHandler; | ||
} | ||
} | ||
|
||
[Serializable] | ||
internal sealed class Response : ApiCommandAbstract.Response | ||
{ | ||
[JsonProperty("push_trigger_option")] internal readonly string pushTriggerOption; | ||
|
||
internal SbPushTriggerOption? GroupChannelPushTriggerOptionNullable { get; private set; } = null; | ||
|
||
internal override void OnResponseAfterDeserialize(string inJsonString) | ||
{ | ||
if (string.IsNullOrEmpty(pushTriggerOption) == false) | ||
{ | ||
GroupChannelPushTriggerOptionNullable = SbPushTriggerOptionExtension.JsonNameToType(pushTriggerOption); | ||
} | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Copyright (c) 2022 Sendbird, Inc. | ||
// | ||
|
||
using System; | ||
using System.Net; | ||
using Newtonsoft.Json; | ||
|
||
namespace Sendbird.Chat | ||
{ | ||
internal sealed class SetPushTriggerOptionApiCommand | ||
{ | ||
internal sealed class Request : ApiCommandAbstract.PutRequest | ||
{ | ||
[Serializable] | ||
private struct Payload | ||
{ | ||
#pragma warning disable CS0649 | ||
[JsonProperty("push_trigger_option")] internal string pushTriggerOption; | ||
#pragma warning restore CS0649 | ||
} | ||
|
||
internal Request(string inUserId, SbPushTriggerOption inPushTriggerOption, ResultHandler inResultHandler) | ||
{ | ||
string encodedUserId = WebUtility.UrlEncode(inUserId); | ||
Url = $"{USERS_PREFIX_URL}/{encodedUserId}/push_preference"; | ||
ResponseType = typeof(Response); | ||
resultHandler = inResultHandler; | ||
|
||
Payload tempPayload = new Payload | ||
{ | ||
pushTriggerOption = inPushTriggerOption.ToJsonName() | ||
}; | ||
|
||
ContentBody = NewtonsoftJsonExtension.SerializeObjectIgnoreException(tempPayload); | ||
} | ||
} | ||
|
||
[Serializable] | ||
internal sealed class Response : ApiCommandAbstract.Response | ||
{ | ||
[JsonProperty("push_trigger_option")] internal readonly string pushTriggerOption; | ||
} | ||
} | ||
} |