public ReadOnlyCollection <Group> Get(long uid, bool extended = false, GroupsFilters filters = null, GroupsFields fields = null, uint offset = 0, uint count = 1000) { VkErrors.ThrowIfNumberIsNegative(() => uid); var parameters = new VkParameters { { "user_id", uid }, { "extended", extended }, { "filter", filters }, { "fields", fields }, { "offset", offset } }; if (count < 1000) { parameters.Add("count", count); } var response = _vk.Call("groups.get", parameters); // в первой записи количество членов группы для (response["items"]) if (!extended) { return(response.ToReadOnlyCollectionOf(id => new Group { Id = id })); } return(response["items"].ToReadOnlyCollectionOf <Group>(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<Group> Get(long uid, bool extended = false, GroupsFilters filters = null, GroupsFields fields = null, int offset = 0, int count = 1000) { var parameters = new VkParameters { { "uid", uid }, { "extended", extended }, { "filter", filters }, { "fields", fields }, { "offset", offset }, { "count", count } }; VkResponse response = _vk.Call("groups.get", parameters); if (!extended) return response.ToReadOnlyCollectionOf<Group>(id => new Group { Id = id }); // в первой записи количество членов группы return response["items"].ToReadOnlyCollectionOf<Group>(r => r); }
public ReadOnlyCollection<Group> GetAll(long uid, bool extended = false, GroupsFilters filters = null, GroupsFields fields = null) { const int count = 1000; var i = 0; var result = new List<Group>(); do { var currentItems = _groups.Get(uid, extended, filters, fields, i * count, count); if (currentItems != null) result.AddRange(currentItems); } while (++i * count < (_vk.CountFromLastResponse ?? 0)); return result.ToReadOnlyCollection(); }
public ReadOnlyCollection<Group> Get(long uid, bool extended = false, GroupsFilters filters = null, GroupsFields fields = null, uint offset = 0, uint count = 1000) { VkErrors.ThrowIfNumberIsNegative(() => uid); var parameters = new GroupsGetParams { Count = count, Extended = extended, Fields = fields, Filter = filters, Offset = offset, UserId = uid }; return Get(parameters).ToReadOnlyCollection(); }
public ReadOnlyCollection <Group> Get(long uid, bool extended = false, GroupsFilters filters = null, GroupsFields fields = null, uint offset = 0, uint count = 1000) { VkErrors.ThrowIfNumberIsNegative(() => uid); var parameters = new GroupsGetParams { Count = count, Extended = extended, Fields = fields, Filter = filters, Offset = offset, UserId = uid }; return(Get(parameters)); }
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 void GroupsFiltersTest() { // get test Assert.That(GroupsFilters.Administrator.ToString(), Is.EqualTo("admin")); Assert.That(GroupsFilters.Editor.ToString(), Is.EqualTo("editor")); Assert.That(GroupsFilters.Moderator.ToString(), Is.EqualTo("moder")); Assert.That(GroupsFilters.Groups.ToString(), Is.EqualTo("groups")); Assert.That(GroupsFilters.Publics.ToString(), Is.EqualTo("publics")); Assert.That(GroupsFilters.Events.ToString(), Is.EqualTo("events")); Assert.That(GroupsFilters.All.ToString(), Is.EqualTo("admin,editor,events,groups,moder,publics")); // parse test Assert.That(GroupsFilters.FromJson("admin"), Is.EqualTo(GroupsFilters.Administrator)); Assert.That(GroupsFilters.FromJson("editor"), Is.EqualTo(GroupsFilters.Editor)); Assert.That(GroupsFilters.FromJson("moder"), Is.EqualTo(GroupsFilters.Moderator)); Assert.That(GroupsFilters.FromJson("groups"), Is.EqualTo(GroupsFilters.Groups)); Assert.That(GroupsFilters.FromJson("publics"), Is.EqualTo(GroupsFilters.Publics)); Assert.That(GroupsFilters.FromJson("events"), Is.EqualTo(GroupsFilters.Events)); Assert.That(GroupsFilters.FromJson("admin,editor,events,groups,moder,publics"), Is.EqualTo(GroupsFilters.All)); }
public void GroupsFiltersTest() { // get test Assert.That(actual: GroupsFilters.Administrator.ToString(), expression: Is.EqualTo(expected: "admin")); Assert.That(actual: GroupsFilters.Editor.ToString(), expression: Is.EqualTo(expected: "editor")); Assert.That(actual: GroupsFilters.Moderator.ToString(), expression: Is.EqualTo(expected: "moder")); Assert.That(actual: GroupsFilters.Groups.ToString(), expression: Is.EqualTo(expected: "groups")); Assert.That(actual: GroupsFilters.Publics.ToString(), expression: Is.EqualTo(expected: "publics")); Assert.That(actual: GroupsFilters.Events.ToString(), expression: Is.EqualTo(expected: "events")); Assert.That(actual: GroupsFilters.All.ToString(), expression: Is.EqualTo(expected: "admin,editor,events,groups,moder,publics")); // parse test Assert.That(actual: GroupsFilters.FromJsonString(val: "admin"), expression: Is.EqualTo(expected: GroupsFilters.Administrator)); Assert.That(actual: GroupsFilters.FromJsonString(val: "editor"), expression: Is.EqualTo(expected: GroupsFilters.Editor)); Assert.That(actual: GroupsFilters.FromJsonString(val: "moder"), expression: Is.EqualTo(expected: GroupsFilters.Moderator)); Assert.That(actual: GroupsFilters.FromJsonString(val: "groups"), expression: Is.EqualTo(expected: GroupsFilters.Groups)); Assert.That(actual: GroupsFilters.FromJsonString(val: "publics"), expression: Is.EqualTo(expected: GroupsFilters.Publics)); Assert.That(actual: GroupsFilters.FromJsonString(val: "events"), expression: Is.EqualTo(expected: GroupsFilters.Events)); Assert.That(actual: GroupsFilters.FromJsonString(val: "admin,editor,moder,groups,publics,events") , expression: Is.EqualTo(expected: GroupsFilters.All)); }
public ReadOnlyCollection<User> GetMembers(string gid, out int totalCount, uint? count = null, uint? offset = null, GroupsSort sort = null, UsersFields fields = null, GroupsFilters filters = null) { var parameters = new GroupsGetMembersParams { Offset = offset, Filter = filters, Fields = fields, Count = count, GroupId = gid, Sort = sort }; return GetMembers(out totalCount, parameters); }
public ReadOnlyCollection<User> GetMembers(long gid, out int totalCount, uint? count = null, uint? offset = null, GroupsSort sort = null, UsersFields fields = null, GroupsFilters filters = null) { VkErrors.ThrowIfNumberIsNegative(() => gid); var parameters = new GroupsGetMembersParams { GroupId = gid.ToString(), Count = count, Offset = offset, Sort = sort, Fields = fields, Filter = filters }; return GetMembers(out totalCount, parameters); }
public ReadOnlyCollection<long> GetMembers(long gid, out int totalCount, uint? count = null, uint? offset = null, GroupsSort sort = null, GroupsFields fields = null, GroupsFilters filters = null) { VkErrors.ThrowIfNumberIsNegative(() => gid); return GetMembers(gid.ToString(), out totalCount, count, offset, sort, fields, filters); }
private long[] getGroups(ulong uid, bool extended = false, GroupsFilters filters = null, GroupsFields fields = null, uint offset = 0, uint count = 1000) { var parameters = new VkParameters { { "uid", uid }, { "extended", extended }, { "filter", filters }, { "fields", fields }, { "offset", offset } }; if (count < 1000) { parameters.Add("count", count); } string answer = vkapi.Invoke("groups.get", parameters, false); JObject json = JObject.Parse(answer); JArray rawResponse = json["response"] as JArray; return rawResponse.Select(jv => (long)jv).ToArray(); }
public ReadOnlyCollection <long> GetMembers(long gid, out int totalCount, uint?count = null, uint?offset = null, GroupsSort sort = null, GroupsFields fields = null, GroupsFilters filters = null) { VkErrors.ThrowIfNumberIsNegative(() => gid); return(GetMembers(gid.ToString(), out totalCount, count, offset, sort, fields, filters)); }
public ReadOnlyCollection<ulong> GetMembers(ulong gid, out int totalCount, uint? count = null, uint? offset = null, GroupsSort sort = null, GroupsFields fields = null, GroupsFilters filters = null) { return GetMembers(gid.ToString(), out totalCount, count, offset, sort, fields, filters); }
public ReadOnlyCollection<Group> Get(long uid, bool extended = false, GroupsFilters filters = null, GroupsFields fields = null, int offset = 0, int count = 1000) { var parameters = new VkParameters { { "uid", uid }, { "extended", extended }, { "filter", filters }, { "fields", fields }, { "offset", offset }, { "count", count } }; VkResponse response = _vk.Call("groups.get", parameters); if (!extended) return response.ToReadOnlyCollectionOf<Group>(id => new Group { Id = id }); // в первой записи количество членов группы return response["items"].ToReadOnlyCollectionOf<Group>(r => r); }
public ReadOnlyCollection <ulong> GetMembers(ulong gid, out int totalCount, uint?count = null, uint?offset = null, GroupsSort sort = null, GroupsFields fields = null, GroupsFilters filters = null) { return(GetMembers(gid.ToString(), out totalCount, count, offset, sort, fields, filters)); }
public ReadOnlyCollection <ulong> GetMembers(string gid, out int totalCount, uint?count = null, uint?offset = null, GroupsSort sort = null, GroupsFields fields = null, GroupsFilters filters = null) { var parameters = new VkParameters { { "gid", gid }, { "offset", offset }, { "sort", sort }, { "fields", fields }, { "filter", filters } }; if (count.HasValue && count.Value > 0 && count.Value < 1000) { parameters.Add("count", count); } var response = _vk.Call("groups.getMembers", parameters, true); totalCount = response["count"]; VkResponseArray users = response["users"]; return(users.ToReadOnlyCollectionOf <ulong>(x => x)); }
public ReadOnlyCollection<Group> Get(ulong uid, bool extended = false, GroupsFilters filters = null, GroupsFields fields = null, uint offset = 0, uint count = 1000) { var parameters = new VkParameters { { "uid", uid }, { "extended", extended }, { "filter", filters }, { "fields", fields }, { "offset", offset } }; if (count < 1000) { parameters.Add("count", count); } var response = _vk.Call("groups.get", parameters); // в первой записи количество членов группы для (response["items"]) return !extended ? response.ToReadOnlyCollectionOf(id => new Group { Id = id }) : response["items"].ToReadOnlyCollectionOf<Group>(r => r); }
public ReadOnlyCollection <User> GetMembers(long gid, out int totalCount, uint?count = null, uint?offset = null, GroupsSort sort = null, UsersFields fields = null, GroupsFilters filters = null) { VkErrors.ThrowIfNumberIsNegative(() => gid); var parameters = new GroupsGetMembersParams { GroupId = gid.ToString(), Count = count, Offset = offset, Sort = sort, Fields = fields, Filter = filters }; return(GetMembers(out totalCount, parameters)); }
public ReadOnlyCollection<ulong> GetMembers(string gid, out int totalCount, uint? count = null, uint? offset = null, GroupsSort sort = null, GroupsFields fields = null, GroupsFilters filters = null) { var parameters = new VkParameters { { "gid", gid }, { "offset", offset }, { "sort", sort }, { "fields", fields }, { "filter", filters } }; if (count.HasValue && count.Value > 0 && count.Value < 1000) { parameters.Add("count", count); } var response = _vk.Call("groups.getMembers", parameters, true); totalCount = response["count"]; VkResponseArray users = response["users"]; return users.ToReadOnlyCollectionOf<ulong>(x => x); }
public ReadOnlyCollection <User> GetMembers(string gid, out int totalCount, uint?count = null, uint?offset = null, GroupsSort sort = null, UsersFields fields = null, GroupsFilters filters = null) { var parameters = new GroupsGetMembersParams { Offset = offset, Filter = filters, Fields = fields, Count = count, GroupId = gid, Sort = sort }; return(GetMembers(out totalCount, parameters)); }