public void Update() { var restClient = MockRestClient .ThatExpects("{\"title\":\"Updated call flow\",\"steps\":[{\"options\":{\"destination\":\"31611223344\"},\"action\":\"transfer\"}]}") .AndReturns(filename: "VoiceCallFlowUpdate.json") .FromEndpoint("PUT", "call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635", VoiceCallFlowsResource.VoiceCallFlowsBaseUrl) .Get(); var client = Client.Create(restClient.Object); var voiceCallFlow = new VoiceCallFlow { Title = "Updated call flow", Steps = new List <Step> { new Step { Action = "transfer", Options = new Options { Destination = "31611223344" } } } }; var updatedVoiceCallFlow = client.UpdateVoiceCallFlow("de3ed163-d5fc-45f4-b8c4-7eea7458c635", voiceCallFlow); restClient.Verify(); Assert.IsNotNull(updatedVoiceCallFlow.Id); }
public void Create() { var restClient = MockRestClient .ThatExpects("{ \"title\": \"Forward call to 31612345678\", \"record\": true, \"steps\": [ { \"options\": { \"destination\": \"31612345678\" }, \"action\": \"transfer\" } ]}") .AndReturns("{ \"data\": [ { \"id\": \"de3ed163-d5fc-45f4-b8c4-7eea7458c635\", \"title\": \"Forward call to 31612345678\", \"record\": true, \"steps\": [ { \"id\": \"2fa1383e-6f21-4e6f-8c36-0920c3d0730b\", \"action\": \"transfer\", \"options\": { \"destination\": \"31612345678\" } } ], \"createdAt\": \"2017-03-06T14:52:22Z\", \"updatedAt\": \"2017-03-06T14:52:22Z\" } ], \"_links\": { \"self\": \"/call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635\" }}") .FromEndpoint("POST", "call-flows", VoiceCallFlowsResource.VoiceCallFlowsBaseUrl) .Get(); var client = Client.Create(restClient.Object); var newVoiceCallFlow = new VoiceCallFlow { Title = "Forward call to 31612345678", Record = true, Steps = new List <Step> { new Step { Action = "transfer", Options = new Options { Destination = "31612345678" } } } }; var voiceCallFlow = client.CreateVoiceCallFlow(newVoiceCallFlow); restClient.Verify(); Assert.AreEqual("Forward call to 31612345678", voiceCallFlow.Title); }
/// <summary> /// This request updates a call flow resource. The single parameter is the unique ID that was returned upon creation.<br/> /// If successful, this request will return an object with a data property, which is an array that has a single call flow object. If the request failed, an error object will be returned. /// </summary> /// <param name="id">The unique ID which was returned upon creation of a call flow.</param> /// <param name="voiceCallFlow"></param> /// <returns></returns> public VoiceCallFlow UpdateVoiceCallFlow(string id, VoiceCallFlow voiceCallFlow) { ParameterValidator.IsNotNullOrWhiteSpace(voiceCallFlow.Title, "title"); ParameterValidator.IsNotNull(voiceCallFlow.Steps, "steps"); var voiceCallFlows = new VoiceCallFlows(new VoiceCallFlow { Id = id, Title = voiceCallFlow.Title, Steps = voiceCallFlow.Steps, Record = voiceCallFlow.Record }); var result = restClient.Update(voiceCallFlows); return((VoiceCallFlow)result.Object); }
/// <summary> /// Creating a call flow /// </summary> /// <param name="request"></param> /// <returns>If successful, this request will return an object with a data property, which is an array that has a single call flow object. If the request failed, an error object will be returned.</returns> public VoiceCallFlow CreateVoiceCallFlow(VoiceCallFlow request) { ParameterValidator.IsNotNullOrWhiteSpace(request.Title, "title"); ParameterValidator.IsNotNull(request.Steps, "steps"); var voiceCallFlows = new VoiceCallFlows(new VoiceCallFlow { Title = request.Title, Steps = request.Steps, Record = request.Record }); var result = restClient.Create(voiceCallFlows); return((VoiceCallFlow)result.Object); }