Esempio n. 1
0
 /// <summary>
 /// Searches vkontakte audio storage.
 /// </summary>
 /// <param name="query">Search query.</param>
 /// <param name="count">Results count to return.</param>
 /// <returns>List of audio objects matching the search query.</returns>
 public List<Audio> Search(string query, int count)
 {
     var request = new Request("audio.search");
     request.Parameters.Add("q", query);
     request.Parameters.Add("count", count.ToString());
     return Api.Call<AudioListResponse>(request).Audios;
 }
Esempio n. 2
0
 /// <summary>
 /// Gets messages filtered by different criteria.
 /// </summary>
 /// <param name="direction">Incoming\outgoing messages.</param>
 /// <param name="offset">Used for paged results.</param>
 /// <param name="count">Count of messages to return.</param>
 /// <param name="filter">MessageFilter to filter messages.</param>
 /// <param name="maxMsgLength">Max message length to load. Pass 0 to load complete messages.</param>
 /// <param name="timeOffset">If specified, returns messages not older than timeOffset seconds.</param>
 /// <returns>List of messages.</returns>
 public List<Message> GetList(MessageDirection direction, int? offset, int? count, MessageFilter filter, int? maxMsgLength, int? timeOffset)
 {
     var request = new Request("messages.get");
     request.Parameters.Add("out", ((int)direction).ToString());
     if (offset.HasValue)
         request.Parameters.Add("offset", offset.ToString());
     if (count.HasValue)
         request.Parameters.Add("count", count.ToString());
     if (filter != MessageFilter.None)
         request.Parameters.Add("filters", ((int)filter).ToString());
     if (maxMsgLength.HasValue)
         request.Parameters.Add("preview_length", maxMsgLength.ToString());
     if (timeOffset.HasValue)
         request.Parameters.Add("time_offset", timeOffset.ToString());
     return Api.Call<MessageListResponse>(request).Messages;
 }
Esempio n. 3
0
 /// <summary>
 /// Gets online friend ids for the specified user.
 /// </summary>
 /// <param name="userId">User id to get online friends for.</param>
 /// <returns>List of user ids.</returns>
 public List<int> GetOnlineFriendIds(uint userId)
 {
     var request = new Request("friends.getOnline");
     request.Parameters.Add("uid", userId.ToString());
     return Api.Call<List<int>>(request);
 }
Esempio n. 4
0
 /// <summary>
 /// Gets friends for the specified user.
 /// </summary>
 /// <param name="userId">User id to get friends for.</param>
 /// <param name="fields">Bitmask of fields to get.</param>
 /// <returns>List of users.</returns>
 public List<User> GetFriends(uint userId, UserFields fields)
 {
     var request = new Request("friends.get");
     request.Parameters.Add("uid", userId.ToString());
     request.Parameters.Add("fields", GetFields(fields));
     return Api.Call<UserListResponse>(request).Users;
 }
Esempio n. 5
0
 /// <summary>
 /// Gets groups information the user is associated with.
 /// </summary>
 /// <returns>List of Group objects.</returns>
 public List<Group> GetGroups()
 {
     var request = new Request("getGroupsFull");
     return Api.Call<GroupListResponse>(request).Groups;
 }
Esempio n. 6
0
 /// <summary>
 /// Gets group ids the user is associated with.
 /// </summary>
 /// <returns>List of group ids.</returns>
 public List<int> GetGroupIds()
 {
     var request = new Request("getGroups");
     return Api.Call<List<int>>(request);
 }
Esempio n. 7
0
 /// <summary>
 /// Gets the permissions set for the current application.
 /// </summary>
 /// <returns>Bitmask of permissions.</returns>
 public string GetSettings()
 {
     var request = new Request("getUserSettings");
     var response = Api.Call<XDocument>(request);
     if (response == null || response.Root == null) throw new ApplicationException("Request failed.");
     var settingsElement = response.Root.Element(XName.Get("settings"));
     if (settingsElement == null) throw new ApplicationException("Cannot parse response.");
     return settingsElement.Value;
 }
Esempio n. 8
0
 /// <summary>
 /// Gets user balance in the application.
 /// </summary>
 /// <returns>User balance.</returns>
 public float GetBalance()
 {
     var request = new Request("getUserBalance");
     var response = Api.Call<XDocument>(request);
     if (response == null || response.Root == null) throw new ApplicationException("Request failed.");
     var balanceElement = response.Root.Element(XName.Get("balance"));
     if (balanceElement == null) throw new ApplicationException("Cannot parse response.");
     return int.Parse(balanceElement.Value) / 100.0F;
 }
Esempio n. 9
0
 /// <summary>
 /// Checks if user is application user.
 /// </summary>
 /// <param name="userId">Identificator of user.</param>
 /// <returns>True if the user the application user, otherwise false.</returns>
 public bool IsAppUser(uint userId)
 {
     var request = new Request("isAppUser");
     request.Parameters.Add("uid", userId.ToString());
     var response = Api.Call<XDocument>(request);
     if (response == null || response.Root == null) throw new ApplicationException("Request failed.");
     return response.Root.Value.Equals("1");
 }
Esempio n. 10
0
 /// <summary>
 /// Gets list of users.
 /// </summary>
 /// <param name="userIds">Identificator of user.</param>
 /// <param name="fields">Bitmask of fields to get.</param>
 /// <returns>User object.</returns>
 public List<User> GetList(uint[] userIds, UserFields fields)
 {
     var request = new Request("getProfiles");
     request.Parameters.Add("uids", string.Join(",", userIds));
     request.Parameters.Add("fields", GetFields(fields));
     return Api.Call<UserListResponse>(request).Users;
 }
Esempio n. 11
0
 /// <summary>
 /// Gets user by id.
 /// </summary>
 /// <param name="userId">Identificator of user.</param>
 /// <param name="fields">Bitmask of fields to get.</param>
 /// <returns>User object.</returns>
 public User GetSingle(uint userId, UserFields fields)
 {
     var request = new Request("getProfiles");
     request.Parameters.Add("uids", userId.ToString());
     request.Parameters.Add("fields", GetFields(fields));
     return Api.Call<User>(request);
 }