public async Task RealEstateProject_Update_RequestsCorrectResource() { RestClient.RespondWith(r => { Assert.Equal(Method.PUT, r.Method); Assert.Equal("https://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/realestateproject/4711", RestClient.BuildUri(r).ToString()); return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_UPDATED, MessageProperty = "" } } }; }); var project = new RealEstateProject { Id = 4711 }; await Client.RealEstateProjects.UpdateAsync(project); }
public async Task RealEstateProject_Update_PostsRealEstateObject() { RestClient.RespondWith(r => { var c = r.Body() as RealEstateProject; Assert.IsType<RealEstateProject>(c); Assert.Equal(4711, c.Id); return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_UPDATED, MessageProperty = "" } } }; }); var project = new RealEstateProject { Id = 4711 }; await Client.RealEstateProjects.UpdateAsync(project); }
/// <summary> /// Updates a real estate project. /// </summary> /// <param name="realEstateProject">The <see cref="IS24RestApi.Offer.RealEstateProject.RealEstateProject" /> object.</param> /// <returns> /// The task object representing the asynchronous operation. /// </returns> /// <exception cref="IS24Exception"></exception> public async Task UpdateAsync(RealEstateProject realEstateProject) { var req = Connection.CreateRequest("realestateproject/{id}", Method.PUT); req.AddParameter("id", realEstateProject.Id.Value, ParameterType.UrlSegment); req.AddBody(realEstateProject); var resp = await ExecuteAsync <Messages>(Connection, req); if (!resp.IsSuccessful()) { throw new IS24Exception(string.Format("Error updating real estate project {0}: {1}", realEstateProject.Id, resp.ToMessage())) { Messages = resp }; } }