public void UpdateConfig() { var expectedJson = GetJsonPayload("/numbers/numberLeasesApi/request/updateNumberLeaseConfig.json"); var restRequest = MockRestResponse(expectedJson); var config = new NumberConfig { Number = "12345678901", ConfigType = NumberConfig.NumberConfigType.TRACKING, CallTrackingConfig = new CallTrackingConfig { Screen = false, Recorded = true, TransferNumbers = new List<string>{ "12135551122", "12135551189" }, Voicemail = true, IntroSoundId = 1234, VoicemailSoundId = 1234, FailedTransferSoundId = 1234, WhisperSoundId = 1234, WeeklySchedule = new WeeklySchedule { StartTimeOfDay = new LocalTime { Hour = 1, Minute = 1, Second = 1 }, StopTimeOfDay = new LocalTime { Hour = 2, Minute = 2, Second = 2 }, DaysOfWeek = new HashSet<DayOfWeek> { DayOfWeek.Friday }, TimeZone = "America/Los_Angeles" }, GoogleAnalytics = new GoogleAnalytics { Category = "Sales", GoogleAccountId = "UA-12345-26", Domain = "testDomain" } } }; Client.NumberLeasesApi.UpdateConfig(config); Console.WriteLine(config); 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/configs/12345678901")); }
/// <summary> /// Update number lease config /// </summary> /// <param name="config">config 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 UpdateConfig(NumberConfig config) { Validate.NotBlank(config.Number, "config.number cannot be blank"); Client.Put<object>(NUMBER_CONFIGS_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, config.Number), config); }