Skip to content

Commit ffc8e9c

Browse files
authored
Merge pull request #46 from Bandwidth/DX-2476
DX-2476 Add `priority` to `createCallRequest` and `createCallResponse` models
2 parents b99307e + 4e89257 commit ffc8e9c

File tree

3 files changed

+137
-6
lines changed

3 files changed

+137
-6
lines changed

Bandwidth.Standard/Voice/Models/CreateCallRequest.cs

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class CreateCallRequest
3333
private string disconnectUrl;
3434
private Models.DisconnectMethodEnum? disconnectMethod;
3535
private string tag;
36+
private int? priority;
3637
private Dictionary<string, bool> shouldSerialize = new Dictionary<string, bool>
3738
{
3839
{ "uui", false },
@@ -48,6 +49,7 @@ public class CreateCallRequest
4849
{ "disconnectUrl", false },
4950
{ "disconnectMethod", false },
5051
{ "tag", false },
52+
{ "priority", false },
5153
};
5254

5355
/// <summary>
@@ -78,6 +80,7 @@ public CreateCallRequest()
7880
/// <param name="disconnectMethod">disconnectMethod.</param>
7981
/// <param name="tag">tag.</param>
8082
/// <param name="machineDetection">machineDetection.</param>
83+
/// <param name="priority">priority.</param>
8184
public CreateCallRequest(
8285
string from,
8386
string to,
@@ -96,7 +99,8 @@ public CreateCallRequest(
9699
string disconnectUrl = null,
97100
Models.DisconnectMethodEnum? disconnectMethod = null,
98101
string tag = null,
99-
Models.MachineDetectionConfiguration machineDetection = null)
102+
Models.MachineDetectionConfiguration machineDetection = null,
103+
int? priority = null)
100104
{
101105
this.From = from;
102106
this.To = to;
@@ -168,6 +172,11 @@ public CreateCallRequest(
168172

169173
this.ApplicationId = applicationId;
170174
this.MachineDetection = machineDetection;
175+
176+
if (priority != null)
177+
{
178+
this.Priority = priority;
179+
}
171180
}
172181

173182
/// <summary>
@@ -422,6 +431,24 @@ public string Tag
422431
}
423432
}
424433

434+
/// <summary>
435+
/// Gets or sets Priority.
436+
/// </summary>
437+
[JsonProperty("priority")]
438+
public int? Priority
439+
{
440+
get
441+
{
442+
return this.priority;
443+
}
444+
445+
set
446+
{
447+
this.shouldSerialize["priority"] = true;
448+
this.priority = value;
449+
}
450+
}
451+
425452
/// <summary>
426453
/// Gets or sets ApplicationId.
427454
/// </summary>
@@ -548,6 +575,14 @@ public void UnsetTag()
548575
this.shouldSerialize["tag"] = false;
549576
}
550577

578+
/// <summary>
579+
/// Marks the field to not be serailized.
580+
/// </summary>
581+
public void UnsetPriority()
582+
{
583+
this.shouldSerialize["priority"] = false;
584+
}
585+
551586
/// <summary>
552587
/// Checks if the field should be serialized or not.
553588
/// </summary>
@@ -665,6 +700,15 @@ public bool ShouldSerializeTag()
665700
return this.shouldSerialize["tag"];
666701
}
667702

703+
/// <summary>
704+
/// Checks if the field should be serialized or not.
705+
/// </summary>
706+
/// <returns>A boolean weather the field should be serialized or not.</returns>
707+
public bool ShouldSerializePriority()
708+
{
709+
return this.shouldSerialize["priority"];
710+
}
711+
668712
/// <inheritdoc/>
669713
public override bool Equals(object obj)
670714
{
@@ -696,7 +740,8 @@ public override bool Equals(object obj)
696740
((this.DisconnectMethod == null && other.DisconnectMethod == null) || (this.DisconnectMethod?.Equals(other.DisconnectMethod) == true)) &&
697741
((this.Tag == null && other.Tag == null) || (this.Tag?.Equals(other.Tag) == true)) &&
698742
((this.ApplicationId == null && other.ApplicationId == null) || (this.ApplicationId?.Equals(other.ApplicationId) == true)) &&
699-
((this.MachineDetection == null && other.MachineDetection == null) || (this.MachineDetection?.Equals(other.MachineDetection) == true));
743+
((this.MachineDetection == null && other.MachineDetection == null) || (this.MachineDetection?.Equals(other.MachineDetection) == true)) &&
744+
((this.Priority == null && other.Priority == null) || (this.Priority?.Equals(other.Priority) == true));
700745
}
701746

702747
/// <inheritdoc/>
@@ -794,6 +839,11 @@ public override int GetHashCode()
794839
hashCode += this.MachineDetection.GetHashCode();
795840
}
796841

842+
if (this.Priority != null)
843+
{
844+
hashCode += this.Priority.GetHashCode();
845+
}
846+
797847
return hashCode;
798848
}
799849

@@ -821,6 +871,7 @@ protected void ToString(List<string> toStringOutput)
821871
toStringOutput.Add($"this.Tag = {(this.Tag == null ? "null" : this.Tag == string.Empty ? "" : this.Tag)}");
822872
toStringOutput.Add($"this.ApplicationId = {(this.ApplicationId == null ? "null" : this.ApplicationId == string.Empty ? "" : this.ApplicationId)}");
823873
toStringOutput.Add($"this.MachineDetection = {(this.MachineDetection == null ? "null" : this.MachineDetection.ToString())}");
874+
toStringOutput.Add($"this.Priority = {(this.Priority == null ? "null" : this.Priority.ToString())}");
824875
}
825876
}
826-
}
877+
}

Bandwidth.Standard/Voice/Models/CreateCallResponse.cs

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class CreateCallResponse
2828
private string fallbackUsername;
2929
private string fallbackPassword;
3030
private string tag;
31+
private int? priority;
3132
private Dictionary<string, bool> shouldSerialize = new Dictionary<string, bool>
3233
{
3334
{ "answerFallbackUrl", false },
@@ -38,6 +39,7 @@ public class CreateCallResponse
3839
{ "fallbackUsername", false },
3940
{ "fallbackPassword", false },
4041
{ "tag", false },
42+
{ "priority", false }
4143
};
4244

4345
/// <summary>
@@ -70,6 +72,7 @@ public CreateCallResponse()
7072
/// <param name="fallbackUsername">fallbackUsername.</param>
7173
/// <param name="fallbackPassword">fallbackPassword.</param>
7274
/// <param name="tag">tag.</param>
75+
/// <param name="priority">priority.</param>
7376
public CreateCallResponse(
7477
string accountId,
7578
string callId,
@@ -90,7 +93,8 @@ public CreateCallResponse(
9093
string password = null,
9194
string fallbackUsername = null,
9295
string fallbackPassword = null,
93-
string tag = null)
96+
string tag = null,
97+
int? priority = null)
9498
{
9599
this.AccountId = accountId;
96100
this.CallId = callId;
@@ -144,6 +148,11 @@ public CreateCallResponse(
144148
this.Tag = tag;
145149
}
146150

151+
if (priority != null)
152+
{
153+
this.Priority = priority;
154+
}
155+
147156
}
148157

149158
/// <summary>
@@ -363,6 +372,24 @@ public string Tag
363372
}
364373
}
365374

375+
/// <summary>
376+
/// Gets or sets Priority.
377+
/// </summary>
378+
[JsonProperty("priority")]
379+
public int? Priority
380+
{
381+
get
382+
{
383+
return this.priority;
384+
}
385+
386+
set
387+
{
388+
this.shouldSerialize["priority"] = true;
389+
this.priority = value;
390+
}
391+
}
392+
366393
/// <inheritdoc/>
367394
public override string ToString()
368395
{
@@ -437,6 +464,14 @@ public void UnsetTag()
437464
this.shouldSerialize["tag"] = false;
438465
}
439466

467+
/// <summary>
468+
/// Marks the field to not be serailized.
469+
/// </summary>
470+
public void UnsetPriority()
471+
{
472+
this.shouldSerialize["priority"] = false;
473+
}
474+
440475
/// <summary>
441476
/// Checks if the field should be serialized or not.
442477
/// </summary>
@@ -509,6 +544,15 @@ public bool ShouldSerializeTag()
509544
return this.shouldSerialize["tag"];
510545
}
511546

547+
/// <summary>
548+
/// Checks if the field should be serialized or not.
549+
/// </summary>
550+
/// <returns>A boolean weather the field should be serialized or not.</returns>
551+
public bool ShouldSerializePriority()
552+
{
553+
return this.shouldSerialize["priority"];
554+
}
555+
512556
/// <inheritdoc/>
513557
public override bool Equals(object obj)
514558
{
@@ -542,7 +586,8 @@ public override bool Equals(object obj)
542586
((this.Password == null && other.Password == null) || (this.Password?.Equals(other.Password) == true)) &&
543587
((this.FallbackUsername == null && other.FallbackUsername == null) || (this.FallbackUsername?.Equals(other.FallbackUsername) == true)) &&
544588
((this.FallbackPassword == null && other.FallbackPassword == null) || (this.FallbackPassword?.Equals(other.FallbackPassword) == true)) &&
545-
((this.Tag == null && other.Tag == null) || (this.Tag?.Equals(other.Tag) == true));
589+
((this.Tag == null && other.Tag == null) || (this.Tag?.Equals(other.Tag) == true)) &&
590+
((this.Priority == null && other.Priority == null) || (this.Priority?.Equals(other.Priority) == true));
546591
}
547592

548593
/// <inheritdoc/>
@@ -647,6 +692,11 @@ public override int GetHashCode()
647692
hashCode += this.Tag.GetHashCode();
648693
}
649694

695+
if (this.Priority != null)
696+
{
697+
hashCode += this.Priority.GetHashCode();
698+
}
699+
650700
return hashCode;
651701
}
652702

@@ -676,6 +726,7 @@ protected void ToString(List<string> toStringOutput)
676726
toStringOutput.Add($"this.FallbackUsername = {(this.FallbackUsername == null ? "null" : this.FallbackUsername == string.Empty ? "" : this.FallbackUsername)}");
677727
toStringOutput.Add($"this.FallbackPassword = {(this.FallbackPassword == null ? "null" : this.FallbackPassword == string.Empty ? "" : this.FallbackPassword)}");
678728
toStringOutput.Add($"this.Tag = {(this.Tag == null ? "null" : this.Tag == string.Empty ? "" : this.Tag)}");
729+
toStringOutput.Add($"this.Priority = {(this.Priority == null ? "null" : this.Priority.ToString())}");
679730
}
680731
}
681-
}
732+
}

Bandwidth.StandardTests/Voice/CreateCallTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,35 @@ public async Task CreateCallWithMachineDetectionReturnsCreated()
8181
Assert.Equal(DisconnectMethodEnum.POST, createCallResponse.Data.DisconnectMethod);
8282
}
8383

84+
[Fact]
85+
public async Task CreateCallWithPriorityReturnsCreated()
86+
{
87+
var accountId = TestConstants.AccountId;
88+
var to = TestConstants.To;
89+
var from = TestConstants.From;
90+
var applicationId = TestConstants.VoiceApplicationId;
91+
var answerUrl = string.Concat(TestConstants.BaseCallbackUrl, "/callbacks/answer");
92+
var priority = 4;
93+
94+
var request = new CreateCallRequest()
95+
{
96+
ApplicationId = applicationId,
97+
To = to,
98+
From = from,
99+
AnswerUrl = answerUrl,
100+
Priority = priority
101+
};
102+
103+
var createCallResponse = await _client.Voice.APIController.CreateCallAsync(accountId, request);
104+
105+
Assert.Equal(201, createCallResponse.StatusCode);
106+
107+
Assert.Equal(applicationId, createCallResponse.Data.ApplicationId);
108+
Assert.Equal(to, createCallResponse.Data.To);
109+
Assert.Equal(from, createCallResponse.Data.From);
110+
Assert.Equal(priority, createCallResponse.Data.Priority);
111+
}
112+
84113
[Fact]
85114
public async Task CreateCallInvalidToPhoneNumberThrows()
86115
{

0 commit comments

Comments
 (0)