-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,289 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Sinch.Conversation.Apps | ||
{ | ||
public class App | ||
{ | ||
/// <summary> | ||
/// An array of channel credentials. The order of the credentials defines the app channel priority. | ||
/// </summary> | ||
public List<ConversationChannelCredential> ChannelCredentials { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or Sets ConversationMetadataReportView | ||
/// </summary> | ||
public ConversationMetadataReportView? ConversationMetadataReportView { get; set; } | ||
|
||
/// <summary> | ||
/// The display name for the app. | ||
/// </summary> | ||
public string DisplayName { get; set; } | ||
|
||
/// <summary> | ||
/// The ID of the app. You can find this on the [Sinch Dashboard](https://dashboard.sinch.com/convapi/apps). | ||
/// </summary> | ||
public string Id { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or Sets RateLimits | ||
/// </summary> | ||
public RateLimits RateLimits { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Gets or Sets RetentionPolicy | ||
/// </summary> | ||
public RetentionPolicy RetentionPolicy { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or Sets DispatchRetentionPolicy | ||
/// </summary> | ||
public DispatchRetentionPolicy DispatchRetentionPolicy { get; set; } | ||
|
||
/// <summary> | ||
/// Whether or not Conversation API should store contacts and conversations for the app. | ||
/// For more information, | ||
/// see [Processing Modes](https://developers.sinch.com/docs/conversation/processing-modes/). | ||
/// </summary> | ||
public ProcessingMode ProcessingMode { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Gets or Sets SmartConversation | ||
/// </summary> | ||
public SmartConversation SmartConversation { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Gets or Sets QueueStats | ||
/// </summary> | ||
public QueueStats QueueStats { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Returns the string presentation of the object | ||
/// </summary> | ||
/// <returns>String presentation of the object</returns> | ||
public override string ToString() | ||
{ | ||
var sb = new StringBuilder(); | ||
sb.Append("class AppResponse {\n"); | ||
sb.Append(" ChannelCredentials: ").Append(ChannelCredentials).Append("\n"); | ||
sb.Append(" ConversationMetadataReportView: ").Append(ConversationMetadataReportView).Append("\n"); | ||
sb.Append(" DisplayName: ").Append(DisplayName).Append("\n"); | ||
sb.Append(" Id: ").Append(Id).Append("\n"); | ||
sb.Append(" RateLimits: ").Append(RateLimits).Append("\n"); | ||
sb.Append(" RetentionPolicy: ").Append(RetentionPolicy).Append("\n"); | ||
sb.Append(" DispatchRetentionPolicy: ").Append(DispatchRetentionPolicy).Append("\n"); | ||
sb.Append(" ProcessingMode: ").Append(ProcessingMode).Append("\n"); | ||
sb.Append(" SmartConversation: ").Append(SmartConversation).Append("\n"); | ||
sb.Append(" QueueStats: ").Append(QueueStats).Append("\n"); | ||
sb.Append("}\n"); | ||
return sb.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Sinch.Conversation.Apps.Create; | ||
using Sinch.Core; | ||
using Sinch.Logger; | ||
|
||
namespace Sinch.Conversation.Apps | ||
{ | ||
/// <summary> | ||
/// Apps are created and configured through | ||
/// the <see href="https://dashboard.sinch.com/convapi/getting-started">Sinch Dashboard</see>, | ||
/// are tied to the API user and come with a set of channel credentials | ||
/// for each underlying connected channel. | ||
/// The app has a list of conversations between itself and different contacts which share the same project. | ||
/// </summary> | ||
public interface IApp | ||
{ | ||
/// <summary> | ||
/// You can create a new Conversation API app using the API. | ||
/// You can create an app for one or more channels at once. | ||
/// The ID of the app is generated at creation and will be returned in the response. | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
Task<App> Create(Request request, CancellationToken cancellationToken = default); | ||
} | ||
|
||
internal class Apps : IApp | ||
{ | ||
private readonly string _projectId; | ||
private readonly Uri _baseAddress; | ||
private readonly ILoggerAdapter<Apps> _logger; | ||
private readonly IHttp _http; | ||
|
||
public Apps(string projectId, Uri baseAddress, ILoggerAdapter<Apps> logger, IHttp http) | ||
{ | ||
_projectId = projectId; | ||
_baseAddress = baseAddress; | ||
_logger = logger; | ||
_http = http; | ||
} | ||
|
||
public Task<App> Create(Request request, CancellationToken cancellationToken = default) | ||
{ | ||
var uri = new Uri(_baseAddress, $"v1/projects/{_projectId}/apps"); | ||
_logger?.LogDebug("Creating an app..."); | ||
return _http.Send<Request, App>(uri, HttpMethod.Post, request, cancellationToken); | ||
} | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
src/Sinch/Conversation/Apps/ConversationChannelCredential.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using System.Text; | ||
using Sinch.Conversation.Apps.Credentials; | ||
using Sinch.Conversation.Messages; | ||
|
||
namespace Sinch.Conversation.Apps | ||
{ | ||
/// <summary> | ||
/// Enables access to the underlying messaging channel. | ||
/// </summary> | ||
public sealed class ConversationChannelCredential | ||
{ | ||
/// <summary> | ||
/// Gets or Sets Channel | ||
/// </summary> | ||
#if NET7_0_OR_GREATER | ||
public required ConversationChannel Channel { get; set; } | ||
#else | ||
public ConversationChannel Channel { get; set; } | ||
#endif | ||
|
||
/// <summary> | ||
/// The secret used to verify the channel callbacks for channels which support callback verification. | ||
/// The callback verification is not needed for Sinch-managed channels because | ||
/// the callbacks are not leaving Sinch internal networks. Max length is 256 characters. | ||
/// Note: leaving channel_callback_secret empty for channels | ||
/// with callback verification will disable the verification. | ||
/// </summary> | ||
public string CallbackSecret { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Gets or Sets MmsCredentials | ||
/// </summary> | ||
public MmsCredentials MmsCredentials { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Gets or Sets KakaotalkCredentials | ||
/// </summary> | ||
public KakaoTalkCredentials KakaotalkCredentials { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Gets or Sets StaticBearer | ||
/// </summary> | ||
public StaticBearerCredential StaticBearer { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Gets or Sets StaticToken | ||
/// </summary> | ||
public StaticTokenCredential StaticToken { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Gets or Sets TelegramCredentials | ||
/// </summary> | ||
public TelegramCredentials TelegramCredentials { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Gets or Sets LineCredentials | ||
/// </summary> | ||
public LineCredentials LineCredentials { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Gets or Sets WechatCredentials | ||
/// </summary> | ||
public WeChatCredentials WechatCredentials { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Returns the string presentation of the object | ||
/// </summary> | ||
/// <returns>String presentation of the object</returns> | ||
public override string ToString() | ||
{ | ||
var sb = new StringBuilder(); | ||
sb.Append("class ConversationChannelCredential {\n"); | ||
sb.Append(" CallbackSecret: ").Append(CallbackSecret).Append("\n"); | ||
sb.Append(" Channel: ").Append(Channel).Append("\n"); | ||
sb.Append(" MmsCredentials: ").Append(MmsCredentials).Append("\n"); | ||
sb.Append(" KakaotalkCredentials: ").Append(KakaotalkCredentials).Append("\n"); | ||
sb.Append(" StaticBearer: ").Append(StaticBearer).Append("\n"); | ||
sb.Append(" StaticToken: ").Append(StaticToken).Append("\n"); | ||
sb.Append(" TelegramCredentials: ").Append(TelegramCredentials).Append("\n"); | ||
sb.Append(" LineCredentials: ").Append(LineCredentials).Append("\n"); | ||
sb.Append(" WechatCredentials: ").Append(WechatCredentials).Append("\n"); | ||
sb.Append("}\n"); | ||
return sb.ToString(); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Sinch/Conversation/Apps/ConversationMetadataReportView.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Runtime.Serialization; | ||
using System.Text.Json.Serialization; | ||
using Sinch.Core; | ||
|
||
namespace Sinch.Conversation.Apps | ||
{ | ||
[JsonConverter(typeof(SinchEnumConverter<ConversationMetadataReportView>))] | ||
public enum ConversationMetadataReportView | ||
{ | ||
[EnumMember(Value = "NONE")] | ||
None, | ||
|
||
[EnumMember(Value = "FULL")] | ||
Full | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Sinch.Conversation.Apps.Create | ||
{ | ||
/// <summary> | ||
/// The request sent to the API endpoint to create a new app. | ||
/// </summary> | ||
public sealed class Request | ||
{ | ||
/// <summary> | ||
/// Gets or Sets ConversationMetadataReportView | ||
/// </summary> | ||
public ConversationMetadataReportView? ConversationMetadataReportView { get; set; } | ||
|
||
/// <summary> | ||
/// An array of channel credentials. The order of the credentials defines the app channel priority. | ||
/// </summary> | ||
#if NET7_0_OR_GREATER | ||
public required List<ConversationChannelCredential> ChannelCredentials { get; set; } | ||
#else | ||
public List<ConversationChannelCredential> ChannelCredentials { get; set; } | ||
#endif | ||
|
||
|
||
/// <summary> | ||
/// The display name for the app. | ||
/// </summary> | ||
#if NET7_0_OR_GREATER | ||
public required string DisplayName { get; set; } | ||
#else | ||
public string DisplayName { get; set; } | ||
#endif | ||
|
||
|
||
/// <summary> | ||
/// Gets or Sets RetentionPolicy | ||
/// </summary> | ||
public RetentionPolicy RetentionPolicy { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Gets or Sets DispatchRetentionPolicy | ||
/// </summary> | ||
public DispatchRetentionPolicy DispatchRetentionPolicy { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Whether or not Conversation API should store contacts and conversations for the app. For more information, see [Processing Modes](../../../../../conversation/processing-modes/). | ||
/// </summary> | ||
public ProcessingMode? ProcessingMode { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Gets or Sets SmartConversation | ||
/// </summary> | ||
public SmartConversation SmartConversation { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Returns the string presentation of the object | ||
/// </summary> | ||
/// <returns>String presentation of the object</returns> | ||
public override string ToString() | ||
{ | ||
var sb = new StringBuilder(); | ||
sb.Append("class AppCreateRequest {\n"); | ||
sb.Append(" ChannelCredentials: ").Append(ChannelCredentials).Append("\n"); | ||
sb.Append(" ConversationMetadataReportView: ").Append(ConversationMetadataReportView).Append("\n"); | ||
sb.Append(" DisplayName: ").Append(DisplayName).Append("\n"); | ||
sb.Append(" RetentionPolicy: ").Append(RetentionPolicy).Append("\n"); | ||
sb.Append(" DispatchRetentionPolicy: ").Append(DispatchRetentionPolicy).Append("\n"); | ||
sb.Append(" ProcessingMode: ").Append(ProcessingMode).Append("\n"); | ||
sb.Append(" SmartConversation: ").Append(SmartConversation).Append("\n"); | ||
sb.Append("}\n"); | ||
return sb.ToString(); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/Sinch/Conversation/Apps/Credentials/BasicAuthCredentials.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Text; | ||
|
||
namespace Sinch.Conversation.Apps.Credentials | ||
{ /// <summary> | ||
/// It consists of a username and a password. | ||
/// </summary> | ||
public sealed class BasicAuthCredential | ||
{ | ||
/// <summary> | ||
/// Basic auth password. | ||
/// </summary> | ||
#if NET7_0_OR_GREATER | ||
public required string Password { get; set; } | ||
#else | ||
public string Password { get; set; } | ||
#endif | ||
|
||
|
||
/// <summary> | ||
/// Basic auth username. | ||
/// </summary> | ||
#if NET7_0_OR_GREATER | ||
public required string Username { get; set; } | ||
#else | ||
public string Username { get; set; } | ||
#endif | ||
|
||
|
||
/// <summary> | ||
/// Returns the string presentation of the object | ||
/// </summary> | ||
/// <returns>String presentation of the object</returns> | ||
public override string ToString() | ||
{ | ||
var sb = new StringBuilder(); | ||
sb.Append("class BasicAuthCredential {\n"); | ||
sb.Append(" Password: ").Append(Password).Append("\n"); | ||
sb.Append(" Username: ").Append(Username).Append("\n"); | ||
sb.Append("}\n"); | ||
return sb.ToString(); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.