Skip to content

Commit

Permalink
feat: add Webhook url and version for Messages requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tr00d committed Aug 6, 2024
1 parent 2100a43 commit feb5153
Show file tree
Hide file tree
Showing 66 changed files with 560 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"client_ref": "abcdefg",
"audio": {
"url": "https://test.com/voice.mp3"
}
},
"webhook_version": "v1",
"webhook_url": "https://example.com/status"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"client_ref": "abcdefg",
"file": {
"url": "https://test.com/me.txt"
}
},
"webhook_version": "v1",
"webhook_url": "https://example.com/status"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"client_ref": "abcdefg",
"image": {
"url": "https://test.com/image.png"
}
},
"webhook_version": "v1",
"webhook_url": "https://example.com/status"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"text": "Hello mum",
"to": "441234567890",
"from": "015417543010",
"client_ref": "abcdefg"
"client_ref": "abcdefg",
"webhook_version": "v1",
"webhook_url": "https://example.com/status"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
},
"to": "441234567890",
"from": "015417543010",
"client_ref": "abcdefg"
"client_ref": "abcdefg",
"webhook_version": "v1",
"webhook_url": "https://example.com/status"
}
12 changes: 12 additions & 0 deletions Vonage.Test/Messages/Messenger/MessengerMessagesTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#region
using System;
using System.Threading.Tasks;
using Vonage.Messages;
Expand All @@ -6,6 +7,7 @@
using Vonage.Serialization;
using Vonage.Test.Common;
using Xunit;
#endregion

namespace Vonage.Test.Messages.Messenger;

Expand Down Expand Up @@ -36,6 +38,8 @@ public async Task SendMessengerAudioAsyncReturnsOk()
Url = "https://test.com/voice.mp3",
},
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
};
var creds = Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey);
this.Setup(this.expectedUri, expectedResponse, expectedRequest);
Expand All @@ -59,6 +63,8 @@ public async Task SendMessengerFileAsyncReturnsOk()
Url = "https://test.com/me.txt",
},
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
};
var credentials = Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey);
this.Setup(this.expectedUri, expectedResponse, expectedRequest);
Expand All @@ -82,6 +88,8 @@ public async Task SendMessengerImageAsyncReturnsOk()
Url = "https://test.com/image.png",
},
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
};
var credentials = Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey);
this.Setup(this.expectedUri, expectedResponse, expectedRequest);
Expand All @@ -102,6 +110,8 @@ public async Task SendMessengerTextAsyncReturnsOk()
From = "015417543010",
Text = "Hello mum",
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
};
var creds = Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey);
this.Setup(this.expectedUri, expectedResponse, expectedRequest);
Expand All @@ -125,6 +135,8 @@ public async Task SendMessengerVideoAsyncReturnsOk()
Url = "https://test.com/me.mp4",
},
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
};
var creds = Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey);
this.Setup(this.expectedUri, expectedResponse, expectedRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"to": "441234567890",
"from": "015417543010",
"client_ref": "abcdefg",
"webhook_version": "v1",
"webhook_url": "https://example.com/status",
"audio": {
"url": "https://test.com/me.mp3",
"caption": "Sounds I make"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"to": "441234567890",
"from": "015417543010",
"client_ref": "abcdefg",
"webhook_version": "v1",
"webhook_url": "https://example.com/status",
"audio": {
"url": "https://test.com/me.mp3",
"caption": "Sounds I make"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"to": "441234567890",
"from": "015417543010",
"client_ref": "abcdefg",
"webhook_version": "v1",
"webhook_url": "https://example.com/status",
"image": {
"url": "https://test.com/image.png"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"to": "441234567890",
"from": "015417543010",
"client_ref": "abcdefg",
"webhook_version": "v1",
"webhook_url": "https://example.com/status",
"image": {
"url": "https://test.com/image.png"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"to": "441234567890",
"from": "015417543010",
"client_ref": "abcdefg",
"webhook_version": "v1",
"webhook_url": "https://example.com/status",
"vcard": {
"url": "https://test.com/contact.vcf"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"to": "441234567890",
"from": "015417543010",
"client_ref": "abcdefg",
"webhook_version": "v1",
"webhook_url": "https://example.com/status",
"vcard": {
"url": "https://test.com/contact.vcf"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"to": "441234567890",
"from": "015417543010",
"client_ref": "abcdefg",
"webhook_version": "v1",
"webhook_url": "https://example.com/status",
"video": {
"url": "https://test.com/image.mp4",
"caption": "A video of me"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"to": "441234567890",
"from": "015417543010",
"client_ref": "abcdefg",
"webhook_version": "v1",
"webhook_url": "https://example.com/status",
"video": {
"url": "https://test.com/image.mp4",
"caption": "A video of me"
Expand Down
18 changes: 18 additions & 0 deletions Vonage.Test/Messages/Mms/MmsMessagesTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#region
using System;
using System.Threading.Tasks;
using Vonage.Messages;
Expand All @@ -6,6 +7,7 @@
using Vonage.Serialization;
using Vonage.Test.Common;
using Xunit;
#endregion

namespace Vonage.Test.Messages.Mms;

Expand Down Expand Up @@ -40,6 +42,8 @@ public async Task SendMmsAudioAsyncReturnsOk()
Caption = "Sounds I make",
},
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
};
await this.AssertResponse(request, this.helper.GetRequestJson());
}
Expand All @@ -65,6 +69,8 @@ public async Task SendMmsAudioAsyncReturnsOkWithTtl()
Caption = "Sounds I make",
},
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
TimeToLive = 600,
};
await this.AssertResponse(request, this.helper.GetRequestJson());
Expand All @@ -82,6 +88,8 @@ public async Task SendMmsImageAsyncReturnsOk()
Url = "https://test.com/image.png",
},
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
};
await this.AssertResponse(request, this.helper.GetRequestJson());
}
Expand All @@ -98,6 +106,8 @@ public async Task SendMmsImageAsyncReturnsOkWithTtl()
Url = "https://test.com/image.png",
},
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
TimeToLive = 600,
};
await this.AssertResponse(request, this.helper.GetRequestJson());
Expand All @@ -115,6 +125,8 @@ public async Task SendMmsVcardAsyncReturnsOk()
Url = "https://test.com/contact.vcf",
},
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
};
await this.AssertResponse(request, this.helper.GetRequestJson());
}
Expand All @@ -131,6 +143,8 @@ public async Task SendMmsVcardAsyncReturnsOkWithTtl()
Url = "https://test.com/contact.vcf",
},
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
TimeToLive = 600,
};
await this.AssertResponse(request, this.helper.GetRequestJson());
Expand All @@ -149,6 +163,8 @@ public async Task SendMmsVideoAsyncReturnsOk()
Caption = "A video of me",
},
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
};
await this.AssertResponse(request, this.helper.GetRequestJson());
}
Expand All @@ -166,6 +182,8 @@ public async Task SendMmsVideoAsyncReturnsOkWithTtl()
Caption = "A video of me",
},
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
TimeToLive = 600,
};
await this.AssertResponse(request, this.helper.GetRequestJson());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"text": "This is a test",
"to": "441234567890",
"from": "015417543010",
"client_ref": "abcdefg"
"client_ref": "abcdefg",
"webhook_version": "v1",
"webhook_url": "https://example.com/status"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"text": "This is a test",
"to": "441234567890",
"from": "015417543010",
"client_ref": "abcdefg"
"client_ref": "abcdefg",
"webhook_version": "v1",
"webhook_url": "https://example.com/status"
}
6 changes: 6 additions & 0 deletions Vonage.Test/Messages/Sms/SmsMessagesTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#region
using System;
using System.Net;
using System.Threading.Tasks;
Expand All @@ -7,6 +8,7 @@
using Vonage.Serialization;
using Vonage.Test.Common;
using Xunit;
#endregion

namespace Vonage.Test.Messages.Sms;

Expand Down Expand Up @@ -35,6 +37,8 @@ public async Task SendSmsAsyncReturnsInvalidCredentials()
From = "015417543010",
Text = "This is a test",
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
};
var creds = Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey);
this.Setup(this.expectedUri, expectedResponse, expectedRequest, HttpStatusCode.Unauthorized);
Expand All @@ -57,6 +61,8 @@ public async Task SendSmsAsyncReturnsOk()
From = "015417543010",
Text = "This is a test",
ClientRef = "abcdefg",
WebhookUrl = new Uri("https://example.com/status"),
WebhookVersion = "v1",
};
var creds = Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey);
this.Setup(this.expectedUri, expectedResponse, expectedRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
"file": {
"url": "https://example.com/files/",
"name": "example.pdf"
}
},
"webhook_version": "v1",
"webhook_url": "https://example.com/status"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
"image": {
"url": "https://test.com/image.png",
"caption": "Check out this new promotion"
}
},
"webhook_version": "v1",
"webhook_url": "https://example.com/status"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
"url": "https://example.com/page1.html",
"text": "Find out more"
}
}
},
"webhook_version": "v1",
"webhook_url": "https://example.com/status"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
"url": "https://example.com/image.jpg",
"caption": "Check out this new video",
"thumb_url": "https://example.com/file1.jpg"
}
},
"webhook_version": "v1",
"webhook_url": "https://example.com/status"
}
Loading

0 comments on commit feb5153

Please sign in to comment.