From 26065969c162541af545fdfca5d05491e58fa1a2 Mon Sep 17 00:00:00 2001
From: Panuchi <41389318+Panuchi@users.noreply.github.com>
Date: Fri, 7 Feb 2020 16:51:18 +0300
Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?=
=?UTF-8?q?=D1=8C=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B=20appWidgets=20(#?=
=?UTF-8?q?929)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* Добавить методы appWidgets
* Добавить тесты appWidgets
---
.../AppWidgets/GetAppImageUploadServerTest.cs | 26 ++++
.../Categories/AppWidgets/GetAppImagesTest.cs | 27 +++++
.../GetGroupImageUploadServerTest.cs | 26 ++++
.../AppWidgets/GetGroupImagesTest.cs | 27 +++++
.../AppWidgets/GetImagesByIdTest.cs | 27 +++++
.../Categories/AppWidgets/SaveAppImageTest.cs | 28 +++++
.../AppWidgets/SaveGroupImageTest.cs | 28 +++++
VkNet.Tests/Categories/AppWidgets/Update.cs | 26 ++++
.../Enum/SafetyEnums/SafetyEnumTests.cs | 25 ++++
.../AppWidgets/GetAppImageUploadServer.json | 5 +
.../Categories/AppWidgets/GetAppImages.json | 112 ++++++++++++++++++
.../AppWidgets/GetGroupImageUploadServer.json | 5 +
.../Categories/AppWidgets/GetGroupImages.json | 112 ++++++++++++++++++
.../Categories/AppWidgets/GetImagesById.json | 25 ++++
.../Categories/AppWidgets/SaveAppImage.json | 23 ++++
.../Categories/AppWidgets/SaveGroupImage.json | 23 ++++
.../Async/IAppWidgetsCategoryAsync.cs | 19 +--
.../Category/IAppWidgetsCategory.cs | 20 ++--
VkNet/Categories/AppWidgetsCategory.cs | 37 +++---
.../Async/AppWidgetsCategoryAsync.cs | 21 ++--
VkNet/Enums/SafetyEnums/AppWidgetType.cs | 72 +++++++++++
VkNet/Model/AppImage.cs | 68 +++++++++++
VkNet/Model/AppImageResult.cs | 58 +++++++++
VkNet/Model/Image.cs | 21 +---
VkNet/Model/UploadServerInfo.cs | 4 +
.../Utils/VkResponseToModelCastsGenerator.cs | 24 ++++
.../VkResponseToSafetyEnumCastGenerator.cs | 22 ++++
27 files changed, 851 insertions(+), 60 deletions(-)
create mode 100644 VkNet.Tests/Categories/AppWidgets/GetAppImageUploadServerTest.cs
create mode 100644 VkNet.Tests/Categories/AppWidgets/GetAppImagesTest.cs
create mode 100644 VkNet.Tests/Categories/AppWidgets/GetGroupImageUploadServerTest.cs
create mode 100644 VkNet.Tests/Categories/AppWidgets/GetGroupImagesTest.cs
create mode 100644 VkNet.Tests/Categories/AppWidgets/GetImagesByIdTest.cs
create mode 100644 VkNet.Tests/Categories/AppWidgets/SaveAppImageTest.cs
create mode 100644 VkNet.Tests/Categories/AppWidgets/SaveGroupImageTest.cs
create mode 100644 VkNet.Tests/Categories/AppWidgets/Update.cs
create mode 100644 VkNet.Tests/TestData/Categories/AppWidgets/GetAppImageUploadServer.json
create mode 100644 VkNet.Tests/TestData/Categories/AppWidgets/GetAppImages.json
create mode 100644 VkNet.Tests/TestData/Categories/AppWidgets/GetGroupImageUploadServer.json
create mode 100644 VkNet.Tests/TestData/Categories/AppWidgets/GetGroupImages.json
create mode 100644 VkNet.Tests/TestData/Categories/AppWidgets/GetImagesById.json
create mode 100644 VkNet.Tests/TestData/Categories/AppWidgets/SaveAppImage.json
create mode 100644 VkNet.Tests/TestData/Categories/AppWidgets/SaveGroupImage.json
create mode 100644 VkNet/Enums/SafetyEnums/AppWidgetType.cs
create mode 100644 VkNet/Model/AppImage.cs
create mode 100644 VkNet/Model/AppImageResult.cs
diff --git a/VkNet.Tests/Categories/AppWidgets/GetAppImageUploadServerTest.cs b/VkNet.Tests/Categories/AppWidgets/GetAppImageUploadServerTest.cs
new file mode 100644
index 000000000..647b70b25
--- /dev/null
+++ b/VkNet.Tests/Categories/AppWidgets/GetAppImageUploadServerTest.cs
@@ -0,0 +1,26 @@
+using System.Diagnostics.CodeAnalysis;
+using NUnit.Framework;
+using VkNet.Enums.SafetyEnums;
+using VkNet.Tests.Infrastructure;
+
+namespace VkNet.Tests.Categories
+{
+ [TestFixture]
+ [ExcludeFromCodeCoverage]
+ public class GetAppImageUploadServerTest : CategoryBaseTest
+ {
+ protected override string Folder => "AppWidgets";
+
+ [Test]
+ public void GetAppImageUploadServer()
+ {
+ Url = "https://api.vk.com/method/appWidgets.getAppImageUploadServer";
+
+ ReadCategoryJsonPath(nameof(GetAppImageUploadServer));
+
+ var result = Api.AppWidgets.GetAppImageUploadServer(AppWidgetImageType.FiftyOnFifty);
+
+ Assert.IsNotNull(result.UploadUrl);
+ }
+ }
+}
\ No newline at end of file
diff --git a/VkNet.Tests/Categories/AppWidgets/GetAppImagesTest.cs b/VkNet.Tests/Categories/AppWidgets/GetAppImagesTest.cs
new file mode 100644
index 000000000..bb55d19cb
--- /dev/null
+++ b/VkNet.Tests/Categories/AppWidgets/GetAppImagesTest.cs
@@ -0,0 +1,27 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using NUnit.Framework;
+using VkNet.Enums.SafetyEnums;
+using VkNet.Tests.Infrastructure;
+
+namespace VkNet.Tests.Categories
+{
+ [TestFixture]
+ [ExcludeFromCodeCoverage]
+ public class GetAppImagesTest : CategoryBaseTest
+ {
+ protected override string Folder => "AppWidgets";
+
+ [Test]
+ public void GetAppImages()
+ {
+ Url = "https://api.vk.com/method/appWidgets.getAppImages";
+
+ ReadCategoryJsonPath(nameof(GetAppImages));
+
+ var result = Api.AppWidgets.GetAppImages(0, 10, AppWidgetImageType.FiftyOnFifty);
+
+ Assert.IsNotNull(result.Items.First().Images.First().Url);
+ }
+ }
+}
\ No newline at end of file
diff --git a/VkNet.Tests/Categories/AppWidgets/GetGroupImageUploadServerTest.cs b/VkNet.Tests/Categories/AppWidgets/GetGroupImageUploadServerTest.cs
new file mode 100644
index 000000000..fec560702
--- /dev/null
+++ b/VkNet.Tests/Categories/AppWidgets/GetGroupImageUploadServerTest.cs
@@ -0,0 +1,26 @@
+using System.Diagnostics.CodeAnalysis;
+using NUnit.Framework;
+using VkNet.Enums.SafetyEnums;
+using VkNet.Tests.Infrastructure;
+
+namespace VkNet.Tests.Categories
+{
+ [TestFixture]
+ [ExcludeFromCodeCoverage]
+ public class GetGroupImageUploadServerTest : CategoryBaseTest
+ {
+ protected override string Folder => "AppWidgets";
+
+ [Test]
+ public void GetGroupImageUploadServer()
+ {
+ Url = "https://api.vk.com/method/appWidgets.getGroupImageUploadServer";
+
+ ReadCategoryJsonPath(nameof(GetGroupImageUploadServer));
+
+ var result = Api.AppWidgets.GetGroupImageUploadServer(AppWidgetImageType.FiftyOnFifty);
+
+ Assert.IsNotNull(result.UploadUrl);
+ }
+ }
+}
\ No newline at end of file
diff --git a/VkNet.Tests/Categories/AppWidgets/GetGroupImagesTest.cs b/VkNet.Tests/Categories/AppWidgets/GetGroupImagesTest.cs
new file mode 100644
index 000000000..79b80dce5
--- /dev/null
+++ b/VkNet.Tests/Categories/AppWidgets/GetGroupImagesTest.cs
@@ -0,0 +1,27 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using NUnit.Framework;
+using VkNet.Enums.SafetyEnums;
+using VkNet.Tests.Infrastructure;
+
+namespace VkNet.Tests.Categories
+{
+ [TestFixture]
+ [ExcludeFromCodeCoverage]
+ public class GetGroupImagesTest : CategoryBaseTest
+ {
+ protected override string Folder => "AppWidgets";
+
+ [Test]
+ public void GetGroupImages()
+ {
+ Url = "https://api.vk.com/method/appWidgets.getGroupImages";
+
+ ReadCategoryJsonPath(nameof(GetGroupImages));
+
+ var result = Api.AppWidgets.GetGroupImages(0, 10, AppWidgetImageType.FiftyOnFifty);
+
+ Assert.IsNotNull(result.Items.First().Images.First().Url);
+ }
+ }
+}
\ No newline at end of file
diff --git a/VkNet.Tests/Categories/AppWidgets/GetImagesByIdTest.cs b/VkNet.Tests/Categories/AppWidgets/GetImagesByIdTest.cs
new file mode 100644
index 000000000..3316ea988
--- /dev/null
+++ b/VkNet.Tests/Categories/AppWidgets/GetImagesByIdTest.cs
@@ -0,0 +1,27 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using NUnit.Framework;
+using VkNet.Tests.Infrastructure;
+
+namespace VkNet.Tests.Categories
+{
+ [TestFixture]
+ [ExcludeFromCodeCoverage]
+ public class GetImagesByIdTest : CategoryBaseTest
+ {
+ protected override string Folder => "AppWidgets";
+
+ [Test]
+ public void GetAppImages()
+ {
+ Url = "https://api.vk.com/method/appWidgets.getImagesById";
+
+ ReadCategoryJsonPath(nameof(GetAppImages));
+
+ var result = Api.AppWidgets.GetImagesById("7309583_1192027");
+
+ Assert.IsNotNull(result);
+ Assert.AreEqual("7309583_1192027", result.First().Id);
+ }
+ }
+}
\ No newline at end of file
diff --git a/VkNet.Tests/Categories/AppWidgets/SaveAppImageTest.cs b/VkNet.Tests/Categories/AppWidgets/SaveAppImageTest.cs
new file mode 100644
index 000000000..7bb6a2af8
--- /dev/null
+++ b/VkNet.Tests/Categories/AppWidgets/SaveAppImageTest.cs
@@ -0,0 +1,28 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using NUnit.Framework;
+using VkNet.Tests.Infrastructure;
+
+namespace VkNet.Tests.Categories
+{
+ [TestFixture]
+ [ExcludeFromCodeCoverage]
+ public class SaveAppImageTest : CategoryBaseTest
+ {
+ protected override string Folder => "AppWidgets";
+
+ [Test]
+ public void SaveAppImage()
+ {
+ Url = "https://api.vk.com/method/appWidgets.saveAppImage";
+
+ ReadCategoryJsonPath(nameof(SaveAppImage));
+
+ var result = Api.AppWidgets.SaveAppImage(
+ "0f009dbdd6154c88b8",
+ "eyJvaWQiOjczMDk1ODMsInR5cGUiOjUsInBob3RvIjp7InBob3RvIjoiMjRkNmQwOWU1ZXgiLCJzaXplcyI6W1siYSIsMjA2NzIwNTg5LCI1YmYxOCIsInJ2a3JxRWRsR0tVIiw1MCw1MF0sWyJiIiwyMDY3MjA1ODksIjViZjE5IiwiYnE2VXhhakJaUFEiLDEwMCwxMDBdLFsiYyIsMjA2NzIwNTg5LCI1YmYxYSIsImI5eTlEalUtTVR3IiwxNTAsMTUwXV0sImtpZCI6IjhlMDkzZjYxOGQyY2M5MzJiMDU5YmRlYTViNjVhYmNhIiwiZGVidWciOiJ4Y2MiLCJ1cmxzIjpbInYyMDY3MjA1ODlcLzViZjE4XC9ydmtycUVkbEdLVS5qcGciLCJ2MjA2NzIwNTg5XC81YmYxOVwvYnE2VXhhakJaUFEuanBnIiwidjIwNjcyMDU4OVwvNWJmMWFcL2I5eTlEalUtTVR3LmpwZyJdfSwiYndhY3QiOiJhcHBfd2lkZ2V0X2ltYWdlIiwic2VydmVyIjoyMDY3MjAsIm1pZCI6MCwiX3NpZyI6ImNhMjI3ZWZlY2MxMjhjMzgxNTYzZjBjOGQ4YTM4ZTJlIn0");
+
+ Assert.IsNotNull(result.Images.First().Url);
+ }
+ }
+}
\ No newline at end of file
diff --git a/VkNet.Tests/Categories/AppWidgets/SaveGroupImageTest.cs b/VkNet.Tests/Categories/AppWidgets/SaveGroupImageTest.cs
new file mode 100644
index 000000000..fea344175
--- /dev/null
+++ b/VkNet.Tests/Categories/AppWidgets/SaveGroupImageTest.cs
@@ -0,0 +1,28 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using NUnit.Framework;
+using VkNet.Tests.Infrastructure;
+
+namespace VkNet.Tests.Categories
+{
+ [TestFixture]
+ [ExcludeFromCodeCoverage]
+ public class SaveGroupImageTest : CategoryBaseTest
+ {
+ protected override string Folder => "AppWidgets";
+
+ [Test]
+ public void SaveGroupImage()
+ {
+ Url = "https://api.vk.com/method/appWidgets.saveGroupImage";
+
+ ReadCategoryJsonPath(nameof(SaveGroupImage));
+
+ var result = Api.AppWidgets.SaveGroupImage(
+ "0f009dbdd6154c88b8",
+ "eyJvaWQiOjczMDk1ODMsInR5cGUiOjUsInBob3RvIjp7InBob3RvIjoiMjRkNmQwOWU1ZXgiLCJzaXplcyI6W1siYSIsMjA2NzIwNTg5LCI1YmYxOCIsInJ2a3JxRWRsR0tVIiw1MCw1MF0sWyJiIiwyMDY3MjA1ODksIjViZjE5IiwiYnE2VXhhakJaUFEiLDEwMCwxMDBdLFsiYyIsMjA2NzIwNTg5LCI1YmYxYSIsImI5eTlEalUtTVR3IiwxNTAsMTUwXV0sImtpZCI6IjhlMDkzZjYxOGQyY2M5MzJiMDU5YmRlYTViNjVhYmNhIiwiZGVidWciOiJ4Y2MiLCJ1cmxzIjpbInYyMDY3MjA1ODlcLzViZjE4XC9ydmtycUVkbEdLVS5qcGciLCJ2MjA2NzIwNTg5XC81YmYxOVwvYnE2VXhhakJaUFEuanBnIiwidjIwNjcyMDU4OVwvNWJmMWFcL2I5eTlEalUtTVR3LmpwZyJdfSwiYndhY3QiOiJhcHBfd2lkZ2V0X2ltYWdlIiwic2VydmVyIjoyMDY3MjAsIm1pZCI6MCwiX3NpZyI6ImNhMjI3ZWZlY2MxMjhjMzgxNTYzZjBjOGQ4YTM4ZTJlIn0");
+
+ Assert.IsNotNull(result.Images.First().Url);
+ }
+ }
+}
\ No newline at end of file
diff --git a/VkNet.Tests/Categories/AppWidgets/Update.cs b/VkNet.Tests/Categories/AppWidgets/Update.cs
new file mode 100644
index 000000000..9917b053b
--- /dev/null
+++ b/VkNet.Tests/Categories/AppWidgets/Update.cs
@@ -0,0 +1,26 @@
+using System.Diagnostics.CodeAnalysis;
+using NUnit.Framework;
+using VkNet.Enums.SafetyEnums;
+using VkNet.Tests.Infrastructure;
+
+namespace VkNet.Tests.Categories
+{
+ [TestFixture]
+ [ExcludeFromCodeCoverage]
+ public class Update : CategoryBaseTest
+ {
+ protected override string Folder => "AppWidgets";
+
+ [Test]
+ public void EnableOnline()
+ {
+ Url = "https://api.vk.com/method/appWidgets.update";
+
+ ReadJsonFile(JsonPaths.True);
+
+ var result = Api.AppWidgets.Update("string", AppWidgetType.Donation);
+
+ Assert.IsTrue(result);
+ }
+ }
+}
\ No newline at end of file
diff --git a/VkNet.Tests/Enum/SafetyEnums/SafetyEnumTests.cs b/VkNet.Tests/Enum/SafetyEnums/SafetyEnumTests.cs
index 0947091c3..992d7b3cd 100644
--- a/VkNet.Tests/Enum/SafetyEnums/SafetyEnumTests.cs
+++ b/VkNet.Tests/Enum/SafetyEnums/SafetyEnumTests.cs
@@ -836,5 +836,30 @@ public void MarketItemButtonTitleTest()
Assert.That(MarketItemButtonTitle.FromJsonString("Купить билет"), Is.EqualTo(MarketItemButtonTitle.BuyATicket));
Assert.That(MarketItemButtonTitle.FromJsonString("Перейти в магазин"), Is.EqualTo(MarketItemButtonTitle.GoToTheStore));
}
+
+ [Test]
+ public void AppWidgetTypeTest()
+ {
+ // get test
+ Assert.That(AppWidgetType.Donation.ToString(), Is.EqualTo("donation"));
+ Assert.That(AppWidgetType.List.ToString(), Is.EqualTo("list"));
+ Assert.That(AppWidgetType.Match.ToString(), Is.EqualTo("match"));
+ Assert.That(AppWidgetType.Matches.ToString(), Is.EqualTo("matches"));
+ Assert.That(AppWidgetType.Table.ToString(), Is.EqualTo("table"));
+ Assert.That(AppWidgetType.Text.ToString(), Is.EqualTo("text"));
+ Assert.That(AppWidgetType.Tiles.ToString(), Is.EqualTo("tiles"));
+ Assert.That(AppWidgetType.CompactList.ToString(), Is.EqualTo("compact_list"));
+ Assert.That(AppWidgetType.CoverList.ToString(), Is.EqualTo("cover_list"));
+ // parse test
+ Assert.That(AppWidgetType.FromJsonString("donation"), Is.EqualTo(AppWidgetType.Donation));
+ Assert.That(AppWidgetType.FromJsonString("list"), Is.EqualTo(AppWidgetType.List));
+ Assert.That(AppWidgetType.FromJsonString("match"), Is.EqualTo(AppWidgetType.Match));
+ Assert.That(AppWidgetType.FromJsonString("matches"), Is.EqualTo(AppWidgetType.Matches));
+ Assert.That(AppWidgetType.FromJsonString("table"), Is.EqualTo(AppWidgetType.Table));
+ Assert.That(AppWidgetType.FromJsonString("text"), Is.EqualTo(AppWidgetType.Text));
+ Assert.That(AppWidgetType.FromJsonString("tiles"), Is.EqualTo(AppWidgetType.Tiles));
+ Assert.That(AppWidgetType.FromJsonString("compact_list"), Is.EqualTo(AppWidgetType.CompactList));
+ Assert.That(AppWidgetType.FromJsonString("cover_list"), Is.EqualTo(AppWidgetType.CoverList));
+ }
}
}
\ No newline at end of file
diff --git a/VkNet.Tests/TestData/Categories/AppWidgets/GetAppImageUploadServer.json b/VkNet.Tests/TestData/Categories/AppWidgets/GetAppImageUploadServer.json
new file mode 100644
index 000000000..025be796a
--- /dev/null
+++ b/VkNet.Tests/TestData/Categories/AppWidgets/GetAppImageUploadServer.json
@@ -0,0 +1,5 @@
+{
+ "response": {
+ "upload_url": "some_url"
+ }
+}
\ No newline at end of file
diff --git a/VkNet.Tests/TestData/Categories/AppWidgets/GetAppImages.json b/VkNet.Tests/TestData/Categories/AppWidgets/GetAppImages.json
new file mode 100644
index 000000000..34074c581
--- /dev/null
+++ b/VkNet.Tests/TestData/Categories/AppWidgets/GetAppImages.json
@@ -0,0 +1,112 @@
+{
+ "response": {
+ "count": 5,
+ "items": [
+ {
+ "id": "7309583_1192027",
+ "type": "50x50",
+ "images": [
+ {
+ "url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
+ "width": 50,
+ "height": 50
+ },
+ {
+ "url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
+ "width": 100,
+ "height": 100
+ },
+ {
+ "url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
+ "width": 150,
+ "height": 150
+ }
+ ]
+ },
+ {
+ "id": "7309583_1192042",
+ "type": "50x50",
+ "images": [
+ {
+ "url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
+ "width": 50,
+ "height": 50
+ },
+ {
+ "url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
+ "width": 100,
+ "height": 100
+ },
+ {
+ "url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
+ "width": 150,
+ "height": 150
+ }
+ ]
+ },
+ {
+ "id": "7309583_1192047",
+ "type": "50x50",
+ "images": [
+ {
+ "url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
+ "width": 50,
+ "height": 50
+ },
+ {
+ "url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
+ "width": 100,
+ "height": 100
+ },
+ {
+ "url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
+ "width": 150,
+ "height": 150
+ }
+ ]
+ },
+ {
+ "id": "7309583_1192053",
+ "type": "50x50",
+ "images": [
+ {
+ "url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
+ "width": 50,
+ "height": 50
+ },
+ {
+ "url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
+ "width": 100,
+ "height": 100
+ },
+ {
+ "url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
+ "width": 150,
+ "height": 150
+ }
+ ]
+ },
+ {
+ "id": "7309583_1192090",
+ "type": "50x50",
+ "images": [
+ {
+ "url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
+ "width": 50,
+ "height": 50
+ },
+ {
+ "url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
+ "width": 100,
+ "height": 100
+ },
+ {
+ "url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
+ "width": 150,
+ "height": 150
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/VkNet.Tests/TestData/Categories/AppWidgets/GetGroupImageUploadServer.json b/VkNet.Tests/TestData/Categories/AppWidgets/GetGroupImageUploadServer.json
new file mode 100644
index 000000000..025be796a
--- /dev/null
+++ b/VkNet.Tests/TestData/Categories/AppWidgets/GetGroupImageUploadServer.json
@@ -0,0 +1,5 @@
+{
+ "response": {
+ "upload_url": "some_url"
+ }
+}
\ No newline at end of file
diff --git a/VkNet.Tests/TestData/Categories/AppWidgets/GetGroupImages.json b/VkNet.Tests/TestData/Categories/AppWidgets/GetGroupImages.json
new file mode 100644
index 000000000..34074c581
--- /dev/null
+++ b/VkNet.Tests/TestData/Categories/AppWidgets/GetGroupImages.json
@@ -0,0 +1,112 @@
+{
+ "response": {
+ "count": 5,
+ "items": [
+ {
+ "id": "7309583_1192027",
+ "type": "50x50",
+ "images": [
+ {
+ "url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
+ "width": 50,
+ "height": 50
+ },
+ {
+ "url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
+ "width": 100,
+ "height": 100
+ },
+ {
+ "url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
+ "width": 150,
+ "height": 150
+ }
+ ]
+ },
+ {
+ "id": "7309583_1192042",
+ "type": "50x50",
+ "images": [
+ {
+ "url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
+ "width": 50,
+ "height": 50
+ },
+ {
+ "url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
+ "width": 100,
+ "height": 100
+ },
+ {
+ "url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
+ "width": 150,
+ "height": 150
+ }
+ ]
+ },
+ {
+ "id": "7309583_1192047",
+ "type": "50x50",
+ "images": [
+ {
+ "url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
+ "width": 50,
+ "height": 50
+ },
+ {
+ "url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
+ "width": 100,
+ "height": 100
+ },
+ {
+ "url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
+ "width": 150,
+ "height": 150
+ }
+ ]
+ },
+ {
+ "id": "7309583_1192053",
+ "type": "50x50",
+ "images": [
+ {
+ "url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
+ "width": 50,
+ "height": 50
+ },
+ {
+ "url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
+ "width": 100,
+ "height": 100
+ },
+ {
+ "url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
+ "width": 150,
+ "height": 150
+ }
+ ]
+ },
+ {
+ "id": "7309583_1192090",
+ "type": "50x50",
+ "images": [
+ {
+ "url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
+ "width": 50,
+ "height": 50
+ },
+ {
+ "url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
+ "width": 100,
+ "height": 100
+ },
+ {
+ "url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
+ "width": 150,
+ "height": 150
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/VkNet.Tests/TestData/Categories/AppWidgets/GetImagesById.json b/VkNet.Tests/TestData/Categories/AppWidgets/GetImagesById.json
new file mode 100644
index 000000000..6ccf341dd
--- /dev/null
+++ b/VkNet.Tests/TestData/Categories/AppWidgets/GetImagesById.json
@@ -0,0 +1,25 @@
+{
+ "response": [
+ {
+ "id": "7309583_1192027",
+ "type": "50x50",
+ "images": [
+ {
+ "url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
+ "width": 50,
+ "height": 50
+ },
+ {
+ "url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
+ "width": 100,
+ "height": 100
+ },
+ {
+ "url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
+ "width": 150,
+ "height": 150
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/VkNet.Tests/TestData/Categories/AppWidgets/SaveAppImage.json b/VkNet.Tests/TestData/Categories/AppWidgets/SaveAppImage.json
new file mode 100644
index 000000000..ee76a2c82
--- /dev/null
+++ b/VkNet.Tests/TestData/Categories/AppWidgets/SaveAppImage.json
@@ -0,0 +1,23 @@
+{
+ "response": {
+ "id": "7309583_1192168",
+ "type": "50x50",
+ "images": [
+ {
+ "url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
+ "width": 50,
+ "height": 50
+ },
+ {
+ "url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
+ "width": 100,
+ "height": 100
+ },
+ {
+ "url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
+ "width": 150,
+ "height": 150
+ }
+ ]
+ }
+}
diff --git a/VkNet.Tests/TestData/Categories/AppWidgets/SaveGroupImage.json b/VkNet.Tests/TestData/Categories/AppWidgets/SaveGroupImage.json
new file mode 100644
index 000000000..cce4ce73f
--- /dev/null
+++ b/VkNet.Tests/TestData/Categories/AppWidgets/SaveGroupImage.json
@@ -0,0 +1,23 @@
+{
+ "response": {
+ "id": "7309583_1192168",
+ "type": "50x50",
+ "images": [
+ {
+ "url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
+ "width": 50,
+ "height": 50
+ },
+ {
+ "url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
+ "width": 100,
+ "height": 100
+ },
+ {
+ "url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
+ "width": 150,
+ "height": 150
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/VkNet/Abstractions/Category/Async/IAppWidgetsCategoryAsync.cs b/VkNet/Abstractions/Category/Async/IAppWidgetsCategoryAsync.cs
index 2430834f4..beccddcc9 100644
--- a/VkNet/Abstractions/Category/Async/IAppWidgetsCategoryAsync.cs
+++ b/VkNet/Abstractions/Category/Async/IAppWidgetsCategoryAsync.cs
@@ -1,6 +1,7 @@
-using System;
+using System.Collections.ObjectModel;
using System.Threading.Tasks;
using VkNet.Enums.SafetyEnums;
+using VkNet.Model;
namespace VkNet.Abstractions.Category
{
@@ -28,7 +29,7 @@ public interface IAppWidgetsCategoryAsync
///
/// Страница документации ВКонтакте http://vk.com/dev/appWidgets.getAppImageUploadServer
///
- Task GetAppImageUploadServerAsync(AppWidgetImageType imageType);
+ Task GetAppImageUploadServerAsync(AppWidgetImageType imageType);
///
/// Позволяет получить коллекцию изображений, загруженных для приложения, в виджетах приложений сообществ.
@@ -54,7 +55,7 @@ public interface IAppWidgetsCategoryAsync
///
/// Страница документации ВКонтакте http://vk.com/dev/appWidgets.getAppImages
///
- Task GetAppImagesAsync(int offset, int count, AppWidgetImageType imageType);
+ Task GetAppImagesAsync(int offset, int count, AppWidgetImageType imageType);
///
/// Позволяет получить адрес для загрузки фотографии в коллекцию сообщества для виджетов приложений сообществ.
@@ -67,7 +68,7 @@ public interface IAppWidgetsCategoryAsync
///
/// Страница документации ВКонтакте http://vk.com/dev/appWidgets.getGroupImageUploadServer
///
- Task GetGroupImageUploadServerAsync(AppWidgetImageType imageType);
+ Task GetGroupImageUploadServerAsync(AppWidgetImageType imageType);
///
/// Позволяет получить коллекцию изображений, загруженных для приложения, в виджетах приложений сообществ.
@@ -93,7 +94,7 @@ public interface IAppWidgetsCategoryAsync
///
/// Страница документации ВКонтакте http://vk.com/dev/appWidgets.getGroupImages
///
- Task GetGroupImagesAsync(int offset, int count, AppWidgetImageType imageType);
+ Task GetGroupImagesAsync(int offset, int count, AppWidgetImageType imageType);
///
/// Позволяет получить изображение для виджетов приложений сообществ по его идентификатору.
@@ -116,7 +117,7 @@ public interface IAppWidgetsCategoryAsync
///
/// Страница документации ВКонтакте http://vk.com/dev/appWidgets.getImagesById
///
- Task GetImagesByIdAsync(string images);
+ Task> GetImagesByIdAsync(string images);
///
/// Позволяет сохранить изображение в коллекцию приложения для виджетов приложений сообществ после загрузки на сервер.
@@ -144,7 +145,7 @@ public interface IAppWidgetsCategoryAsync
///
/// Страница документации ВКонтакте http://vk.com/dev/appWidgets.saveAppImage
///
- Task SaveAppImageAsync(string hash, string image);
+ Task SaveAppImageAsync(string hash, string image);
///
/// Позволяет сохранить изображение в коллекцию сообщества для виджетов приложений сообществ. после загрузки на сервер.
@@ -166,7 +167,7 @@ public interface IAppWidgetsCategoryAsync
///
/// Страница документации ВКонтакте http://vk.com/dev/appWidgets.saveGroupImage
///
- Task SaveGroupImageAsync();
+ Task SaveGroupImageAsync(string hash, string image);
///
/// Позволяет обновить виджет приложения сообщества.
@@ -183,6 +184,6 @@ public interface IAppWidgetsCategoryAsync
///
/// Страница документации ВКонтакте http://vk.com/dev/appWidgets.update
///
- Task UpdateAsync(string code, string type);
+ Task UpdateAsync(string code, AppWidgetType type);
}
}
\ No newline at end of file
diff --git a/VkNet/Abstractions/Category/IAppWidgetsCategory.cs b/VkNet/Abstractions/Category/IAppWidgetsCategory.cs
index 4e550e7bb..3b024d67c 100644
--- a/VkNet/Abstractions/Category/IAppWidgetsCategory.cs
+++ b/VkNet/Abstractions/Category/IAppWidgetsCategory.cs
@@ -1,6 +1,9 @@
using System;
+using System.Collections.ObjectModel;
using VkNet.Abstractions.Category;
using VkNet.Enums.SafetyEnums;
+using VkNet.Model;
+using VkNet.Model.Attachments;
namespace VkNet.Abstractions
{
@@ -8,27 +11,28 @@ namespace VkNet.Abstractions
public interface IAppWidgetsCategory : IAppWidgetsCategoryAsync
{
///
- Uri GetAppImageUploadServer(AppWidgetImageType imageType);
+ UploadServerInfo GetAppImageUploadServer(AppWidgetImageType imageType);
///
- Uri GetAppImages(int offset, int count, AppWidgetImageType imageType);
+ AppImageResult GetAppImages(int offset, int count, AppWidgetImageType imageType);
///
- Uri GetGroupImageUploadServer(AppWidgetImageType imageType);
+ UploadServerInfo GetGroupImageUploadServer(AppWidgetImageType imageType);
///
- Uri GetGroupImages(int offset, int count, AppWidgetImageType imageType);
+ AppImageResult GetGroupImages(int offset, int count, AppWidgetImageType imageType);
///
- Uri GetImagesById(string images);
+ ReadOnlyCollection GetImagesById(string images);
///
- Uri SaveAppImage(string hash, string image);
+ AppImage SaveAppImage(string hash, string image);
///
- Uri SaveGroupImage();
+ AppImage SaveGroupImage(string hash, string image);
+ //TODO: TEST IT!!
///
- bool Update(string code, string type);
+ bool Update(string code, AppWidgetType type);
}
}
\ No newline at end of file
diff --git a/VkNet/Categories/AppWidgetsCategory.cs b/VkNet/Categories/AppWidgetsCategory.cs
index e8d863b91..916605490 100644
--- a/VkNet/Categories/AppWidgetsCategory.cs
+++ b/VkNet/Categories/AppWidgetsCategory.cs
@@ -1,6 +1,7 @@
-using System;
+using System.Collections.ObjectModel;
using VkNet.Abstractions;
using VkNet.Enums.SafetyEnums;
+using VkNet.Model;
using VkNet.Utils;
namespace VkNet.Categories
@@ -23,15 +24,15 @@ public AppWidgetsCategory(IVkApiInvoke api)
}
///
- public Uri GetAppImageUploadServer(AppWidgetImageType imageType)
+ public UploadServerInfo GetAppImageUploadServer(AppWidgetImageType imageType)
{
- return _vk.Call("appWidgets.getAppImageUploadServer", new VkParameters { { "image_type", imageType } })["upload_url"];
+ return _vk.Call("appWidgets.getAppImageUploadServer", new VkParameters { { "image_type", imageType } });
}
///
- public Uri GetAppImages(int offset, int count, AppWidgetImageType imageType)
+ public AppImageResult GetAppImages(int offset, int count, AppWidgetImageType imageType)
{
- return _vk.Call("appWidgets.getAppImages",
+ return _vk.Call("appWidgets.getAppImages",
new VkParameters
{
{ "offset", offset },
@@ -41,15 +42,15 @@ public Uri GetAppImages(int offset, int count, AppWidgetImageType imageType)
}
///
- public Uri GetGroupImageUploadServer(AppWidgetImageType imageType)
+ public UploadServerInfo GetGroupImageUploadServer(AppWidgetImageType imageType)
{
- return _vk.Call("appWidgets.getGroupImageUploadServer", new VkParameters { { "image_type", imageType } });
+ return _vk.Call("appWidgets.getGroupImageUploadServer", new VkParameters { { "image_type", imageType } });
}
///
- public Uri GetGroupImages(int offset, int count, AppWidgetImageType imageType)
+ public AppImageResult GetGroupImages(int offset, int count, AppWidgetImageType imageType)
{
- return _vk.Call("appWidgets.getGroupImages",
+ return _vk.Call("appWidgets.getGroupImages",
new VkParameters
{
{ "offset", offset },
@@ -60,25 +61,29 @@ public Uri GetGroupImages(int offset, int count, AppWidgetImageType imageType)
///
///
- public Uri GetImagesById(string images)
+ public ReadOnlyCollection GetImagesById(string images)
{
- return _vk.Call("appWidgets.getImagesById", VkParameters.Empty);
+ var parameters = new VkParameters
+ {
+ { "images", images }
+ };
+ return _vk.Call("appWidgets.getImagesById", parameters).ToReadOnlyCollectionOf(x => x);
}
///
- public Uri SaveAppImage(string hash, string image)
+ public AppImage SaveAppImage(string hash, string image)
{
- return _vk.Call("appWidgets.saveAppImage", new VkParameters { { "hash", hash }, { "image", image } });
+ return _vk.Call("appWidgets.saveAppImage", new VkParameters { { "hash", hash }, { "image", image } });
}
///
- public Uri SaveGroupImage()
+ public AppImage SaveGroupImage(string hash, string image)
{
- return _vk.Call("appWidgets.saveGroupImage", VkParameters.Empty);
+ return _vk.Call("appWidgets.saveGroupImage", new VkParameters { { "hash", hash }, { "image", image } });
}
///
- public bool Update(string code, string type)
+ public bool Update(string code, AppWidgetType type)
{
return _vk.Call("appWidgets.update", new VkParameters
{
diff --git a/VkNet/Categories/Async/AppWidgetsCategoryAsync.cs b/VkNet/Categories/Async/AppWidgetsCategoryAsync.cs
index 0688d11e3..48dd10477 100644
--- a/VkNet/Categories/Async/AppWidgetsCategoryAsync.cs
+++ b/VkNet/Categories/Async/AppWidgetsCategoryAsync.cs
@@ -1,6 +1,7 @@
-using System;
+using System.Collections.ObjectModel;
using System.Threading.Tasks;
using VkNet.Enums.SafetyEnums;
+using VkNet.Model;
using VkNet.Utils;
namespace VkNet.Categories
@@ -9,49 +10,49 @@ namespace VkNet.Categories
public partial class AppWidgetsCategory
{
///
- public Task GetAppImageUploadServerAsync(AppWidgetImageType imageType)
+ public Task GetAppImageUploadServerAsync(AppWidgetImageType imageType)
{
return TypeHelper.TryInvokeMethodAsync(() => GetAppImageUploadServer(imageType));
}
///
- public Task GetAppImagesAsync(int offset, int count, AppWidgetImageType imageType)
+ public Task GetAppImagesAsync(int offset, int count, AppWidgetImageType imageType)
{
return TypeHelper.TryInvokeMethodAsync(() => GetAppImages(offset, count, imageType));
}
///
- public Task GetGroupImageUploadServerAsync(AppWidgetImageType imageType)
+ public Task GetGroupImageUploadServerAsync(AppWidgetImageType imageType)
{
return TypeHelper.TryInvokeMethodAsync(() => GetGroupImageUploadServer(imageType));
}
///
- public Task GetGroupImagesAsync(int offset, int count, AppWidgetImageType imageType)
+ public Task GetGroupImagesAsync(int offset, int count, AppWidgetImageType imageType)
{
return TypeHelper.TryInvokeMethodAsync(() => GetGroupImages(offset, count, imageType));
}
///
- public Task GetImagesByIdAsync(string images)
+ public Task> GetImagesByIdAsync(string images)
{
return TypeHelper.TryInvokeMethodAsync(() => GetImagesById(images));
}
///
- public Task SaveAppImageAsync(string hash, string image)
+ public Task SaveAppImageAsync(string hash, string image)
{
return TypeHelper.TryInvokeMethodAsync(() => SaveAppImage(hash, image));
}
///
- public Task SaveGroupImageAsync()
+ public Task SaveGroupImageAsync(string hash, string image)
{
- return TypeHelper.TryInvokeMethodAsync(SaveGroupImage);
+ return TypeHelper.TryInvokeMethodAsync(() => SaveGroupImage(hash, image));
}
///
- public Task UpdateAsync(string code, string type)
+ public Task UpdateAsync(string code, AppWidgetType type)
{
return TypeHelper.TryInvokeMethodAsync((() => Update(code, type)));
}
diff --git a/VkNet/Enums/SafetyEnums/AppWidgetType.cs b/VkNet/Enums/SafetyEnums/AppWidgetType.cs
new file mode 100644
index 000000000..315f12e2c
--- /dev/null
+++ b/VkNet/Enums/SafetyEnums/AppWidgetType.cs
@@ -0,0 +1,72 @@
+using System;
+using Newtonsoft.Json;
+using VkNet.Utils.JsonConverter;
+
+namespace VkNet.Enums.SafetyEnums
+{
+ ///
+ /// Тип виджета приложения
+ ///
+ [Serializable]
+ [JsonConverter(typeof(SafetyEnumJsonConverter))]
+ public class AppWidgetType : SafetyEnum
+ {
+ ///
+ /// Text - Выводит текст.
+ ///
+ public static readonly AppWidgetType Text = RegisterPossibleValue("text");
+
+ ///
+ /// List - Выводит список объектов с описанием и
+ /// кнопками для действий. Список может содержать
+ /// до 6 объектов,
+ /// если не указан сопроводительный текст (поле text),
+ /// и до 3 объектов, если текст указан.
+ ///
+ public static readonly AppWidgetType List = RegisterPossibleValue("list");
+
+ ///
+ /// Table - Выводит таблицу с данными.
+ /// В первом столбце текст и ссылки могут
+ /// сопровождаться иконками.
+ /// Таблица может содержать от 1 до 6 столбцов
+ /// и от 1 до 11 строк (включая строку с названиями колонок).
+ ///
+ public static readonly AppWidgetType Table = RegisterPossibleValue("table");
+
+ ///
+ /// Tiles - Выводит плитки с изображением и кратким описанием.
+ /// Количество плиток — от 3 до 10 для мобильных приложений,
+ /// 3 для десктопной версии.
+ ///
+ public static readonly AppWidgetType Tiles = RegisterPossibleValue("tiles");
+
+ ///
+ /// Compact List - Выводит список элементов в компактном виде.
+ /// Аналогичен виджету List, за исключением того,
+ /// что кнопка располагается справа.
+ ///
+ public static readonly AppWidgetType CompactList = RegisterPossibleValue("compact_list");
+
+ ///
+ /// Cover List - Выводит список изображений (от 1 до 3)
+ /// с кнопкой для действия, заголовком и описанием.
+ ///
+ public static readonly AppWidgetType CoverList = RegisterPossibleValue("cover_list");
+
+ ///
+ /// Match - Выводит текущий результат спортивного матча.
+ ///
+ public static readonly AppWidgetType Match = RegisterPossibleValue("match");
+
+ ///
+ /// Matches - Выводит список спортивных матчей.
+ ///
+ public static readonly AppWidgetType Matches = RegisterPossibleValue("matches");
+
+ ///
+ /// Donation - Выводит прогресс пожертвований.
+ ///
+ public static readonly AppWidgetType Donation = RegisterPossibleValue("donation");
+ }
+}
\ No newline at end of file
diff --git a/VkNet/Model/AppImage.cs b/VkNet/Model/AppImage.cs
new file mode 100644
index 000000000..637a1222b
--- /dev/null
+++ b/VkNet/Model/AppImage.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using VkNet.Enums.SafetyEnums;
+using VkNet.Utils;
+using VkNet.Utils.JsonConverter;
+
+namespace VkNet.Model
+{
+ ///
+ /// Массив объектов, описывающих изображения
+ ///
+ [Serializable]
+ public class AppImage
+ {
+ ///
+ /// Идентификатор изображения
+ ///
+ [JsonProperty("id")]
+ public string Id { get; set; }
+
+ ///
+ /// Тип изображения.
+ ///
+ [JsonConverter(typeof(SafetyEnumJsonConverter))]
+ [JsonProperty("type")]
+ public AppWidgetImageType Type { get; set; }
+
+ ///
+ /// Массив копий изображения
+ ///
+ [JsonProperty("images")]
+ public IEnumerable Images { get; set; }
+
+ ///
+ /// Разобрать из json.
+ ///
+ /// Ответ сервера.
+ ///
+ public static AppImage FromJson(VkResponse response)
+ {
+ return new AppImage
+ {
+ Id = response[key: "id"],
+ Type = response[key: "type"],
+ Images = response[key: "images"].ToReadOnlyCollectionOf(x => x)
+ };
+ }
+
+ ///
+ /// Разобрать из json.
+ ///
+ /// Ответ сервера.
+ ///
+ public static implicit operator AppImage(VkResponse response)
+ {
+ if (response == null)
+ {
+ return null;
+ }
+
+ return response.HasToken()
+ ? FromJson(response: response)
+ : null;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/VkNet/Model/AppImageResult.cs b/VkNet/Model/AppImageResult.cs
new file mode 100644
index 000000000..1b8a3ec20
--- /dev/null
+++ b/VkNet/Model/AppImageResult.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using VkNet.Utils;
+
+namespace VkNet.Model
+{
+ ///
+ /// Копия изображения обложки.
+ ///
+ [Serializable]
+ public class AppImageResult
+ {
+ ///
+ /// Общее число результатов
+ ///
+ [JsonProperty("count")]
+ public int Count { get; set; }
+
+ ///
+ /// Массив объектов, описывающих изображения
+ ///
+ [JsonProperty("items")]
+ public IEnumerable Items { get; set; }
+
+ ///
+ /// Разобрать из json.
+ ///
+ /// Ответ сервера.
+ ///
+ public static AppImageResult FromJson(VkResponse response)
+ {
+ return new AppImageResult
+ {
+ Count = response[key: "count"],
+ Items = response[key: "items"].ToReadOnlyCollectionOf(x => x)
+ };
+ }
+
+ ///
+ /// Разобрать из json.
+ ///
+ /// Ответ сервера.
+ ///
+ public static implicit operator AppImageResult(VkResponse response)
+ {
+ if (response == null)
+ {
+ return null;
+ }
+
+ return response.HasToken()
+ ? FromJson(response: response)
+ : null;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/VkNet/Model/Image.cs b/VkNet/Model/Image.cs
index f00cc41a9..b8fe4f505 100644
--- a/VkNet/Model/Image.cs
+++ b/VkNet/Model/Image.cs
@@ -1,4 +1,5 @@
using System;
+using Newtonsoft.Json;
using VkNet.Utils;
namespace VkNet.Model
@@ -12,16 +13,19 @@ public class Image
///
/// URL копии;
///
+ [JsonProperty("url")]
public Uri Url { get; set; }
///
/// Ширина копии;
///
+ [JsonProperty("width")]
public int Width { get; set; }
///
/// Высота копии.
///
+ [JsonProperty("height")]
public int Height { get; set; }
///
@@ -38,22 +42,5 @@ public static Image FromJson(VkResponse response)
Height = response[key: "height"]
};
}
-
- ///
- /// Разобрать из json.
- ///
- /// Ответ сервера.
- ///
- public static implicit operator Image(VkResponse response)
- {
- if (response == null)
- {
- return null;
- }
-
- return response.HasToken()
- ? FromJson(response: response)
- : null;
- }
}
}
\ No newline at end of file
diff --git a/VkNet/Model/UploadServerInfo.cs b/VkNet/Model/UploadServerInfo.cs
index 3ec5b6b74..0f783aadc 100644
--- a/VkNet/Model/UploadServerInfo.cs
+++ b/VkNet/Model/UploadServerInfo.cs
@@ -1,4 +1,5 @@
using System;
+using Newtonsoft.Json;
using VkNet.Utils;
namespace VkNet.Model
@@ -12,16 +13,19 @@ public class UploadServerInfo
///
/// Адрес для загрузки фотографий
///
+ [JsonProperty("upload_url")]
public string UploadUrl { get; set; }
///
/// Идентификатор альбома, в который будет загружена фотография
///
+ [JsonProperty("album_id")]
public long? AlbumId { get; set; }
///
/// Идентификатор пользователя, от чьего имени будет загружено фото
///
+ [JsonProperty("user_id")]
public long? UserId { get; set; }
#region Methods
diff --git a/VkNet/Utils/VkResponseToModelCastsGenerator.cs b/VkNet/Utils/VkResponseToModelCastsGenerator.cs
index 73ee36c08..67117c513 100644
--- a/VkNet/Utils/VkResponseToModelCastsGenerator.cs
+++ b/VkNet/Utils/VkResponseToModelCastsGenerator.cs
@@ -36,6 +36,30 @@ public static implicit operator PageVersion(VkResponse response)
: PageVersion.FromJson(response);
}
+ ///
+ /// Преобразовать из VkResponse
+ ///
+ /// Ответ.
+ ///
+ /// Результат преобразования.
+ ///
+ public static implicit operator AppImageResult(VkResponse response)
+ {
+ return response?._token == null || !response._token.HasValues
+ ? null
+ : AppImageResult.FromJson(response);
+ }
+
+ ///
+ /// Разобрать из json.
+ ///
+ /// Ответ сервера.
+ ///
+ public static implicit operator Image(VkResponse response)
+ {
+ return response?._token == null || !response._token.HasValues ? null : Image.FromJson(response);
+ }
+
///
/// Преобразовать из VkResponse
///
diff --git a/VkNet/Utils/VkResponseToSafetyEnumCastGenerator.cs b/VkNet/Utils/VkResponseToSafetyEnumCastGenerator.cs
index ec38b47ab..c98379087 100644
--- a/VkNet/Utils/VkResponseToSafetyEnumCastGenerator.cs
+++ b/VkNet/Utils/VkResponseToSafetyEnumCastGenerator.cs
@@ -31,6 +31,16 @@ public static implicit operator OnlineStatusType(VkResponse response)
return response == null ? null : OnlineStatusType.FromJson(response: response);
}
+ ///
+ /// Разобрать из json.
+ ///
+ /// Ответ сервера.
+ ///
+ public static implicit operator AppWidgetImageType(VkResponse response)
+ {
+ return response == null ? null : AppWidgetImageType.FromJson(response: response);
+ }
+
///
/// Преобразовать из VkResponse
///
@@ -151,6 +161,18 @@ public static implicit operator AppType(VkResponse response)
return response == null ? null : AppType.FromJson(response: response);
}
+ ///
+ /// Преобразовать из VkResponse
+ ///
+ /// Ответ.
+ ///
+ /// Результат преобразования.
+ ///
+ public static implicit operator AppWidgetType(VkResponse response)
+ {
+ return response == null ? null : AppWidgetType.FromJson(response: response);
+ }
+
///
/// Преобразовать из VkResponse
///