/// <summary>
        /// Triggers a new Engagement for the Flow
        /// </summary>
        /// <param name="options"> Create Engagement parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Engagement </returns>
        public static EngagementResource Create(CreateEngagementOptions options, ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = client.Request(BuildCreateRequest(options, client));

            return(FromJson(response.Content));
        }
 private static Request BuildCreateRequest(CreateEngagementOptions options, ITwilioRestClient client)
 {
     return(new Request(
                HttpMethod.Post,
                Rest.Domain.Preview,
                "/Studio/Flows/" + options.PathFlowSid + "/Engagements",
                client.Region,
                postParams: options.GetParams()
                ));
 }
        /// <summary>
        /// Triggers a new Engagement for the Flow
        /// </summary>
        /// <param name="pathFlowSid"> Flow Sid. </param>
        /// <param name="to"> The to </param>
        /// <param name="from"> The from </param>
        /// <param name="parameters"> The parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Engagement </returns>
        public static async System.Threading.Tasks.Task <EngagementResource> CreateAsync(string pathFlowSid,
                                                                                         Types.PhoneNumber to,
                                                                                         Types.PhoneNumber from,
                                                                                         string parameters        = null,
                                                                                         ITwilioRestClient client = null)
        {
            var options = new CreateEngagementOptions(pathFlowSid, to, from)
            {
                Parameters = parameters
            };

            return(await CreateAsync(options, client));
        }
        /// <summary>
        /// Triggers a new Engagement for the Flow
        /// </summary>
        /// <param name="pathFlowSid"> Flow Sid. </param>
        /// <param name="to"> The to </param>
        /// <param name="from"> The from </param>
        /// <param name="parameters"> The parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Engagement </returns>
        public static EngagementResource Create(string pathFlowSid,
                                                Types.PhoneNumber to,
                                                Types.PhoneNumber from,
                                                string parameters        = null,
                                                ITwilioRestClient client = null)
        {
            var options = new CreateEngagementOptions(pathFlowSid, to, from)
            {
                Parameters = parameters
            };

            return(Create(options, client));
        }
        /// <summary>
        /// Triggers a new Engagement for the Flow
        /// </summary>
        /// <param name="options"> Create Engagement parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Engagement </returns>
        public static async System.Threading.Tasks.Task <EngagementResource> CreateAsync(CreateEngagementOptions options,
                                                                                         ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = await client.RequestAsync(BuildCreateRequest(options, client));

            return(FromJson(response.Content));
        }