-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Добавлены отсутствующие методы в категорию Ads (#1193)
* Реализовал метод getMusicians * Реализовал метод getMusiciansByIds * Реализовал метод updateOfficeUsers
- Loading branch information
1 parent
e65ab72
commit c04208c
Showing
14 changed files
with
425 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using NUnit.Framework; | ||
using VkNet.Tests.Infrastructure; | ||
|
||
namespace VkNet.Tests.Categories.Ads | ||
{ | ||
[TestFixture] | ||
public class GetMusiciansByIdsTest : CategoryBaseTest | ||
{ | ||
protected override string Folder => "Ads"; | ||
|
||
[Test] | ||
public void GetMusiciansByIds() | ||
{ | ||
Url = "https://api.vk.com/method/ads.getMusiciansByIds"; | ||
|
||
ReadCategoryJsonPath(nameof(Api.Ads.GetMusiciansByIds)); | ||
|
||
var result = Api.Ads.GetMusiciansByIds("1, 2, 3"); | ||
Assert.That(result[0].Name, Is.EqualTo("UGLYBOY")); | ||
Assert.That(result[1].Name, Is.EqualTo("Rudesarcasmov")); | ||
Assert.That(result[2].Name, Is.EqualTo("Santiz")); | ||
Assert.That(result[1].Id, Is.EqualTo(2)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using NUnit.Framework; | ||
using VkNet.Enums; | ||
using VkNet.Enums.SafetyEnums; | ||
using VkNet.Model; | ||
using VkNet.Model.RequestParams.Ads; | ||
using VkNet.Tests.Infrastructure; | ||
|
||
namespace VkNet.Tests.Categories.Ads | ||
{ | ||
[TestFixture] | ||
public class GetMusiciansTest : CategoryBaseTest | ||
{ | ||
protected override string Folder => "Ads"; | ||
|
||
[Test] | ||
public void GetMusicians() | ||
{ | ||
Url = "https://api.vk.com/method/ads.getMusicians"; | ||
|
||
ReadCategoryJsonPath(nameof(Api.Ads.GetMusicians)); | ||
|
||
var result = Api.Ads.GetMusicians("Alan Walker"); | ||
Assert.That(result[0].Name, Is.EqualTo("Alan Walker")); | ||
Assert.That(result[0].Id, Is.EqualTo(32697)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using NUnit.Framework; | ||
using VkNet.Enums.SafetyEnums; | ||
using VkNet.Model; | ||
using VkNet.Model.RequestParams.Ads; | ||
using VkNet.Tests.Infrastructure; | ||
|
||
namespace VkNet.Tests.Categories.Ads | ||
{ | ||
[TestFixture] | ||
public class UpdateOfficeUsersTest : CategoryBaseTest | ||
{ | ||
protected override string Folder => "Ads"; | ||
|
||
[Test] | ||
public void UpdateOfficeUsers() | ||
{ | ||
Url = "https://api.vk.com/method/ads.updateOfficeUsers"; | ||
|
||
ReadCategoryJsonPath(nameof(Api.Ads.UpdateOfficeUsers)); | ||
|
||
OfficeUsersSpecification officeUsersSpecification1 = new OfficeUsersSpecification | ||
{ | ||
UserId = 12423, | ||
Role = AccessRole.Reports, | ||
ClientsIds = new int[] | ||
{ | ||
1245, | ||
566, | ||
323 | ||
}, | ||
GrantAccessToAllClients = true, | ||
ViewBudget = true | ||
}; | ||
|
||
OfficeUsersSpecification officeUsersSpecification2 = new OfficeUsersSpecification | ||
{ | ||
UserId = 4324432, | ||
Role = AccessRole.Manager, | ||
ClientsIds = new int[] | ||
{ | ||
567357, | ||
566566, | ||
3645623 | ||
}, | ||
GrantAccessToAllClients = false, | ||
ViewBudget = false | ||
}; | ||
|
||
OfficeUsersSpecification[] data = | ||
{ | ||
officeUsersSpecification1, | ||
officeUsersSpecification2 | ||
}; | ||
|
||
var result = Api.Ads.UpdateOfficeUsers(new AdsDataSpecificationParams<OfficeUsersSpecification> | ||
{ | ||
AccountId = 1605245430, | ||
Data = data | ||
}); | ||
|
||
Assert.That(result[0].UserId, Is.EqualTo(1567)); | ||
Assert.That(result[0].IsSuccess, Is.False); | ||
Assert.That(result[0].Error.ErrorCode, Is.EqualTo(100)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"response": [{ | ||
"id": 32697, | ||
"name": "Alan Walker", | ||
"avatar": "https://sun9-24.u...-e7E&type=audio" | ||
}] | ||
} |
13 changes: 13 additions & 0 deletions
13
VkNet.Tests/TestData/Categories/Ads/GetMusiciansByIds.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"response": [{ | ||
"id": 1, | ||
"name": "UGLYBOY", | ||
"avatar": "https://sun9-11.u...FeTk&type=audio" | ||
}, { | ||
"id": 2, | ||
"name": "Rudesarcasmov" | ||
}, { | ||
"id": 3, | ||
"name": "Santiz" | ||
}] | ||
} |
10 changes: 10 additions & 0 deletions
10
VkNet.Tests/TestData/Categories/Ads/UpdateOfficeUsers.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"response": [{ | ||
"user_id": 1567, | ||
"is_success": false, | ||
"error": { | ||
"error_code": 100, | ||
"error_msg": "One of the parameters specified was missing or invalid: account_id is undefined" | ||
} | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
using VkNet.Enums; | ||
using VkNet.Enums.SafetyEnums; | ||
using VkNet.Utils; | ||
using VkNet.Utils.JsonConverter; | ||
|
||
namespace VkNet.Model | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
[Serializable] | ||
public class OfficeUsersSpecification | ||
{ | ||
/// <summary> | ||
/// Идентификатор пользователя, добавляемого как администратор/наблюдатель. | ||
/// </summary> | ||
[JsonProperty("user_id")] | ||
public long UserId { get; set; } | ||
|
||
/// <summary> | ||
/// Тип полномочий. | ||
/// </summary> | ||
[JsonProperty("role")] | ||
[JsonConverter(typeof(SafetyEnumJsonConverter))] | ||
public AccessRole Role { get; set; } | ||
|
||
/// <summary> | ||
/// Массив идентификаторов клиента. | ||
/// </summary> | ||
[JsonProperty("clients_ids")] | ||
public int[] ClientsIds { get; set; } | ||
|
||
/// <summary> | ||
/// Доступ ко всем текущим и новым клиентам этого кабинета. | ||
/// </summary> | ||
[JsonProperty("grant_access_to_all_clients")] | ||
public bool GrantAccessToAllClients { get; set; } | ||
|
||
/// <summary> | ||
/// Показывать ли бюджет пользователю. | ||
/// </summary> | ||
[JsonProperty("view_budget")] | ||
public bool? ViewBudget { get; set; } | ||
|
||
public OfficeUsersSpecification FromJson(VkResponse response) | ||
{ | ||
return new OfficeUsersSpecification | ||
{ | ||
UserId = response["user_id"], | ||
Role = response["role"], | ||
ClientsIds = response["client_ids"].ToListOf<int>(x => x).ToArray(), | ||
GrantAccessToAllClients = response["grant_access_to_all_clients"] | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using VkNet.Utils; | ||
|
||
namespace VkNet.Model | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
[Serializable] | ||
public class GetMusiciansByIdsResult | ||
{ | ||
/// <summary> | ||
/// Идентификатор музыканта. | ||
/// </summary> | ||
[JsonProperty("id")] | ||
public long Id { get; set; } | ||
|
||
/// <summary> | ||
/// Полный псевдоним музыканта. | ||
/// </summary> | ||
[JsonProperty("name")] | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// Аватарка музыканта. | ||
/// </summary> | ||
[JsonProperty("avatar")] | ||
public string Avatar { get; set; } | ||
|
||
/// <summary> | ||
/// Разобрать из json. | ||
/// </summary> | ||
/// <param name="response"> Ответ сервера. </param> | ||
/// <returns></returns> | ||
public static GetMusiciansByIdsResult FromJson(VkResponse response) | ||
{ | ||
return new GetMusiciansByIdsResult | ||
{ | ||
Id = response["id"], | ||
Name = response["name"], | ||
Avatar = response["avatar"] | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.