private static async Task AuthorizeAsync(Config config) { // see http://api.immobilienscout24.de/useful/authentication/authentication-detailed.html var connection = new IS24Connection { ConsumerKey = config.ConsumerKey, ConsumerSecret = config.ConsumerSecret, BaseUrlPrefix = @"https://rest.sandbox-immobilienscout24.de/restapi/security" }; // step 1 await connection.GetRequestToken(callbackUrl: "oob"); // step 2 try { var url = string.Format("{0}/oauth/confirm_access?oauth_token={1}", connection.BaseUrlPrefix, HttpUtility.UrlEncode(connection.RequestToken)); Process.Start(url); } catch { } Console.Out.Write("Enter verifier: "); var verifier = Console.In.ReadLine().Trim(); // step 3 await connection.GetAccessToken(verifier); Console.Out.WriteLine("Access Token: {0}", connection.AccessToken); Console.Out.WriteLine("Access Token Secret: {0}", connection.AccessTokenSecret); }
private static async Task AuthorizeAsync(Config config) { // see http://api.immobilienscout24.de/useful/authentication/authentication-detailed.html var connection = new IS24Connection { ConsumerKey = config.ConsumerKey, ConsumerSecret = config.ConsumerSecret, BaseUrlPrefix = @"https://rest.sandbox-immobilienscout24.de/restapi/security" }; // step 1 await connection.GetRequestToken(callbackUrl : "oob"); // step 2 try { var url = string.Format("{0}/oauth/confirm_access?oauth_token={1}", connection.BaseUrlPrefix, HttpUtility.UrlEncode(connection.RequestToken)); Console.Out.WriteLine($"Please open {url} to obtain verifier."); } catch { } Console.Out.Write("Enter verifier: "); var verifier = Console.In.ReadLine().Trim(); // step 3 await connection.GetAccessToken(verifier); Console.Out.WriteLine("Access Token: {0}", connection.AccessToken); Console.Out.WriteLine("Access Token Secret: {0}", connection.AccessTokenSecret); }
public AuthTests() { Http = new HttpStub(); Connection = new IS24Connection { HttpFactory = new HttpFactory(Http), BaseUrlPrefix = @"http://rest.sandbox-immobilienscout24.de/restapi/api", ConsumerKey = "ConsumerKey", ConsumerSecret = "ConsumerSecret" }; }
public AuthTests() { RestClient = new RestClientStub(); Connection = new IS24Connection { RestClientFactory = baseUrl => { RestClient.BaseUrl = new Uri(baseUrl); return(RestClient); }, BaseUrlPrefix = @"https://rest.sandbox-immobilienscout24.de/restapi/api", ConsumerKey = "ConsumerKey", ConsumerSecret = "ConsumerSecret" }; }
public TestBase(string baseUrlPrefix) { Http = new HttpStub(); var connection = new IS24Connection { HttpFactory = new HttpFactory(Http), BaseUrlPrefix = baseUrlPrefix, AccessToken = "AccessToken", AccessTokenSecret = "AccessTokenSecret", ConsumerKey = "ConsumerKey", ConsumerSecret = "ConsumerSecret" }; Client = new ImportExportClient(connection); }
public TestBase(string baseUrlPrefix, Func <IIS24Connection, T> createClient) { RestClient = new RestClientStub(); var connection = new IS24Connection { RestClientFactory = baseUrl => { RestClient.BaseUrl = new Uri(baseUrl); return(RestClient); }, BaseUrlPrefix = baseUrlPrefix, AccessToken = "AccessToken", AccessTokenSecret = "AccessTokenSecret", ConsumerKey = "ConsumerKey", ConsumerSecret = "ConsumerSecret" }; Client = createClient(connection); }
private static async Task TestAsync(Config config) { var connection = new IS24Connection { ConsumerKey = config.ConsumerKey, ConsumerSecret = config.ConsumerSecret, AccessToken = config.AccessToken, AccessTokenSecret = config.AccessSecret, BaseUrlPrefix = @"https://rest.sandbox-immobilienscout24.de/restapi/api" }; var searchResource = new SearchResource(connection); var query = new RadiusQuery { Latitude = 52.49023, Longitude = 13.35939, Radius = 1, RealEstateType = RealEstateType.APARTMENT_RENT, Parameters = new { Price = new DecimalRange { Max = 1000 }, LivingSpace = new DecimalRange { Min = 100 }, NumberOfRooms = new DecimalRange { Min = 4 }, Equipment = "balcony" }, Channel = new HomepageChannel("me") }; var results = await searchResource.Search(query); var api = new ImportExportClient(connection); RealtorContactDetails contact = null; try { contact = await api.Contacts.GetAsync("Hans Meiser", isExternal: true); } catch (IS24Exception ex) { if (ex.Messages.Message.First().MessageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) throw; } if (contact == null) { contact = new RealtorContactDetails { Lastname = "Meiser", Firstname = "Hans", Address = new Address { Street = "Hauptstraße", HouseNumber = "1", Postcode = "10827", City = "Berlin", InternationalCountryRegion = new CountryRegion { Country = CountryCode.DEU, Region = "Berlin" } }, Email = "*****@*****.**", ExternalId = "Hans Meiser" }; await api.Contacts.CreateAsync(contact); contact.Address.HouseNumber = "1a"; await api.Contacts.UpdateAsync(contact); } IRealEstate realEstate = null; try { realEstate = await api.RealEstates.GetAsync("Hauptstraße 1", isExternal: true); } catch (IS24Exception ex) { if (ex.Messages.Message.First().MessageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) throw; } if (realEstate == null) { var re = new ApartmentRent { Contact = new RealEstateContact { Id = contact.Id }, ExternalId = "Hauptstraße 1", Title = "IS24RestApi Test", Address = new Wgs84Address { Street = "Hauptstraße", HouseNumber = "1", City = "Berlin", Postcode = "10827" }, BaseRent = 500.0, LivingSpace = 100.0, NumberOfRooms = 4.0, ShowAddress = true, Courtage = new CourtageInfo { HasCourtage = YesNoNotApplicableType.NO } }; await api.RealEstates.CreateAsync(re); re.BaseRent += 100.0; await api.RealEstates.UpdateAsync(re); realEstate = new RealEstateItem(re, connection); } else { var re = (ApartmentRent)realEstate.RealEstate; re.BaseRent += 100.0; await api.RealEstates.UpdateAsync(re); re.BaseRent -= 100.0; await api.RealEstates.UpdateAsync(re); } var projects = await api.RealEstateProjects.GetAllAsync(); if (projects.RealEstateProject.Any()) { var project = projects.RealEstateProject.First(); var entries = await api.RealEstateProjects.GetAllAsync(project.Id.Value); if (!entries.RealEstateProjectEntry.Any(e => e.RealEstateId.Value == realEstate.RealEstate.Id.Value)) await api.RealEstateProjects.AddAsync(project.Id.Value, realEstate.RealEstate); } var placement = await realEstate.PremiumPlacements.GetAsync(); var atts = await realEstate.Attachments.GetAsync(); if (atts == null || !atts.Any()) { var att = new Picture { Floorplan = false, TitlePicture = true, Title = "Zimmer", }; await realEstate.Attachments.CreateAsync(att, @"..\..\test.jpg"); att.Title = "Zimmer 1"; await realEstate.Attachments.UpdateAsync(att); var link = new Link { Title = "Test", Url = "http://www.example.com/" }; await realEstate.Attachments.CreateAsync(link); var video = new StreamingVideo { Title = "Video" }; await realEstate.Attachments.CreateStreamingVideoAsync(video, @"..\..\test.avi"); } var res = new List<RealEstate>(); await api.RealEstates.GetAsync().ForEachAsync(x => res.Add(x.RealEstate)); }
private static async Task TestAsync(Config config) { var connection = new IS24Connection { ConsumerKey = config.ConsumerKey, ConsumerSecret = config.ConsumerSecret, AccessToken = config.AccessToken, AccessTokenSecret = config.AccessSecret, BaseUrlPrefix = @"https://rest.sandbox-immobilienscout24.de/restapi/api" }; var searchResource = new SearchResource(connection); var query = new RadiusQuery { Latitude = 52.49023, Longitude = 13.35939, Radius = 1, RealEstateType = RealEstateType.APARTMENT_RENT, Parameters = new { Price = new DecimalRange { Max = 1000 }, LivingSpace = new DecimalRange { Min = 100 }, NumberOfRooms = new DecimalRange { Min = 4 }, Equipment = "balcony" }, Channel = new HomepageChannel("me") }; var results = await searchResource.Search(query); var api = new ImportExportClient(connection); RealtorContactDetails contact = null; try { contact = await api.Contacts.GetAsync("Hans Meiser", isExternal : true); } catch (IS24Exception ex) { if (ex.Messages.Message.First().MessageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) { throw; } } if (contact == null) { contact = new RealtorContactDetails { Lastname = "Meiser", Firstname = "Hans", Address = new Address { Street = "Hauptstraße", HouseNumber = "1", Postcode = "10827", City = "Berlin", InternationalCountryRegion = new CountryRegion { Country = CountryCode.DEU, Region = "Berlin" } }, Email = "*****@*****.**", ExternalId = "Hans Meiser" }; await api.Contacts.CreateAsync(contact); contact.Address.HouseNumber = "1a"; await api.Contacts.UpdateAsync(contact); } IRealEstate realEstate = null; try { realEstate = await api.RealEstates.GetAsync("Hauptstraße 1", isExternal : true); } catch (IS24Exception ex) { if (ex.Messages.Message.First().MessageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) { throw; } } if (realEstate == null) { var re = new ApartmentRent { Contact = new RealEstateContact { Id = contact.Id }, ExternalId = "Hauptstraße 1", Title = "IS24RestApi Test", Address = new Wgs84Address { Street = "Hauptstraße", HouseNumber = "1", City = "Berlin", Postcode = "10827" }, BaseRent = 500.0, LivingSpace = 100.0, NumberOfRooms = 4.0, ShowAddress = true, Courtage = new CourtageInfo { HasCourtage = YesNoNotApplicableType.NO } }; await api.RealEstates.CreateAsync(re); re.BaseRent += 100.0; await api.RealEstates.UpdateAsync(re); realEstate = new RealEstateItem(re, connection); } else { var re = (ApartmentRent)realEstate.RealEstate; re.BaseRent += 100.0; await api.RealEstates.UpdateAsync(re); re.BaseRent -= 100.0; await api.RealEstates.UpdateAsync(re); } var projects = await api.RealEstateProjects.GetAllAsync(); if (projects.RealEstateProject.Any()) { var project = projects.RealEstateProject.First(); var entries = await api.RealEstateProjects.GetAllAsync(project.Id.Value); if (!entries.RealEstateProjectEntry.Any(e => e.RealEstateId.Value == realEstate.RealEstate.Id.Value)) { await api.RealEstateProjects.AddAsync(project.Id.Value, realEstate.RealEstate); } } var placement = await realEstate.PremiumPlacements.GetAsync(); var a1 = new KeyValuePair <Attachment, string>(new Picture { Title = "Zimmer 1", Floorplan = false, TitlePicture = true }, @"..\..\..\test.jpg"); var a2 = new KeyValuePair <Attachment, string>(new Picture { Title = "Zimmer 2" }, @"..\..\..\test.jpg"); var a3 = new KeyValuePair <Attachment, string>(new Picture { Title = "Zimmer 3" }, @"..\..\..\test.jpg"); var pdf = new KeyValuePair <Attachment, string>(new PDFDocument { Title = "Test" }, @"..\..\..\test.pdf"); var video = new KeyValuePair <Attachment, string>(new StreamingVideo { Title = "Video" }, @"..\..\..\test.avi"); var link = new KeyValuePair <Attachment, string>(new Link { Title = "Test", Url = "http://www.example.com/" }, null); var atts = new[] { video, a1, pdf, a2, link, a3 }; await realEstate.Attachments.UpdateAsync(atts); var res = new List <RealEstate>(); await api.RealEstates.GetAsync().ForEachAsync(x => res.Add(x.RealEstate)); }
private static async Task TestAsync() { var config = RestSharp.SimpleJson.DeserializeObject <Config>(File.ReadAllText("config.json")); var connection = new IS24Connection { ConsumerKey = config.ConsumerKey, ConsumerSecret = config.ConsumerSecret, AccessToken = config.AccessToken, AccessTokenSecret = config.AccessSecret, BaseUrlPrefix = @"http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0" }; var api = new ImportExportClient(connection); RealtorContactDetails contact = null; try { contact = await api.Contacts.GetAsync("Hans Meiser", isExternal : true); } catch (IS24Exception ex) { if (ex.Messages.message.First().messageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) { throw; } } if (contact == null) { contact = new RealtorContactDetails { lastname = "Meiser", firstname = "Hans", email = "*****@*****.**", address = new Address { street = "Hauptstraße", houseNumber = "1", postcode = "10827", city = "Berlin", internationalCountryRegion = new CountryRegion { country = CountryCode.DEU, region = "Berlin" } }, externalId = "Hans Meiser" }; await api.Contacts.CreateAsync(contact); contact.address.houseNumber = "1a"; await api.Contacts.UpdateAsync(contact); } IRealEstate realEstate = null; try { realEstate = await api.RealEstates.GetAsync("Hauptstraße 1", isExternal : true); } catch (IS24Exception ex) { if (ex.Messages.message.First().messageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) { throw; } } if (realEstate == null) { var re = new ApartmentRent { contact = new RealEstateContact { id = contact.id, idSpecified = true }, externalId = "Hauptstraße 1", title = "IS24RestApi Test", address = new Wgs84Address { street = "Hauptstraße", houseNumber = "1", city = "Berlin", postcode = "10827" }, baseRent = 500.0, livingSpace = 100.0, numberOfRooms = 4.0, showAddress = true, courtage = new CourtageInfo { hasCourtage = YesNoNotApplicableType.NO } }; await api.RealEstates.CreateAsync(re); re.baseRent += 100.0; await api.RealEstates.UpdateAsync(re); realEstate = new RealEstateItem(re, connection); } var atts = await realEstate.Attachments.GetAsync(); if (atts == null || !atts.Any()) { var att = new Picture { floorplan = false, titlePicture = true, title = "Zimmer", }; await realEstate.Attachments.CreateAsync(att, @"..\..\test.jpg"); att.title = "Zimmer 1"; await realEstate.Attachments.UpdateAsync(att); } await api.Publish.PublishAsync(realEstate.RealEstate); await api.Publish.UnpublishAsync(realEstate.RealEstate); var res = new List <RealEstate>(); await api.RealEstates.GetAsync().ForEachAsync(x => res.Add(x.RealEstate)); }
private static async Task TestAsync() { var config = RestSharp.SimpleJson.DeserializeObject<Config>(File.ReadAllText("config.json")); var connection = new IS24Connection { ConsumerKey = config.ConsumerKey, ConsumerSecret = config.ConsumerSecret, AccessToken = config.AccessToken, AccessTokenSecret = config.AccessSecret, BaseUrlPrefix = @"http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0" }; var api = new ImportExportClient(connection); RealtorContactDetails contact = null; try { contact = await api.Contacts.GetAsync("Hans Meiser", isExternal: true); } catch (IS24Exception ex) { if (ex.Messages.message.First().messageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) throw; } if (contact == null) { contact = new RealtorContactDetails { lastname = "Meiser", firstname = "Hans", email = "*****@*****.**", address = new Address { street = "Hauptstraße", houseNumber = "1", postcode = "10827", city = "Berlin", internationalCountryRegion = new CountryRegion { country = CountryCode.DEU, region = "Berlin" } }, externalId = "Hans Meiser" }; await api.Contacts.CreateAsync(contact); contact.address.houseNumber = "1a"; await api.Contacts.UpdateAsync(contact); } IRealEstate realEstate = null; try { realEstate = await api.RealEstates.GetAsync("Hauptstraße 1", isExternal: true); } catch (IS24Exception ex) { if (ex.Messages.message.First().messageCode != MessageCode.ERROR_RESOURCE_NOT_FOUND) throw; } if (realEstate == null) { var re = new ApartmentRent { contact = new RealEstateContact { id = contact.id, idSpecified = true }, externalId = "Hauptstraße 1", title = "IS24RestApi Test", address = new Wgs84Address { street = "Hauptstraße", houseNumber = "1", city = "Berlin", postcode = "10827" }, baseRent = 500.0, livingSpace = 100.0, numberOfRooms = 4.0, showAddress = true, courtage = new CourtageInfo { hasCourtage = YesNoNotApplicableType.NO } }; await api.RealEstates.CreateAsync(re); re.baseRent += 100.0; await api.RealEstates.UpdateAsync(re); realEstate = new RealEstateItem(re, connection); } var atts = await realEstate.Attachments.GetAsync(); if (atts == null || !atts.Any()) { var att = new Picture { floorplan = false, titlePicture = true, title = "Zimmer", }; await realEstate.Attachments.CreateAsync(att, @"..\..\test.jpg"); att.title = "Zimmer 1"; await realEstate.Attachments.UpdateAsync(att); } await api.Publish.PublishAsync(realEstate.RealEstate); await api.Publish.UnpublishAsync(realEstate.RealEstate); var res = new List<RealEstate>(); await api.RealEstates.GetAsync().ForEachAsync(x => res.Add(x.RealEstate)); }