Beispiel #1
0
 /// <inheritdoc />
 public Task <ReadOnlyCollection <Group> > GetByIdAsync(IEnumerable <string> groupIds
                                                        , string groupId
                                                        , GroupsFields fields
                                                        , bool skipAuthorization = false)
 {
     return(TypeHelper.TryInvokeMethodAsync(func: () =>
                                            GetById(groupIds: groupIds, groupId: groupId, fields: fields, skipAuthorization: skipAuthorization)));
 }
Beispiel #2
0
        public Group GetById(string gid, GroupsFields fields = null)
        {
            var parameters = new VkParameters {
                { "group_id", gid }, { "fields", fields }
            };

            return(_vk.Call("groups.getById", parameters)[0]);
        }
Beispiel #3
0
 public ReadOnlyCollection <Group> GetById(IEnumerable <long> gids, GroupsFields fields = null)
 {
     foreach (var gid in gids)
     {
         VkErrors.ThrowIfNumberIsNegative(() => gid);
     }
     return(GetById(gids.Select(x => x.ToString()), fields));
 }
Beispiel #4
0
 /// <inheritdoc />
 public Task <VkCollection <GetBannedResult> > GetBannedAsync(long groupId
                                                              , long?offset         = null
                                                              , long?count          = null
                                                              , GroupsFields fields = null
                                                              , long?ownerId        = null)
 {
     return(TypeHelper.TryInvokeMethodAsync(func: () =>
                                            GetBanned(groupId: groupId, offset: offset, count: count, fields: fields, ownerId: ownerId)));
 }
        public ReadOnlyCollection <Group> GetById(IEnumerable <long> gids, GroupsFields fields = null)
        {
            var parameters = new VkParameters {
                { "gids", gids }, { "fields", fields }
            };

            VkResponseArray response = _vk.Call("groups.getById", parameters);

            return(response.ToReadOnlyCollectionOf <Group>(x => x));
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
 /// <inheritdoc />
 public Task <VkCollection <Group> > GetSubscriptionsAsync(long?userId              = null
                                                           , int?count              = null
                                                           , int?offset             = null
                                                           , GroupsFields fields    = null
                                                           , bool skipAuthorization = false)
 {
     return(TypeHelper.TryInvokeMethodAsync(func: () =>
                                            _vk.Users.GetSubscriptions(userId: userId
                                                                       , count: count
                                                                       , offset: offset
                                                                       , fields: fields
                                                                       , skipAuthorization: skipAuthorization)));
 }
Beispiel #8
0
 public void GroupsFieldsTest()
 {
     // get test
     Assert.That(GroupsFields.CityId.ToString(), Is.EqualTo("city"));
     Assert.That(GroupsFields.CountryId.ToString(), Is.EqualTo("country"));
     Assert.That(GroupsFields.Place.ToString(), Is.EqualTo("place"));
     Assert.That(GroupsFields.Description.ToString(), Is.EqualTo("description"));
     Assert.That(GroupsFields.WikiPage.ToString(), Is.EqualTo("wiki_page"));
     Assert.That(GroupsFields.MembersCount.ToString(), Is.EqualTo("members_count"));
     Assert.That(GroupsFields.Counters.ToString(), Is.EqualTo("counters"));
     Assert.That(GroupsFields.StartDate.ToString(), Is.EqualTo("start_date"));
     Assert.That(GroupsFields.EndDate.ToString(), Is.EqualTo("end_date"));
     Assert.That(GroupsFields.CanPost.ToString(), Is.EqualTo("can_post"));
     Assert.That(GroupsFields.CanSeelAllPosts.ToString(), Is.EqualTo("can_see_all_posts"));
     Assert.That(GroupsFields.CanUploadDocuments.ToString(), Is.EqualTo("can_upload_doc"));
     Assert.That(GroupsFields.CanCreateTopic.ToString(), Is.EqualTo("can_create_topic"));
     Assert.That(GroupsFields.Activity.ToString(), Is.EqualTo("activity"));
     Assert.That(GroupsFields.Status.ToString(), Is.EqualTo("status"));
     Assert.That(GroupsFields.Contacts.ToString(), Is.EqualTo("contacts"));
     Assert.That(GroupsFields.Links.ToString(), Is.EqualTo("links"));
     Assert.That(GroupsFields.FixedPostId.ToString(), Is.EqualTo("fixed_post"));
     Assert.That(GroupsFields.IsVerified.ToString(), Is.EqualTo("verified"));
     Assert.That(GroupsFields.Site.ToString(), Is.EqualTo("site"));
     Assert.That(GroupsFields.BanInfo.ToString(), Is.EqualTo("ban_info"));
     Assert.That(GroupsFields.All.ToString(), Is.EqualTo("activity,ban_info,can_create_topic,can_post,can_see_all_posts,city,contacts,counters,country,description,end_date,fixed_post,links,members_count,place,site,start_date,status,verified,wiki_page"));
     Assert.That(GroupsFields.AllUndocumented.ToString(), Is.EqualTo("activity,ban_info,can_create_topic,can_post,can_see_all_posts,can_upload_doc,city,contacts,counters,country,description,end_date,fixed_post,links,members_count,place,site,start_date,status,verified,wiki_page"));
     // parse test
     Assert.That(GroupsFields.FromJson("city"), Is.EqualTo(GroupsFields.CityId));
     Assert.That(GroupsFields.FromJson("country"), Is.EqualTo(GroupsFields.CountryId));
     Assert.That(GroupsFields.FromJson("place"), Is.EqualTo(GroupsFields.Place));
     Assert.That(GroupsFields.FromJson("description"), Is.EqualTo(GroupsFields.Description));
     Assert.That(GroupsFields.FromJson("wiki_page"), Is.EqualTo(GroupsFields.WikiPage));
     Assert.That(GroupsFields.FromJson("members_count"), Is.EqualTo(GroupsFields.MembersCount));
     Assert.That(GroupsFields.FromJson("counters"), Is.EqualTo(GroupsFields.Counters));
     Assert.That(GroupsFields.FromJson("start_date"), Is.EqualTo(GroupsFields.StartDate));
     Assert.That(GroupsFields.FromJson("end_date"), Is.EqualTo(GroupsFields.EndDate));
     Assert.That(GroupsFields.FromJson("can_post"), Is.EqualTo(GroupsFields.CanPost));
     Assert.That(GroupsFields.FromJson("can_see_all_posts"), Is.EqualTo(GroupsFields.CanSeelAllPosts));
     Assert.That(GroupsFields.FromJson("can_upload_doc"), Is.EqualTo(GroupsFields.CanUploadDocuments));
     Assert.That(GroupsFields.FromJson("can_create_topic"), Is.EqualTo(GroupsFields.CanCreateTopic));
     Assert.That(GroupsFields.FromJson("activity"), Is.EqualTo(GroupsFields.Activity));
     Assert.That(GroupsFields.FromJson("status"), Is.EqualTo(GroupsFields.Status));
     Assert.That(GroupsFields.FromJson("contacts"), Is.EqualTo(GroupsFields.Contacts));
     Assert.That(GroupsFields.FromJson("links"), Is.EqualTo(GroupsFields.Links));
     Assert.That(GroupsFields.FromJson("fixed_post"), Is.EqualTo(GroupsFields.FixedPostId));
     Assert.That(GroupsFields.FromJson("verified"), Is.EqualTo(GroupsFields.IsVerified));
     Assert.That(GroupsFields.FromJson("site"), Is.EqualTo(GroupsFields.Site));
     Assert.That(GroupsFields.FromJson("ban_info"), Is.EqualTo(GroupsFields.BanInfo));
     Assert.That(GroupsFields.FromJson("activity,ban_info,can_create_topic,can_post,can_see_all_posts,city,contacts,counters,country,description,end_date,fixed_post,links,members_count,place,site,start_date,status,verified,wiki_page"), Is.EqualTo(GroupsFields.All));
     Assert.That(GroupsFields.FromJson("activity,ban_info,can_create_topic,can_post,can_see_all_posts,can_upload_doc,city,contacts,counters,country,description,end_date,fixed_post,links,members_count,place,site,start_date,status,verified,wiki_page"), Is.EqualTo(GroupsFields.AllUndocumented));
 }
Beispiel #9
0
        /// <inheritdoc />
        public VkCollection <GetBannedResult> GetBanned(long groupId, long?offset = null, long?count   = null,
                                                        GroupsFields fields       = null, long?ownerId = null)
        {
            var parameters = new VkParameters
            {
                { "group_id", groupId },
                { "offset", offset },
                { "count", count },
                { "fields", fields },
                { "owner_id", ownerId }
            };

            return(_vk.Call <VkCollection <GetBannedResult> >("groups.getBanned", parameters));
        }
        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();
        }
Beispiel #11
0
        /// <inheritdoc />
        public ReadOnlyCollection <Group> GetById(IEnumerable <string> groupIds
                                                  , string groupId
                                                  , GroupsFields fields
                                                  , bool skipAuthorization = false)
        {
            var parameters = new VkParameters
            {
                { "group_ids", groupIds }
                , { "group_id", groupId }
                , { "fields", fields }
            };

            return(_vk.Call(methodName: "groups.getById", parameters: parameters, skipAuthorization: skipAuthorization)
                   .ToReadOnlyCollectionOf <Group>(selector: x => x));
        }
Beispiel #12
0
		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();
		}
Beispiel #13
0
        public VkCollection <Group> GetSubscriptions(long?userId              = null
                                                     , int?count              = null
                                                     , int?offset             = null
                                                     , GroupsFields fields    = null
                                                     , bool skipAuthorization = false)
        {
            VkErrors.ThrowIfNumberIsNegative(expr: () => userId);
            VkErrors.ThrowIfNumberIsNegative(expr: () => count);
            VkErrors.ThrowIfNumberIsNegative(expr: () => offset);

            var parameters = new VkParameters
            {
                { "user_id", userId }
                , { "extended", true }
                , { "offset", offset }
                , { "count", count }
                , { "fields", fields }
            };

            return(_vk.Call(methodName: "users.getSubscriptions", parameters: parameters, skipAuthorization: skipAuthorization)
                   .ToVkCollectionOf <Group>(selector: x => x));
        }
Beispiel #14
0
 public Group GetById(ulong gid, GroupsFields fields = null)
 {
     return GetById(gid.ToString(), fields);
 }
Beispiel #15
0
 public ReadOnlyCollection <Group> GetById(IEnumerable <ulong> gids, GroupsFields fields = null)
 {
     return(GetById(gids.Select(x => x.ToString()), fields));
 }
Beispiel #16
0
        public VkCollection <Group> GetSubscriptions(long?userId = null, int?count = null, int?offset = null, GroupsFields fields = null)
        {
            VkErrors.ThrowIfNumberIsNegative(() => userId);
            VkErrors.ThrowIfNumberIsNegative(() => count);
            VkErrors.ThrowIfNumberIsNegative(() => offset);

            var parameters = new VkParameters
            {
                { "user_id", userId },
                { "extended", true },
                { "offset", offset },
                { "count", count },
                { "fields", fields }
            };

            return(_vk.Call("users.getSubscriptions", parameters).ToVkCollectionOf <Group>(x => x));
        }
Beispiel #17
0
 public Group GetGroup(long id, GroupsFields fields)
 {
     RaiseLog(LogSeverity.Debug, "GetGroup request");
     return(_vkApi.Groups.GetById(-id, fields));
 }
Beispiel #18
0
 public Group GetById(long gid, GroupsFields fields = null)
 {
     VkErrors.ThrowIfNumberIsNegative(() => gid);
     return GetById(gid.ToString(), fields);
 }
Beispiel #19
0
 /// <inheritdoc />
 public async Task <ReadOnlyCollection <Group> > GetByIdAsync(IEnumerable <string> groupIds, string groupId,
                                                              GroupsFields fields, bool skipAuthorization = false)
 {
     return(await TypeHelper.TryInvokeMethodAsync(() =>
                                                  _vk.Groups.GetById(groupIds, groupId, fields, skipAuthorization)));
 }
Beispiel #20
0
		public ReadOnlyCollection<User> GetMembers(long gid, out int totalCount, uint? count = null, uint? offset = null, GroupsSort sort = null, GroupsFields 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);
		}
Beispiel #21
0
        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
            {
                { "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"])
            return(!extended?response.ToReadOnlyCollectionOf(id => new Group {
                Id = id
            }) : response["items"].ToReadOnlyCollectionOf <Group>(r => r));
        }
Beispiel #22
0
        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));
        }
Beispiel #23
0
 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));
 }
Beispiel #24
0
 public Group GetById(ulong gid, GroupsFields fields = null)
 {
     return(GetById(gid.ToString(), fields));
 }
Beispiel #25
0
 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)
        {
            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));
        }
Beispiel #27
0
		public ReadOnlyCollection<User> GetMembers(string gid, out int totalCount, uint? count = null, uint? offset = null, GroupsSort sort = null, GroupsFields 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);
		}
Beispiel #28
0
        public ReadOnlyCollection <Group> GetById(IEnumerable <string> groupIds, string groupId, GroupsFields fields)
        {
            var parameters = new VkParameters {
                { "group_ids", groupIds },
                { "group_id", groupId },
                { "fields", fields }
            };

            return(_vk.Call("groups.getById", parameters).ToReadOnlyCollectionOf <Group>(x => x));
        }
Beispiel #29
0
        public ReadOnlyCollection<Group> GetSubscriptions(long? userId = null, int? count = null, int? offset = null, GroupsFields fields = null)
        {
            VkErrors.ThrowIfNumberIsNegative(() => userId);
            VkErrors.ThrowIfNumberIsNegative(() => count);
            VkErrors.ThrowIfNumberIsNegative(() => offset);

            var parameters = new VkParameters
                {
                    { "user_id", userId },
                    { "extended", true },
                    { "offset", offset },
                    { "count", count },
                    { "fields", fields }
                };

            VkResponseArray response = _vk.Call("users.getSubscriptions", parameters);

            return response.ToReadOnlyCollectionOf<Group>(x => x);
        }
Beispiel #30
0
 public ReadOnlyCollection<Group> GetById(IEnumerable<long> gids, GroupsFields fields = null)
 {
     foreach (var gid in gids)
         VkErrors.ThrowIfNumberIsNegative(() => gid);
     return GetById(gids.Select(x => x.ToString()), fields);
 }
Beispiel #31
0
        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();
        }
Beispiel #32
0
        public ReadOnlyCollection<User> GetBanned(long groupId, long? offset = null, long? count = null, GroupsFields fields = null, long? userId = null)
        {
            var parameters = new VkParameters {
                { "group_id", groupId },
                { "offset", offset },
                { "count", count },
                { "fields", fields },
                { "user_id", userId }
            };

            return _vk.Call("groups.getBanned", parameters).ToReadOnlyCollectionOf<User>(x => x);
        }
Beispiel #33
0
 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);
 }
Beispiel #34
0
 public Group GetById(long gid, GroupsFields fields = null)
 {
     VkErrors.ThrowIfNumberIsNegative(() => gid);
     return(GetById(gid.ToString(), fields));
 }
Beispiel #35
0
 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));
 }
Beispiel #36
0
 public ReadOnlyCollection<Group> GetById(IEnumerable<ulong> gids, GroupsFields fields = null)
 {
     return GetById(gids.Select(x => x.ToString()), fields);
 }
Beispiel #37
0
 public Group GetById(long gid, GroupsFields fields = null)
 {
     VkErrors.ThrowIfNumberIsNegative(() => gid);
     return GetById(new List<string>(), gid.ToString(), fields).FirstOrDefault();
 }
        public ReadOnlyCollection<Group> Search([NotNull] string query, out int totalCount, int? offset = null, int? count = null, GroupsFields fields = null, int sort = 0)
        {
            VkErrors.ThrowIfNullOrEmpty(() => query);

            var parameters = new VkParameters { { "q", query }, { "offset", offset }, { "count", count }, { "fields", fields }, { "sort", sort } };

            VkResponseArray response = _vk.Call("groups.search", parameters);

            totalCount = response[0];

            return response.Skip(1).ToReadOnlyCollectionOf<Group>(r => r);
        }
Beispiel #39
0
        public ReadOnlyCollection<Group> GetById(IEnumerable<string> groupIds, string groupId, GroupsFields fields)
        {
            var parameters = new VkParameters {
                { "group_ids", groupIds },
                { "group_id", groupId },
                { "fields", fields }
            };

            return _vk.Call("groups.getById", parameters).ToReadOnlyCollectionOf<Group>(x => x);
        }
Beispiel #40
0
        public VkCollection<Group> GetSubscriptions(long? userId = null, int? count = null, int? offset = null, GroupsFields fields = null, bool skipAuthorization = false)
        {
            VkErrors.ThrowIfNumberIsNegative(() => userId);
            VkErrors.ThrowIfNumberIsNegative(() => count);
            VkErrors.ThrowIfNumberIsNegative(() => offset);

            var parameters = new VkParameters
            {
                { "user_id", userId },
                { "extended", true },
                { "offset", offset },
                { "count", count },
                { "fields", fields }
            };

            return _vk.Call("users.getSubscriptions", parameters, skipAuthorization).ToVkCollectionOf<Group>(x => x);
        }
Beispiel #41
0
        public ReadOnlyCollection <User> GetBanned(long groupId, long?offset = null, long?count = null, GroupsFields fields = null, long?userId = null)
        {
            var parameters = new VkParameters {
                { "group_id", groupId },
                { "offset", offset },
                { "count", count },
                { "fields", fields },
                { "user_id", userId }
            };

            return(_vk.Call("groups.getBanned", parameters).ToReadOnlyCollectionOf <User>(x => x));
        }
Beispiel #42
0
        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);
        }
Beispiel #43
0
 public ReadOnlyCollection<Group> GetById(IEnumerable<string> gids, GroupsFields fields = null)
 {
     return GetById(gids, null, fields);
 }
Beispiel #44
0
        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);
        }
Beispiel #45
0
 public Group GetById(string gid, GroupsFields fields = null)
 {
     return GetById(new List<string>(), gid, fields).FirstOrDefault();
 }
Beispiel #46
0
 public Group GetById(long gid, GroupsFields fields = null)
 {
     VkErrors.ThrowIfNumberIsNegative(() => gid);
     return(GetById(new List <string>(), gid.ToString(), fields).FirstOrDefault());
 }
Beispiel #47
0
 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);
 }
Beispiel #48
0
 public Group GetById(string gid, GroupsFields fields = null)
 {
     return(GetById(new List <string>(), gid, fields).FirstOrDefault());
 }
Beispiel #49
0
        public ReadOnlyCollection<Group> GetById(IEnumerable<string> gids, GroupsFields fields = null)
        {
            var parameters = new VkParameters { { "group_ids", gids }, { "fields", fields } };

            VkResponseArray response = _vk.Call("groups.getById", parameters);
            return response.ToReadOnlyCollectionOf<Group>(x => x);
        }
Beispiel #50
0
        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));
        }
Beispiel #51
0
        public Group GetById(string gid, GroupsFields fields = null)
        {
            var parameters = new VkParameters { { "group_id", gid }, { "fields", fields } };

            return _vk.Call("groups.getById", parameters)[0];
        }
Beispiel #52
0
 public ReadOnlyCollection <Group> GetById(IEnumerable <string> gids, GroupsFields fields = null)
 {
     return(GetById(gids, null, fields));
 }
Beispiel #53
0
        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);
        }
Beispiel #54
0
        public ReadOnlyCollection <Group> Search([NotNull] string query, out int totalCount, int?offset = null, int?count = null, GroupsFields fields = null, int sort = 0)
        {
            VkErrors.ThrowIfNullOrEmpty(() => query);

            var parameters = new VkParameters {
                { "q", query }, { "offset", offset }, { "count", count }, { "fields", fields }, { "sort", sort }
            };

            VkResponseArray response = _vk.Call("groups.search", parameters);

            totalCount = response[0];

            return(response.Skip(1).ToReadOnlyCollectionOf <Group>(r => r));
        }