diff --git a/Vonage.Test/Messages/Mms/Data/SendMmsAudioAsyncReturnsOk-response.json b/Vonage.Test/Messages/Mms/Data/SendMessageReturnsOk-response.json
similarity index 100%
rename from Vonage.Test/Messages/Mms/Data/SendMmsAudioAsyncReturnsOk-response.json
rename to Vonage.Test/Messages/Mms/Data/SendMessageReturnsOk-response.json
diff --git a/Vonage.Test/Messages/Mms/Data/SendMmsAudioAsyncReturnsOkWithTtl-request.json b/Vonage.Test/Messages/Mms/Data/SendMmsAudioAsyncReturnsOkWithTtl-request.json
new file mode 100644
index 000000000..decb5dc8e
--- /dev/null
+++ b/Vonage.Test/Messages/Mms/Data/SendMmsAudioAsyncReturnsOkWithTtl-request.json
@@ -0,0 +1,12 @@
+{
+ "channel": "mms",
+ "message_type": "audio",
+ "to": "441234567890",
+ "from": "015417543010",
+ "client_ref": "abcdefg",
+ "audio": {
+ "url": "https://test.com/me.mp3",
+ "caption": "Sounds I make"
+ },
+ "ttl": 600
+}
\ No newline at end of file
diff --git a/Vonage.Test/Messages/Mms/Data/SendMmsImageAsyncReturnsOk-response.json b/Vonage.Test/Messages/Mms/Data/SendMmsImageAsyncReturnsOk-response.json
deleted file mode 100644
index d9cb11686..000000000
--- a/Vonage.Test/Messages/Mms/Data/SendMmsImageAsyncReturnsOk-response.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "message_uuid": "aaaaaaaa-bbbb-cccc-dddd-0123456789ab"
-}
\ No newline at end of file
diff --git a/Vonage.Test/Messages/Mms/Data/SendMmsImageAsyncReturnsOkWithTtl-request.json b/Vonage.Test/Messages/Mms/Data/SendMmsImageAsyncReturnsOkWithTtl-request.json
new file mode 100644
index 000000000..3549be4bf
--- /dev/null
+++ b/Vonage.Test/Messages/Mms/Data/SendMmsImageAsyncReturnsOkWithTtl-request.json
@@ -0,0 +1,11 @@
+{
+ "channel": "mms",
+ "message_type": "image",
+ "to": "441234567890",
+ "from": "015417543010",
+ "client_ref": "abcdefg",
+ "image": {
+ "url": "https://test.com/image.png"
+ },
+ "ttl": 600
+}
\ No newline at end of file
diff --git a/Vonage.Test/Messages/Mms/Data/SendMmsVcardAsyncReturnsOk-response.json b/Vonage.Test/Messages/Mms/Data/SendMmsVcardAsyncReturnsOk-response.json
deleted file mode 100644
index d9cb11686..000000000
--- a/Vonage.Test/Messages/Mms/Data/SendMmsVcardAsyncReturnsOk-response.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "message_uuid": "aaaaaaaa-bbbb-cccc-dddd-0123456789ab"
-}
\ No newline at end of file
diff --git a/Vonage.Test/Messages/Mms/Data/SendMmsVcardAsyncReturnsOkWithTtl-request.json b/Vonage.Test/Messages/Mms/Data/SendMmsVcardAsyncReturnsOkWithTtl-request.json
new file mode 100644
index 000000000..614752e33
--- /dev/null
+++ b/Vonage.Test/Messages/Mms/Data/SendMmsVcardAsyncReturnsOkWithTtl-request.json
@@ -0,0 +1,11 @@
+{
+ "channel": "mms",
+ "message_type": "vcard",
+ "to": "441234567890",
+ "from": "015417543010",
+ "client_ref": "abcdefg",
+ "vcard": {
+ "url": "https://test.com/contact.vcf"
+ },
+ "ttl": 600
+}
\ No newline at end of file
diff --git a/Vonage.Test/Messages/Mms/Data/SendMmsVideoAsyncReturnsOk-response.json b/Vonage.Test/Messages/Mms/Data/SendMmsVideoAsyncReturnsOk-response.json
deleted file mode 100644
index d9cb11686..000000000
--- a/Vonage.Test/Messages/Mms/Data/SendMmsVideoAsyncReturnsOk-response.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "message_uuid": "aaaaaaaa-bbbb-cccc-dddd-0123456789ab"
-}
\ No newline at end of file
diff --git a/Vonage.Test/Messages/Mms/Data/SendMmsVideoAsyncReturnsOkWithTtl-request.json b/Vonage.Test/Messages/Mms/Data/SendMmsVideoAsyncReturnsOkWithTtl-request.json
new file mode 100644
index 000000000..d0ba41316
--- /dev/null
+++ b/Vonage.Test/Messages/Mms/Data/SendMmsVideoAsyncReturnsOkWithTtl-request.json
@@ -0,0 +1,12 @@
+{
+ "channel": "mms",
+ "message_type": "video",
+ "to": "441234567890",
+ "from": "015417543010",
+ "client_ref": "abcdefg",
+ "video": {
+ "url": "https://test.com/image.mp4",
+ "caption": "A video of me"
+ },
+ "ttl": 600
+}
\ No newline at end of file
diff --git a/Vonage.Test/Messages/Mms/MmsMessagesTest.cs b/Vonage.Test/Messages/Mms/MmsMessagesTest.cs
index db843fc0d..08841419a 100644
--- a/Vonage.Test/Messages/Mms/MmsMessagesTest.cs
+++ b/Vonage.Test/Messages/Mms/MmsMessagesTest.cs
@@ -12,22 +12,24 @@ namespace Vonage.Test.Messages.Mms;
[Trait("Category", "Legacy")]
public class MmsMessagesTest : TestBase
{
+ private const string ResponseKey = "SendMessageReturnsOk";
+ private readonly VonageClient client;
+ private readonly string expectedResponse;
private readonly string expectedUri;
- private readonly SerializationTestHelper helper;
+
+ private readonly SerializationTestHelper helper = new SerializationTestHelper(typeof(MmsMessagesTest).Namespace,
+ JsonSerializerBuilder.BuildWithCamelCase());
public MmsMessagesTest()
{
this.expectedUri = $"{this.ApiUrl}/v1/messages";
- this.helper =
- new SerializationTestHelper(typeof(MmsMessagesTest).Namespace,
- JsonSerializerBuilder.BuildWithCamelCase());
+ this.client = this.BuildVonageClient(Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey));
+ this.expectedResponse = this.helper.GetResponseJson(ResponseKey);
}
[Fact]
public async Task SendMmsAudioAsyncReturnsOk()
{
- var expectedResponse = this.helper.GetResponseJson();
- var expectedRequest = this.helper.GetRequestJson();
var request = new MmsAudioRequest
{
To = "441234567890",
@@ -39,19 +41,38 @@ public async Task SendMmsAudioAsyncReturnsOk()
},
ClientRef = "abcdefg",
};
- var creds = Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey);
- this.Setup(this.expectedUri, expectedResponse, expectedRequest);
- var client = this.BuildVonageClient(creds);
- var response = await client.MessagesClient.SendAsync(request);
+ await this.AssertResponse(request, this.helper.GetRequestJson());
+ }
+
+ private async Task AssertResponse(IMessage request, string expectedRequest)
+ {
+ this.Setup(this.expectedUri, this.expectedResponse, expectedRequest);
+ var response = await this.client.MessagesClient.SendAsync(request);
Assert.NotNull(response);
Assert.Equal(new Guid("aaaaaaaa-bbbb-cccc-dddd-0123456789ab"), response.MessageUuid);
}
+ [Fact]
+ public async Task SendMmsAudioAsyncReturnsOkWithTtl()
+ {
+ var request = new MmsAudioRequest
+ {
+ To = "441234567890",
+ From = "015417543010",
+ Audio = new CaptionedAttachment
+ {
+ Url = "https://test.com/me.mp3",
+ Caption = "Sounds I make",
+ },
+ ClientRef = "abcdefg",
+ TimeToLive = 600,
+ };
+ await this.AssertResponse(request, this.helper.GetRequestJson());
+ }
+
[Fact]
public async Task SendMmsImageAsyncReturnsOk()
{
- var expectedResponse = this.helper.GetResponseJson();
- var expectedRequest = this.helper.GetRequestJson();
var request = new MmsImageRequest
{
To = "441234567890",
@@ -62,19 +83,29 @@ public async Task SendMmsImageAsyncReturnsOk()
},
ClientRef = "abcdefg",
};
- var creds = Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey);
- this.Setup(this.expectedUri, expectedResponse, expectedRequest);
- var client = this.BuildVonageClient(creds);
- var response = await client.MessagesClient.SendAsync(request);
- Assert.NotNull(response);
- Assert.Equal(new Guid("aaaaaaaa-bbbb-cccc-dddd-0123456789ab"), response.MessageUuid);
+ await this.AssertResponse(request, this.helper.GetRequestJson());
+ }
+
+ [Fact]
+ public async Task SendMmsImageAsyncReturnsOkWithTtl()
+ {
+ var request = new MmsImageRequest
+ {
+ To = "441234567890",
+ From = "015417543010",
+ Image = new Attachment
+ {
+ Url = "https://test.com/image.png",
+ },
+ ClientRef = "abcdefg",
+ TimeToLive = 600,
+ };
+ await this.AssertResponse(request, this.helper.GetRequestJson());
}
[Fact]
public async Task SendMmsVcardAsyncReturnsOk()
{
- var expectedResponse = this.helper.GetResponseJson();
- var expectedRequest = this.helper.GetRequestJson();
var request = new MmsVcardRequest
{
To = "441234567890",
@@ -85,19 +116,29 @@ public async Task SendMmsVcardAsyncReturnsOk()
},
ClientRef = "abcdefg",
};
- var creds = Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey);
- this.Setup(this.expectedUri, expectedResponse, expectedRequest);
- var client = this.BuildVonageClient(creds);
- var response = await client.MessagesClient.SendAsync(request);
- Assert.NotNull(response);
- Assert.Equal(new Guid("aaaaaaaa-bbbb-cccc-dddd-0123456789ab"), response.MessageUuid);
+ await this.AssertResponse(request, this.helper.GetRequestJson());
+ }
+
+ [Fact]
+ public async Task SendMmsVcardAsyncReturnsOkWithTtl()
+ {
+ var request = new MmsVcardRequest
+ {
+ To = "441234567890",
+ From = "015417543010",
+ Vcard = new Attachment
+ {
+ Url = "https://test.com/contact.vcf",
+ },
+ ClientRef = "abcdefg",
+ TimeToLive = 600,
+ };
+ await this.AssertResponse(request, this.helper.GetRequestJson());
}
[Fact]
public async Task SendMmsVideoAsyncReturnsOk()
{
- var expectedResponse = this.helper.GetResponseJson();
- var expectedRequest = this.helper.GetRequestJson();
var request = new MmsVideoRequest
{
To = "441234567890",
@@ -109,11 +150,24 @@ public async Task SendMmsVideoAsyncReturnsOk()
},
ClientRef = "abcdefg",
};
- var creds = Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey);
- this.Setup(this.expectedUri, expectedResponse, expectedRequest);
- var client = this.BuildVonageClient(creds);
- var response = await client.MessagesClient.SendAsync(request);
- Assert.NotNull(response);
- Assert.Equal(new Guid("aaaaaaaa-bbbb-cccc-dddd-0123456789ab"), response.MessageUuid);
+ await this.AssertResponse(request, this.helper.GetRequestJson());
+ }
+
+ [Fact]
+ public async Task SendMmsVideoAsyncReturnsOkWithTtl()
+ {
+ var request = new MmsVideoRequest
+ {
+ To = "441234567890",
+ From = "015417543010",
+ Video = new CaptionedAttachment
+ {
+ Url = "https://test.com/image.mp4",
+ Caption = "A video of me",
+ },
+ ClientRef = "abcdefg",
+ TimeToLive = 600,
+ };
+ await this.AssertResponse(request, this.helper.GetRequestJson());
}
}
\ No newline at end of file
diff --git a/Vonage.Test/Vonage.Test.csproj b/Vonage.Test/Vonage.Test.csproj
index 66d4ef61e..41a7c9994 100644
--- a/Vonage.Test/Vonage.Test.csproj
+++ b/Vonage.Test/Vonage.Test.csproj
@@ -317,27 +317,15 @@
PreserveNewest
-
- PreserveNewest
-
PreserveNewest
-
- PreserveNewest
-
PreserveNewest
-
- PreserveNewest
-
PreserveNewest
-
- PreserveNewest
-
PreserveNewest
@@ -682,7 +670,6 @@
PreserveNewest
-
PreserveNewest
@@ -1248,6 +1235,21 @@
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
diff --git a/Vonage/Messages/Mms/MmsAudioRequest.cs b/Vonage/Messages/Mms/MmsAudioRequest.cs
index dcde6313b..64d522713 100644
--- a/Vonage/Messages/Mms/MmsAudioRequest.cs
+++ b/Vonage/Messages/Mms/MmsAudioRequest.cs
@@ -9,4 +9,13 @@ public class MmsAudioRequest : MessageRequestBase
public override MessagesChannel Channel => MessagesChannel.MMS;
public override MessagesMessageType MessageType => MessagesMessageType.Audio;
+
+ ///
+ /// Time-To-Live (how long a message should exist before it is delivered successfully) in seconds. If a message is not
+ /// delivered successfully within the TTL time, the message is considered expired and will be rejected if TTL is
+ /// supported.
+ ///
+ [JsonPropertyName("ttl")]
+ [JsonPropertyOrder(7)]
+ public int? TimeToLive { get; set; }
}
\ No newline at end of file
diff --git a/Vonage/Messages/Mms/MmsImageRequest.cs b/Vonage/Messages/Mms/MmsImageRequest.cs
index 7454e4e64..f8d105580 100644
--- a/Vonage/Messages/Mms/MmsImageRequest.cs
+++ b/Vonage/Messages/Mms/MmsImageRequest.cs
@@ -8,4 +8,13 @@ public class MmsImageRequest : MessageRequestBase
[JsonPropertyOrder(6)] public Attachment Image { get; set; }
public override MessagesMessageType MessageType => MessagesMessageType.Image;
+
+ ///
+ /// Time-To-Live (how long a message should exist before it is delivered successfully) in seconds. If a message is not
+ /// delivered successfully within the TTL time, the message is considered expired and will be rejected if TTL is
+ /// supported.
+ ///
+ [JsonPropertyOrder(7)]
+ [JsonPropertyName("ttl")]
+ public int? TimeToLive { get; set; }
}
\ No newline at end of file
diff --git a/Vonage/Messages/Mms/MmsVcardRequest.cs b/Vonage/Messages/Mms/MmsVcardRequest.cs
index 0020abfe8..d70c99b15 100644
--- a/Vonage/Messages/Mms/MmsVcardRequest.cs
+++ b/Vonage/Messages/Mms/MmsVcardRequest.cs
@@ -8,4 +8,13 @@ public class MmsVcardRequest : MessageRequestBase
public override MessagesMessageType MessageType => MessagesMessageType.Vcard;
[JsonPropertyOrder(6)] public Attachment Vcard { get; set; }
+
+ ///
+ /// Time-To-Live (how long a message should exist before it is delivered successfully) in seconds. If a message is not
+ /// delivered successfully within the TTL time, the message is considered expired and will be rejected if TTL is
+ /// supported.
+ ///
+ [JsonPropertyName("ttl")]
+ [JsonPropertyOrder(7)]
+ public int? TimeToLive { get; set; }
}
\ No newline at end of file
diff --git a/Vonage/Messages/Mms/MmsVideoRequest.cs b/Vonage/Messages/Mms/MmsVideoRequest.cs
index 379a8670f..2b29fd219 100644
--- a/Vonage/Messages/Mms/MmsVideoRequest.cs
+++ b/Vonage/Messages/Mms/MmsVideoRequest.cs
@@ -8,4 +8,13 @@ public class MmsVideoRequest : MessageRequestBase
public override MessagesMessageType MessageType => MessagesMessageType.Video;
[JsonPropertyOrder(6)] public CaptionedAttachment Video { get; set; }
+
+ ///
+ /// Time-To-Live (how long a message should exist before it is delivered successfully) in seconds. If a message is not
+ /// delivered successfully within the TTL time, the message is considered expired and will be rejected if TTL is
+ /// supported.
+ ///
+ [JsonPropertyName("ttl")]
+ [JsonPropertyOrder(7)]
+ public int? TimeToLive { get; set; }
}
\ No newline at end of file