-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/conversation contact #33
Changes from 16 commits
023fe39
1fe0bc4
7a960ff
c24fbc3
e7e83cc
a57f28d
6a2b88a
ebcade8
a6c9987
0051915
8658ebb
a8a4fa0
2f7067a
50c2974
0f23470
76edf11
93d9cbc
5b4118a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ jobs: | |
- 6039:6039 | ||
- 6040:6040 | ||
- 6041:6041 | ||
- 6042:6042 | ||
- 6043:6043 | ||
- 6044:6044 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Sinch.Conversation.Messages; | ||
using Sinch.Core; | ||
|
||
namespace Sinch.Conversation.Contacts | ||
{ | ||
public sealed class Contact | ||
{ | ||
/// <summary> | ||
/// Tracks the fields which where initialized. | ||
/// </summary> | ||
private readonly ISet<string> _setFields = new HashSet<string>(); | ||
|
||
private List<ChannelIdentity> _channelIdentities; | ||
private List<ConversationChannel> _channelPriority; | ||
private string _displayName; | ||
private string _email; | ||
private string _externalId; | ||
private string _id; | ||
private string _language; | ||
private string _metadata; | ||
|
||
/// <summary> | ||
/// List of channel identities. | ||
/// </summary> | ||
public List<ChannelIdentity> ChannelIdentities | ||
{ | ||
get => _channelIdentities; | ||
set | ||
{ | ||
_setFields.Add(nameof(ChannelIdentities)); | ||
_channelIdentities = value; | ||
} | ||
} | ||
|
||
|
||
/// <summary> | ||
/// List of channels defining the channel priority. | ||
/// </summary> | ||
public List<ConversationChannel> ChannelPriority | ||
{ | ||
get => _channelPriority; | ||
set | ||
{ | ||
_setFields.Add(nameof(ChannelPriority)); | ||
_channelPriority = value; | ||
} | ||
} | ||
|
||
|
||
/// <summary> | ||
/// The display name. A default 'Unknown' will be assigned if left empty. | ||
/// </summary> | ||
public string DisplayName | ||
{ | ||
get => _displayName; | ||
set | ||
{ | ||
_setFields.Add(nameof(DisplayName)); | ||
_displayName = value; | ||
} | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Email of the contact. | ||
/// </summary> | ||
public string Email | ||
{ | ||
get => _email; | ||
set | ||
{ | ||
_setFields.Add(nameof(Email)); | ||
_email = value; | ||
} | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Contact identifier in an external system. | ||
/// </summary> | ||
public string ExternalId | ||
{ | ||
get => _externalId; | ||
set | ||
{ | ||
_setFields.Add(nameof(ExternalId)); | ||
_externalId = value; | ||
} | ||
} | ||
|
||
|
||
/// <summary> | ||
/// The ID of the contact. | ||
/// </summary> | ||
public string Id | ||
{ | ||
get => _id; | ||
set | ||
{ | ||
_setFields.Add(nameof(Id)); | ||
_id = value; | ||
} | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Gets or Sets Language | ||
/// </summary> | ||
public string Language | ||
{ | ||
get => _language; | ||
set | ||
{ | ||
_setFields.Add(nameof(Language)); | ||
_language = value; | ||
} | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Metadata associated with the contact. Up to 1024 characters long. | ||
/// </summary> | ||
public string Metadata | ||
{ | ||
get => _metadata; | ||
set | ||
{ | ||
_setFields.Add(nameof(Metadata)); | ||
_metadata = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Get the comma separated snake_case list of properties which were directly initialized in this object. | ||
/// If, for example, DisplayName and Metadata were set, will return <example>display_name,metadata</example> | ||
/// </summary> | ||
/// <returns></returns> | ||
internal string GetPropertiesMask() | ||
{ | ||
return string.Join(',', _setFields.Select(StringUtils.ToSnakeCase)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally this logic could be dynamic and dependent of OAS description based onto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, why to avoid makes sense but how, you mean add helpers for that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Java SDK is based onto this: https://github.com/sinch/sinch-sdk-java/blob/feat/voice/core/src/main/com/sinch/sdk/core/http/URLParameterUtils.java There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, okay, I'll refactor in other task |
||
} | ||
|
||
/// <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 Contact {\n"); | ||
sb.Append(" ChannelIdentities: ").Append(ChannelIdentities).Append("\n"); | ||
sb.Append(" ChannelPriority: ").Append(ChannelPriority).Append("\n"); | ||
sb.Append(" DisplayName: ").Append(DisplayName).Append("\n"); | ||
sb.Append(" Email: ").Append(Email).Append("\n"); | ||
sb.Append(" ExternalId: ").Append(ExternalId).Append("\n"); | ||
sb.Append(" Id: ").Append(Id).Append("\n"); | ||
sb.Append(" Language: ").Append(Language).Append("\n"); | ||
sb.Append(" Metadata: ").Append(Metadata).Append("\n"); | ||
sb.Append("}\n"); | ||
return sb.ToString(); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From specs it is a dedicated schema and a (long) list of predefined values.
Ideally we should provide enums as helper ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, makes sense.
Side comment: did you enjoy working with enums of 20+ values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No 😞
But from SDK user point of view and because not related to any ISO definition, we can just assuming providing list of supported values will be helpful