Skip to content
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

DX-2476 Add priority to createCallRequest and createCallResponse models #46

Merged
merged 3 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 54 additions & 3 deletions Bandwidth.Standard/Voice/Models/CreateCallRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class CreateCallRequest
private string disconnectUrl;
private Models.DisconnectMethodEnum? disconnectMethod;
private string tag;
private int? priority;
private Dictionary<string, bool> shouldSerialize = new Dictionary<string, bool>
{
{ "uui", false },
Expand All @@ -48,6 +49,7 @@ public class CreateCallRequest
{ "disconnectUrl", false },
{ "disconnectMethod", false },
{ "tag", false },
{ "priority", false },
};

/// <summary>
Expand Down Expand Up @@ -78,6 +80,7 @@ public CreateCallRequest()
/// <param name="disconnectMethod">disconnectMethod.</param>
/// <param name="tag">tag.</param>
/// <param name="machineDetection">machineDetection.</param>
/// <param name="priority">priority.</param>
public CreateCallRequest(
string from,
string to,
Expand All @@ -96,7 +99,8 @@ public CreateCallRequest(
string disconnectUrl = null,
Models.DisconnectMethodEnum? disconnectMethod = null,
string tag = null,
Models.MachineDetectionConfiguration machineDetection = null)
Models.MachineDetectionConfiguration machineDetection = null,
int? priority = null)
{
this.From = from;
this.To = to;
Expand Down Expand Up @@ -168,6 +172,11 @@ public CreateCallRequest(

this.ApplicationId = applicationId;
this.MachineDetection = machineDetection;

if (priority != null)
{
this.Priority = priority;
}
}

/// <summary>
Expand Down Expand Up @@ -422,6 +431,24 @@ public string Tag
}
}

/// <summary>
/// Gets or sets Priority.
/// </summary>
[JsonProperty("priority")]
public int? Priority
{
get
{
return this.priority;
}

set
{
this.shouldSerialize["priority"] = true;
this.priority = value;
}
}

/// <summary>
/// Gets or sets ApplicationId.
/// </summary>
Expand Down Expand Up @@ -548,6 +575,14 @@ public void UnsetTag()
this.shouldSerialize["tag"] = false;
}

/// <summary>
/// Marks the field to not be serailized.
/// </summary>
public void UnsetPriority()
{
this.shouldSerialize["priority"] = false;
}

/// <summary>
/// Checks if the field should be serialized or not.
/// </summary>
Expand Down Expand Up @@ -665,6 +700,15 @@ public bool ShouldSerializeTag()
return this.shouldSerialize["tag"];
}

/// <summary>
/// Checks if the field should be serialized or not.
/// </summary>
/// <returns>A boolean weather the field should be serialized or not.</returns>
public bool ShouldSerializePriority()
{
return this.shouldSerialize["priority"];
}

/// <inheritdoc/>
public override bool Equals(object obj)
{
Expand Down Expand Up @@ -696,7 +740,8 @@ public override bool Equals(object obj)
((this.DisconnectMethod == null && other.DisconnectMethod == null) || (this.DisconnectMethod?.Equals(other.DisconnectMethod) == true)) &&
((this.Tag == null && other.Tag == null) || (this.Tag?.Equals(other.Tag) == true)) &&
((this.ApplicationId == null && other.ApplicationId == null) || (this.ApplicationId?.Equals(other.ApplicationId) == true)) &&
((this.MachineDetection == null && other.MachineDetection == null) || (this.MachineDetection?.Equals(other.MachineDetection) == true));
((this.MachineDetection == null && other.MachineDetection == null) || (this.MachineDetection?.Equals(other.MachineDetection) == true)) &&
((this.Priority == null && other.Priority == null) || (this.Priority?.Equals(other.Priority) == true));
}

/// <inheritdoc/>
Expand Down Expand Up @@ -794,6 +839,11 @@ public override int GetHashCode()
hashCode += this.MachineDetection.GetHashCode();
}

if (this.Priority != null)
{
hashCode += this.Priority.GetHashCode();
}

return hashCode;
}

Expand Down Expand Up @@ -821,6 +871,7 @@ protected void ToString(List<string> toStringOutput)
toStringOutput.Add($"this.Tag = {(this.Tag == null ? "null" : this.Tag == string.Empty ? "" : this.Tag)}");
toStringOutput.Add($"this.ApplicationId = {(this.ApplicationId == null ? "null" : this.ApplicationId == string.Empty ? "" : this.ApplicationId)}");
toStringOutput.Add($"this.MachineDetection = {(this.MachineDetection == null ? "null" : this.MachineDetection.ToString())}");
toStringOutput.Add($"this.Priority = {(this.Priority == null ? "null" : this.Priority.ToString())}");
}
}
}
}
57 changes: 54 additions & 3 deletions Bandwidth.Standard/Voice/Models/CreateCallResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class CreateCallResponse
private string fallbackUsername;
private string fallbackPassword;
private string tag;
private int? priority;
private Dictionary<string, bool> shouldSerialize = new Dictionary<string, bool>
{
{ "answerFallbackUrl", false },
Expand All @@ -38,6 +39,7 @@ public class CreateCallResponse
{ "fallbackUsername", false },
{ "fallbackPassword", false },
{ "tag", false },
{ "priority", false }
};

/// <summary>
Expand Down Expand Up @@ -70,6 +72,7 @@ public CreateCallResponse()
/// <param name="fallbackUsername">fallbackUsername.</param>
/// <param name="fallbackPassword">fallbackPassword.</param>
/// <param name="tag">tag.</param>
/// <param name="priority">priority.</param>
public CreateCallResponse(
string accountId,
string callId,
Expand All @@ -90,7 +93,8 @@ public CreateCallResponse(
string password = null,
string fallbackUsername = null,
string fallbackPassword = null,
string tag = null)
string tag = null,
int? priority = null)
{
this.AccountId = accountId;
this.CallId = callId;
Expand Down Expand Up @@ -144,6 +148,11 @@ public CreateCallResponse(
this.Tag = tag;
}

if (priority != null)
{
this.Priority = priority;
}

}

/// <summary>
Expand Down Expand Up @@ -363,6 +372,24 @@ public string Tag
}
}

/// <summary>
/// Gets or sets Priority.
/// </summary>
[JsonProperty("priority")]
public int? Priority
{
get
{
return this.priority;
}

set
{
this.shouldSerialize["priority"] = true;
this.priority = value;
}
}

/// <inheritdoc/>
public override string ToString()
{
Expand Down Expand Up @@ -437,6 +464,14 @@ public void UnsetTag()
this.shouldSerialize["tag"] = false;
}

/// <summary>
/// Marks the field to not be serailized.
/// </summary>
public void UnsetPriority()
{
this.shouldSerialize["priority"] = false;
}

/// <summary>
/// Checks if the field should be serialized or not.
/// </summary>
Expand Down Expand Up @@ -509,6 +544,15 @@ public bool ShouldSerializeTag()
return this.shouldSerialize["tag"];
}

/// <summary>
/// Checks if the field should be serialized or not.
/// </summary>
/// <returns>A boolean weather the field should be serialized or not.</returns>
public bool ShouldSerializePriority()
{
return this.shouldSerialize["priority"];
}

/// <inheritdoc/>
public override bool Equals(object obj)
{
Expand Down Expand Up @@ -542,7 +586,8 @@ public override bool Equals(object obj)
((this.Password == null && other.Password == null) || (this.Password?.Equals(other.Password) == true)) &&
((this.FallbackUsername == null && other.FallbackUsername == null) || (this.FallbackUsername?.Equals(other.FallbackUsername) == true)) &&
((this.FallbackPassword == null && other.FallbackPassword == null) || (this.FallbackPassword?.Equals(other.FallbackPassword) == true)) &&
((this.Tag == null && other.Tag == null) || (this.Tag?.Equals(other.Tag) == true));
((this.Tag == null && other.Tag == null) || (this.Tag?.Equals(other.Tag) == true)) &&
((this.Priority == null && other.Priority == null) || (this.Priority?.Equals(other.Priority) == true));
}

/// <inheritdoc/>
Expand Down Expand Up @@ -647,6 +692,11 @@ public override int GetHashCode()
hashCode += this.Tag.GetHashCode();
}

if (this.Priority != null)
{
hashCode += this.Priority.GetHashCode();
}

return hashCode;
}

Expand Down Expand Up @@ -676,6 +726,7 @@ protected void ToString(List<string> toStringOutput)
toStringOutput.Add($"this.FallbackUsername = {(this.FallbackUsername == null ? "null" : this.FallbackUsername == string.Empty ? "" : this.FallbackUsername)}");
toStringOutput.Add($"this.FallbackPassword = {(this.FallbackPassword == null ? "null" : this.FallbackPassword == string.Empty ? "" : this.FallbackPassword)}");
toStringOutput.Add($"this.Tag = {(this.Tag == null ? "null" : this.Tag == string.Empty ? "" : this.Tag)}");
toStringOutput.Add($"this.Priority = {(this.Priority == null ? "null" : this.Priority.ToString())}");
}
}
}
}
29 changes: 29 additions & 0 deletions Bandwidth.StandardTests/Voice/CreateCallTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,35 @@ public async Task CreateCallWithMachineDetectionReturnsCreated()
Assert.Equal(DisconnectMethodEnum.POST, createCallResponse.Data.DisconnectMethod);
}

[Fact]
public async Task CreateCallWithPriorityReturnsCreated()
{
var accountId = TestConstants.AccountId;
var to = TestConstants.To;
var from = TestConstants.From;
var applicationId = TestConstants.VoiceApplicationId;
var answerUrl = string.Concat(TestConstants.BaseCallbackUrl, "/callbacks/answer");
var priority = 4;

var request = new CreateCallRequest()
{
ApplicationId = applicationId,
To = to,
From = from,
AnswerUrl = answerUrl,
Priority = priority
};

var createCallResponse = await _client.Voice.APIController.CreateCallAsync(accountId, request);

Assert.Equal(201, createCallResponse.StatusCode);

Assert.Equal(applicationId, createCallResponse.Data.ApplicationId);
Assert.Equal(to, createCallResponse.Data.To);
Assert.Equal(from, createCallResponse.Data.From);
Assert.Equal(priority, createCallResponse.Data.Priority);
}

[Fact]
public async Task CreateCallInvalidToPhoneNumberThrows()
{
Expand Down