/// <summary> /// Returns a list of locations that match the search criteria. /// Those locations added by website moderators and the current user are searched.Locations are sorted by increasing distance from the initial search point. /// </summary> /// <param name="coords">Geographical coordinates and radius.</param> /// <param name="query">Search query string.</param> /// <param name="cityId">City ID.</param> /// <param name="count">Number of locations to return.</param> /// <param name="offset">Offset needed to return a specific subset of locations.</param> /// <returns>Returns a <see cref="List{T}"/> of <see cref="Place"/> objects.</returns> public async Task<Response<ItemsList<Place>>> Search(Coordinates coords, string query = null, int? cityId = null, int count = 30, int offset = 0) => await Request<ItemsList<Place>>("search", new MethodParams { {"q", query}, {"latitude", coords?.Latitude, true}, {"longitude", coords?.Longitude, true}, {"radius", coords?.Radius}, {"city", cityId}, {"count", count, false, new[] {0, 1000}}, {"offset", offset} });
/// <summary> /// Adds a new location to the location database. /// Created locations will be shown in search by locations only for the user who added it. /// </summary> /// <param name="title">Title of the location. </param> /// <param name="coords">Geographical coordinates.</param> /// <param name="typeId">ID of the location's type (e.g., 1 — Home, 2 — Work). To get location type IDs, use the <see cref="GetTypes"/> method.</param> /// <param name="countryId">ID of the location's country. To get country IDs, use the <see cref="DatabaseMethods.GetCountries(bool,string,int?,int)"/> method. </param> /// <param name="cityId">ID of the location's city. To get city IDs, use the <see cref="DatabaseMethods.GetCities"/> method.</param> /// <param name="address">Street address of the location (e.g., 125 Elm Street).</param> /// <returns>Returns the ID of the created location.</returns> public async Task<Response<int>> Add(string title, Coordinates coords, int? typeId = null, int? countryId = null, int? cityId = null, string address = null) => await Request<int>("add", new MethodParams { {"title", title, true}, {"type", typeId}, {"latitude", coords?.Latitude, true}, {"longitude", coords?.Longitude, true}, {"city", cityId}, {"country", countryId}, {"address", address} }, false, "id");
/// <summary> /// Indexes user's current location and returns a list of users who are located near. /// </summary> /// <param name="coords">Geographical coordinates including <see cref="Coordinates.Radius"/> and <see cref="Coordinates.Accuracy"/>.</param> /// <param name="timeout">Time when a user disappears from location search results, in seconds.</param> /// <param name="fields">List of additional fields to return.</param> /// <param name="nameCase">Case for declension of user name and surname.</param> /// <returns>Returns a <see cref="List{T}"/> of <see cref="User"/> objects.</returns> public async Task<Response<ItemsList<User>>> GetNearby(Coordinates coords, int timeout = 7200, List<UserProfileFields> fields = null, NameCases nameCase = NameCases.Nominative) => await Request<ItemsList<User>>("getNearby", new MethodParams { {"latitude", coords?.Latitude, true}, {"longitude", coords?.Longitude, true}, {"radius", coords?.Radius}, {"accuracy", coords?.Accuracy}, {"timeout", timeout}, {"name_case", ToEnumString(nameCase)}, {"fields", fields} });
/// <summary> /// Checks a user in at the specified location. /// </summary> /// <param name="placeId">Location ID. </param> /// <param name="coords">Geographical coordinates.</param> /// <param name="text">Text of the comment on the check-in (255 characters maximum; line breaks not supported). </param> /// <param name="friendsOnly">True - Check-in will be available only for friends. False — Check-in will be available for all users(default).</param> /// <param name="services">List of services or websites (e.g., twitter, facebook) to which the check-in will be exported, if the user has set up the respective option.</param> /// <returns></returns> public async Task<Response<int>> Checkin(int placeId, Coordinates coords = null, string text = null, bool friendsOnly = false, List<Services> services = null) => await Request<int>("checkin", new MethodParams { {"place_id", placeId, true}, {"text", text?.Substring(0, 255)}, {"latitude", coords?.Latitude}, {"longitude", coords?.Longitude}, {"friends_only", friendsOnly}, {"services", services} });