public ReadOnlyCollection <Message> Search([NotNull] string query, out int totalCount, int?count = null, int?offset = null) { if (string.IsNullOrEmpty(query)) { throw new ArgumentException("Query can not be null or empty.", "query"); } var parameters = new VkParameters { { "q", query }, { "count", count }, { "offset", offset } }; VkResponseArray response = _vk.Call("messages.search", parameters); totalCount = response[0]; return(response.Skip(1).ToReadOnlyCollectionOf <Message>(r => r)); }
public ReadOnlyCollection <Group> Get(long uid, bool extended = false, GroupsFilters filters = null, GroupsFields fields = null) { var parameters = new VkParameters { { "uid", uid }, { "extended", extended }, { "filter", filters }, { "fields", fields } }; VkResponseArray response = _vk.Call("groups.get", parameters); if (!extended) { return(response.Select(id => new Group { Id = id }).ToReadOnlyCollection()); } // в первой записи количество членов группы return(response.Skip(1).ToReadOnlyCollectionOf <Group>(r => r)); }
public ReadOnlyCollection <School> GetSchools(int countryId, int cityId, string query = "", int?offset = null, int?count = null) { VkErrors.ThrowIfNumberIsNegative(() => countryId); VkErrors.ThrowIfNumberIsNegative(() => cityId); VkErrors.ThrowIfNumberIsNegative(() => count); VkErrors.ThrowIfNumberIsNegative(() => offset); var parameters = new VkParameters { { "q", query }, { "country_id", countryId }, { "city_id", cityId }, { "offset", offset }, { "count", count } }; VkResponseArray response = _vk.Call("database.getSchools", parameters, true); return(response.Skip(1).ToReadOnlyCollectionOf <School>(x => x)); }
public ReadOnlyCollection <User> Search([NotNull] string query, out int itemsCount, ProfileFields fields = null, int count = 20, int offset = 0) { if (string.IsNullOrEmpty(query)) { throw new ArgumentException("Query can not be null or empty."); } var parameters = new VkParameters { { "q", query }, { "fields", fields }, { "count", count } }; if (offset > 0) { parameters.Add("offset", offset); } VkResponseArray response = _vk.Call("users.search", parameters); itemsCount = response[0]; return(response.Skip(1).ToReadOnlyCollectionOf <User>(r => r)); }
public ReadOnlyCollection <Group> Search([NotNull] string query, out int totalCount, uint?offset = null, uint?count = null, GroupSort sort = GroupSort.Normal, GroupType type = null, uint?countryId = null, uint?cityId = null, bool future = false) { VkErrors.ThrowIfNullOrEmpty(() => query); var parameters = new VkParameters { { "q", query }, { "offset", offset }, { "count", count }, { "future", future }, { "sort", sort }, { "type", type }, { "country_id", countryId }, { "city_id", cityId } }; VkResponseArray response = _vk.Call("groups.search", parameters); totalCount = response[0]; return(response.Skip(1).ToReadOnlyCollectionOf <Group>(r => r)); }
public ReadOnlyCollection <Comment> GetComments( long ownerId, long postId, out int totalCount, CommentsSort sort = null, bool needLikes = false, int?count = null, int?offset = null, int previewLength = 0) { VkErrors.ThrowIfNumberIsNegative(() => postId); VkErrors.ThrowIfNumberIsNegative(() => offset); VkErrors.ThrowIfNumberIsNegative(() => count); VkErrors.ThrowIfNumberIsNegative(() => previewLength); var parameters = new VkParameters { { "owner_id", ownerId }, { "post_id", postId }, { "need_likes", needLikes }, { "count", count }, { "offset", offset }, { "preview_length", previewLength }, { "v", _vk.ApiVersion } }; if (sort != null) { parameters.Add("sort", sort.ToString().ToLowerInvariant()); } VkResponseArray response = _vk.Call("wall.getComments", parameters); totalCount = response[0]; return(response.Skip(1).ToReadOnlyCollectionOf <Comment>(c => c)); }
public ReadOnlyCollection <Message> GetHistory( long id, bool isChat, out int totalCount, int?offset = null, int?count = null, bool?inReverse = null, long?startMessageId = null) { var parameters = new VkParameters { { isChat ? "chat_id" : "uid", id }, { "offset", offset }, { "count", count }, { "start_mid", startMessageId }, { "rev", inReverse } }; VkResponseArray response = _vk.Call("messages.getHistory", parameters); totalCount = response[0]; return(response.Skip(1).ToReadOnlyCollectionOf <Message>(r => r)); }