-
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.
Feat/conversation conversations (#36)
* feat: implement requests create list list auto stop update delete inject * fix(conversation/messages): use appropriate json structure * fix(messages): include accept_time * feat(tests): add e2e tests for conversations * fix: typo in doc of ConversationChannel.cs * chore: update AccessingPolymorphicType.cs with actual types
- Loading branch information
Showing
32 changed files
with
1,192 additions
and
255 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,33 @@ | ||
using Sinch; | ||
using Sinch.Verification.Report.Request; | ||
using Sinch.Verification.Report.Response; | ||
|
||
namespace Examples | ||
{ | ||
public class AccessingPolymorphicType | ||
{ | ||
public static void Example() | ||
{ | ||
var sinchClient = new SinchClient("KEY_ID", "KEY_SECRET", "PROJECT_ID"); | ||
var response = sinchClient.Verification("APP_KEY", "APP_SECRET").Verification | ||
.ReportId("id", new SmsVerificationReportRequest() | ||
{ | ||
Sms = new SmsVerify() | ||
{ | ||
Code = "123", | ||
Cli = "it's a cli" | ||
} | ||
}).Result; | ||
var id = response switch | ||
{ | ||
FlashCallVerificationReportResponse flashCallVerificationReportResponse => | ||
flashCallVerificationReportResponse.Id, | ||
PhoneCallVerificationReportResponse phoneCallVerificationReportResponse => | ||
phoneCallVerificationReportResponse.Id, | ||
SmsVerificationReportResponse smsVerificationReportResponse => smsVerificationReportResponse.Id, | ||
_ => throw new ArgumentOutOfRangeException(nameof(response)) | ||
}; | ||
Console.WriteLine(id); | ||
} | ||
} | ||
} |
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
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
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,147 @@ | ||
using System; | ||
using System.Text; | ||
using System.Text.Json.Nodes; | ||
using System.Text.Json.Serialization; | ||
using Sinch.Core; | ||
|
||
namespace Sinch.Conversation.Conversations | ||
{ | ||
/// <summary> | ||
/// A collection of messages exchanged between a contact and an app. Conversations are normally created on the fly by | ||
/// Conversation API once a message is sent and there is no active conversation already. There can be only one active | ||
/// conversation at any given time between a particular contact and an app. | ||
/// </summary> | ||
public sealed class Conversation : PropertyMaskQuery | ||
{ | ||
private bool? _active; | ||
private ConversationChannel _activeChannel; | ||
private string _appId; | ||
private string _contactId; | ||
private string _correlationId; | ||
private string _metadata; | ||
private JsonObject _metadataJson; | ||
|
||
/// <summary> | ||
/// Gets or Sets ActiveChannel | ||
/// </summary> | ||
public ConversationChannel ActiveChannel | ||
{ | ||
get => _activeChannel; | ||
set | ||
{ | ||
SetFields.Add(nameof(ActiveChannel)); | ||
_activeChannel = value; | ||
} | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Flag for whether this conversation is active. | ||
/// </summary> | ||
public bool? Active | ||
{ | ||
get => _active; | ||
set | ||
{ | ||
SetFields.Add(nameof(Active)); | ||
_active = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The ID of the participating app. | ||
/// </summary> | ||
public string AppId | ||
{ | ||
get => _appId; | ||
set | ||
{ | ||
SetFields.Add(nameof(AppId)); | ||
_appId = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The ID of the participating contact. | ||
/// </summary> | ||
public string ContactId | ||
{ | ||
get => _contactId; | ||
set | ||
{ | ||
SetFields.Add(nameof(ContactId)); | ||
_contactId = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The ID of the conversation. | ||
/// </summary> | ||
public string Id { get; set; } | ||
|
||
/// <summary> | ||
/// The timestamp of the latest message in the conversation. | ||
/// </summary> | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] | ||
public DateTime LastReceived { get; set; } | ||
|
||
/// <summary> | ||
/// Arbitrary data set by the Conversation API clients. Up to 1024 characters long. | ||
/// </summary> | ||
public string Metadata | ||
{ | ||
get => _metadata; | ||
set | ||
{ | ||
SetFields.Add(nameof(Metadata)); | ||
_metadata = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Arbitrary data set by the Conversation API clients and/or provided in the conversation_metadata field of a | ||
/// SendMessageRequest. A valid JSON object. | ||
/// </summary> | ||
public JsonObject MetadataJson | ||
{ | ||
get => _metadataJson; | ||
set | ||
{ | ||
SetFields.Add(nameof(MetadataJson)); | ||
_metadataJson = value; | ||
} | ||
} | ||
|
||
public string CorrelationId | ||
{ | ||
get => _correlationId; | ||
set | ||
{ | ||
SetFields.Add(nameof(CorrelationId)); | ||
_correlationId = value; | ||
} | ||
} | ||
|
||
|
||
/// <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 Conversation {\n"); | ||
sb.Append(" Active: ").Append(Active).Append("\n"); | ||
sb.Append(" ActiveChannel: ").Append(ActiveChannel).Append("\n"); | ||
sb.Append(" AppId: ").Append(AppId).Append("\n"); | ||
sb.Append(" ContactId: ").Append(ContactId).Append("\n"); | ||
sb.Append(" Id: ").Append(Id).Append("\n"); | ||
sb.Append(" LastReceived: ").Append(LastReceived).Append("\n"); | ||
sb.Append(" Metadata: ").Append(Metadata).Append("\n"); | ||
sb.Append(" MetadataJson: ").Append(MetadataJson).Append("\n"); | ||
sb.Append(" CorrelationId: ").Append(CorrelationId).Append("\n"); | ||
sb.Append("}\n"); | ||
return sb.ToString(); | ||
} | ||
} | ||
} |
Oops, something went wrong.