Skip to content

Commit d576902

Browse files
author
Bohdan Shtepan
authored
Merge pull request #24 from virtyaluk/feature/v5.63
API v5.63
2 parents 70092d0 + 461129f commit d576902

19 files changed

+385
-31
lines changed

ModernDev.InTouch.Shared/API/MethodParamsGroup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public abstract class MethodParamsGroup
2626
/// Iterates over all non-nullable class properties and adds them to the <see cref="MethodParamsGroup"/> collection.
2727
/// </summary>
2828
/// <returns>A <see cref="MethodParamsGroup"/> instance containing all the non-nullable properties of the current class.</returns>
29-
public MethodParams GetParams()
29+
private MethodParams GetParams()
3030
{
3131
var mp = new MethodParams();
3232

ModernDev.InTouch.Shared/API/Methods/UtilsMethods.cs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ public async Task<Response<int>> GetServerTime()
6161
/// Allows to receive a link shortened via vk.cc.
6262
/// </summary>
6363
/// <param name="url">URL to be shortened.</param>
64+
/// <param name="isPrivate">True — private stats, False — public stats.</param>
6465
/// <returns>Returns an object containing shortened URL.</returns>
65-
public async Task<Response<string>> GetShortLink(string url)
66-
=> await Request<string>("getShortLink", new MethodParams
66+
public async Task<Response<ShortenedLink>> GetShortLink(string url, bool isPrivate = false)
67+
=> await Request<ShortenedLink>("getShortLink", new MethodParams
6768
{
68-
{"url", url}
69-
}, false, "short_url");
69+
{"url", url},
70+
{"private", isPrivate}
71+
});
7072

7173
/// <summary>
7274
/// Returns stats data for shortened link.
@@ -89,6 +91,30 @@ public async Task<Response<LinkStats>> GetLinkStats(string key,
8991
{"extended", extended}
9092
});
9193

94+
/// <summary>
95+
/// Returns a list of user's shortened links.
96+
/// </summary>
97+
/// <param name="count">Number of links to return.</param>
98+
/// <param name="offset">Offset needed to return a specific subset of links.</param>
99+
/// <returns>Returns a list of <see cref="ShortenedLink"/> objects.</returns>
100+
public async Task<Response<ItemsList<ShortenedLink>>> GetLastShortenedLinks(int count = 10, int offset = 0)
101+
=> await Request<ItemsList<ShortenedLink>>("getLastShortenedLinks", new MethodParams
102+
{
103+
{"count", count},
104+
{"offset", offset}
105+
});
106+
107+
/// <summary>
108+
/// Deletes shortened link from user's list.
109+
/// </summary>
110+
/// <param name="key">Link key (characters after "vk.cc").</param>
111+
/// <returns>When executed successfully it returns True.</returns>
112+
public async Task<Response<bool>> DeleteFromLastShortened(string key)
113+
=> await Request<bool>("deleteFromLastShortened", new MethodParams
114+
{
115+
{"key", key, true}
116+
});
117+
92118
#endregion
93119
}
94120
}

ModernDev.InTouch.Shared/API/Methods/WallMethods.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,24 @@ public async Task<Response<bool>> ReportComment(int commentId, int ownerId, Repo
294294
{"reason", (int) reason }
295295
});
296296

297+
/// <summary>
298+
/// Allows to create hidden post which will not be shown on the community's wall and can be used for creating an ad with type "Community post".
299+
/// Hidden posts creation is available for communities only; user should be community's editor, moderator or administrator.
300+
/// </summary>
301+
/// <param name="methodParams">A <see cref="WallAdsStealthParams"/> object with the params.</param>
302+
/// <returns>Returns the Id of the created post.</returns>
303+
public async Task<Response<int>> PostAdsStealth(WallAdsStealthParams methodParams)
304+
=> await Request<int>("postAdsStealth", methodParams);
305+
306+
/// <summary>
307+
/// Allows to edit hidden post.
308+
/// Hidden posts creation is available for communities only; user should be community's editor, moderator or administrator.
309+
/// </summary>
310+
/// <param name="methodParams">A <see cref="WallEditAdsStealthParams"/> object with the params.</param>
311+
/// <returns>Returns 1.</returns>
312+
public async Task<Response<bool>> EditAdsStealth(WallEditAdsStealthParams methodParams)
313+
=> await Request<bool>("editAdsStealth", methodParams);
314+
297315
#endregion
298316
}
299317
}

ModernDev.InTouch.Shared/API/MethodsParams/BaseGetCommentsParams.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
* Licensed under the GPLv3 license.
1111
*/
1212

13+
using System.Collections.Generic;
14+
using System.Linq;
15+
using static ModernDev.InTouch.Helpers.Utils;
16+
1317
namespace ModernDev.InTouch
1418
{
1519
public abstract class BaseGetCommentsParams : MethodParamsGroup
@@ -55,5 +59,22 @@ public abstract class BaseGetCommentsParams : MethodParamsGroup
5559
/// </summary>
5660
[MethodParam(Name = "extended")]
5761
public bool Extended { get; set; }
62+
63+
private List<string> _fields;
64+
65+
/// <summary>
66+
/// The list of additional fields for the profiles and groups that need to be returned. The list can accept <see cref="UserProfileFields"/>, <see cref="GroupProfileFields"/> and regular string objects.
67+
/// </summary>
68+
[MethodParam(Name = "fields")]
69+
public List<object> Fields
70+
{
71+
get { return _fields?.Cast<object>().ToList(); }
72+
set
73+
{
74+
_fields = value?.Where(
75+
el => el != null && (el is UserProfileFields || el is GroupProfileFields || el is string))
76+
.Select(el => el is string ? (string)el : ToEnumString(el)).ToList();
77+
}
78+
}
5879
}
5980
}

ModernDev.InTouch.Shared/API/MethodsParams/GroupsSetCallbackSettingsParams.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,11 @@ public class GroupsSetCallbackSettingsParams : MethodParamsGroup
118118
/// </summary>
119119
[MethodParam(Name = "group_leave")]
120120
public bool GroupLeave { get; set; }
121+
122+
/// <summary>
123+
/// epost from the community
124+
/// </summary>
125+
[MethodParam(Name = "wall_repost")]
126+
public bool WallRepost { get; set; }
121127
}
122128
}

ModernDev.InTouch.Shared/API/MethodsParams/PhotosGetCommentsParam.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
* Licensed under the GPLv3 license.
1111
*/
1212

13-
using System.Collections.Generic;
14-
using System.Linq;
15-
using static ModernDev.InTouch.Helpers.Utils;
16-
1713
namespace ModernDev.InTouch
1814
{
1915
/// <summary>
@@ -32,22 +28,5 @@ public class PhotosGetCommentsParam : BaseGetCommentsParams
3228
/// </summary>
3329
[MethodParam(Name = "access_key")]
3430
public string AccessKey { get; set; }
35-
36-
private List<string> _fields;
37-
38-
/// <summary>
39-
/// The list of additional fields for the profiles and groups that need to be returned. The list can accept <see cref="UserProfileFields"/>, <see cref="GroupProfileFields"/> and regular string objects.
40-
/// </summary>
41-
[MethodParam(Name = "fields")]
42-
public List<object> Fields
43-
{
44-
get { return _fields?.Cast<object>().ToList(); }
45-
set
46-
{
47-
_fields = value?.Where(
48-
el => el != null && (el is UserProfileFields || el is GroupProfileFields || el is string))
49-
.Select(el => el is string ? (string)el : ToEnumString(el)).ToList();
50-
}
51-
}
5231
}
5332
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/**
2+
* This file\code is part of InTouch project.
3+
*
4+
* InTouch - is a .NET wrapper for the vk.com API.
5+
* https://github.com/virtyaluk/InTouch
6+
*
7+
* Copyright (c) 2016 Bohdan Shtepan
8+
* http://modern-dev.com/
9+
*
10+
* Licensed under the GPLv3 license.
11+
*/
12+
13+
using System.Collections.Generic;
14+
using ModernDev.InTouch.Helpers;
15+
16+
namespace ModernDev.InTouch
17+
{
18+
public class WallAdsStealthParams : MethodParamsGroup
19+
{
20+
/// <summary>
21+
/// Wall owner ID (community ID should be passed with minus).
22+
/// </summary>
23+
[MethodParam(Name = "owner_id")]
24+
public int OwnerId { get; set; }
25+
26+
/// <summary>
27+
/// (Required if attachments is not set.) Text of the post.
28+
/// </summary>
29+
[MethodParam(Name = "message")]
30+
public string Message { get; set; }
31+
32+
/// <summary>
33+
/// (Required if message is not set.) List of objects attached to the post.
34+
/// </summary>
35+
[MethodParam(Name = "attachments")]
36+
public List<string> Attachments { get; set; }
37+
38+
/// <summary>
39+
/// (Required if message is not set.) List of objects attached to the post.
40+
/// </summary>
41+
public List<IMediaAttachment> Attachments2
42+
{
43+
set { Attachments = value?.GetPostAttachments(); }
44+
}
45+
46+
/// <summary>
47+
/// True — post will be signed with the name of the posting user; False — post will not be signed(default).
48+
/// </summary>
49+
[MethodParam(Name = "signed")]
50+
public bool IsSigned { get;set; }
51+
52+
/// <summary>
53+
/// Geographical latitude of a check-in, in degrees (from -90 to 90).
54+
/// </summary>
55+
[MethodParam(Name = "lat")]
56+
public double? Latitude { get; set; }
57+
58+
/// <summary>
59+
/// Geographical longitude of a check-in, in degrees (from -180 to 180).
60+
/// </summary>
61+
[MethodParam(Name = "long")]
62+
public double? Longitude { get; set; }
63+
64+
/// <summary>
65+
/// Location ID.
66+
/// </summary>
67+
[MethodParam(Name = "place_id")]
68+
public int? PlaceId { get; set; }
69+
70+
/// <summary>
71+
/// Unique identifier to avoid duplication the same post.
72+
/// </summary>
73+
[MethodParam(Name = "guid")]
74+
public string GUID { get; } = Utils.RandomString(10);
75+
76+
/// <summary>
77+
/// Snippet button Id.
78+
/// </summary>
79+
[MethodParam(Name = "link_button")]
80+
public string LinkButton { get; set; }
81+
82+
/// <summary>
83+
/// Snippet button title.
84+
/// </summary>
85+
[MethodParam(Name = "link_title")]
86+
public string LinkTitle { get; set; }
87+
88+
/// <summary>
89+
/// Snippet button image url.
90+
/// </summary>
91+
[MethodParam(Name = "link_image")]
92+
public string LinkImage { get; set; }
93+
}
94+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* This file\code is part of InTouch project.
3+
*
4+
* InTouch - is a .NET wrapper for the vk.com API.
5+
* https://github.com/virtyaluk/InTouch
6+
*
7+
* Copyright (c) 2016 Bohdan Shtepan
8+
* http://modern-dev.com/
9+
*
10+
* Licensed under the GPLv3 license.
11+
*/
12+
13+
namespace ModernDev.InTouch
14+
{
15+
public class WallEditAdsStealthParams : WallAdsStealthParams
16+
{
17+
/// <summary>
18+
/// Post Id.
19+
/// </summary>
20+
[MethodParam(Name = "post_id", IsRequired = true)]
21+
public int PostId { get; set; }
22+
}
23+
}

ModernDev.InTouch.Shared/Enums/AccessPermissions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,11 @@ public enum AccessPermissions
140140
/// </summary>
141141
[EnumMember(Value = "")]
142142
None = 0,
143+
144+
/// <summary>
145+
/// Possibility to make API requests without HTTPS.
146+
/// </summary>
147+
[EnumMember(Value = "nohttps")]
148+
NoHTTPS = 0
143149
}
144150
}

ModernDev.InTouch.Shared/Model/Attachments/Post.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ public class Post : IMediaAttachment, IFeedback, IMessageAttachment
181181
[JsonProperty("is_pinned")]
182182
public bool IsPinned { get; set; }
183183

184+
/// <summary>
185+
/// An information about post views.
186+
/// </summary>
187+
[DataMember, JsonProperty("views")]
188+
public PostViews Views { get; set; }
189+
184190
#region Extra properties
185191

186192
[DataMember]

ModernDev.InTouch.Shared/Model/CallbackSettings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,11 @@ public class CallbackSettings
148148
[DataMember]
149149
[JsonProperty("wall_post_new")]
150150
public bool WallPostNew { get; set; }
151+
152+
/// <summary>
153+
/// Repost from the community.
154+
/// </summary>
155+
[DataMember, JsonProperty("wall_repost")]
156+
public bool WallRepost { get; set; }
151157
}
152158
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* This file\code is part of InTouch project.
3+
*
4+
* InTouch - is a .NET wrapper for the vk.com API.
5+
* https://github.com/virtyaluk/InTouch
6+
*
7+
* Copyright (c) 2017 Bohdan Shtepan
8+
* http://modern-dev.com/
9+
*
10+
* Licensed under the GPLv3 license.
11+
*/
12+
13+
using System.Diagnostics;
14+
using System.Runtime.Serialization;
15+
using Newtonsoft.Json;
16+
17+
namespace ModernDev.InTouch
18+
{
19+
/// <summary>
20+
/// Represents an information about post views.
21+
/// </summary>
22+
[DataContract, DebuggerDisplay("PostViews: {Count}")]
23+
public class PostViews
24+
{
25+
/// <summary>
26+
/// Views number.
27+
/// </summary>
28+
[DataMember, JsonProperty("views")]
29+
public int? Count { get; set; }
30+
}
31+
}

0 commit comments

Comments
 (0)