public void Update() { var expectedJson = GetJsonPayload("/numbers/numberLeasesApi/request/updateNumberLease.json"); var restRequest = MockRestResponse(expectedJson); var lease = new NumberLease { PhoneNumber = "12345678901", AutoRenew = false }; Client.NumberLeasesApi.Update(lease); Assert.AreEqual(Method.PUT, restRequest.Value.Method); var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); Assert.That(requestBodyParam.Value, Is.EqualTo(expectedJson)); Assert.That(restRequest.Value.Resource, Is.StringEnding("/numbers/leases/12345678901")); }
/// <summary> /// Update number lease /// </summary> /// <param name="lease">lease to update</param> /// <exception cref="BadRequestException"> in case HTTP response code is 400 - Bad request, the request was formatted improperly.</exception> /// <exception cref="UnauthorizedException"> in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.</exception> /// <exception cref="AccessForbiddenException"> in case HTTP response code is 403 - Forbidden, insufficient permissions.</exception> /// <exception cref="ResourceNotFoundException"> in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.</exception> /// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception> /// <exception cref="CallfireApiException"> in case HTTP response code is something different from codes listed above.</exception> /// <exception cref="CallfireClientException"> in case error has occurred in client.</exception> public void Update(NumberLease lease) { Validate.NotBlank(lease.PhoneNumber, "lease.number cannot be blank"); Client.Put<object>(NUMBER_LEASES_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, lease.PhoneNumber), lease); }