예제 #1
0
        /// <summary>
        /// create
        /// </summary>
        /// <param name="options"> Create Worker parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Worker </returns>
        public static WorkerResource Create(CreateWorkerOptions options, ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = client.Request(BuildCreateRequest(options, client));

            return(FromJson(response.Content));
        }
        /// <summary>
        /// create
        /// </summary>
        ///
        /// <param name="options"> Create Worker parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Worker </returns>
        public static async System.Threading.Tasks.Task <WorkerResource> CreateAsync(CreateWorkerOptions options, ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = await client.RequestAsync(BuildCreateRequest(options, client));

            return(FromJson(response.Content));
        }
        /// <summary>
        /// create
        /// </summary>
        ///
        /// <param name="pathWorkspaceSid"> The workspace_sid </param>
        /// <param name="friendlyName"> The friendly_name </param>
        /// <param name="activitySid"> The activity_sid </param>
        /// <param name="attributes"> The attributes </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Worker </returns>
        public static async System.Threading.Tasks.Task <WorkerResource> CreateAsync(string pathWorkspaceSid, string friendlyName, string activitySid = null, string attributes = null, ITwilioRestClient client = null)
        {
            var options = new CreateWorkerOptions(pathWorkspaceSid, friendlyName)
            {
                ActivitySid = activitySid, Attributes = attributes
            };

            return(await CreateAsync(options, client));
        }
        /// <summary>
        /// create
        /// </summary>
        ///
        /// <param name="pathWorkspaceSid"> The workspace_sid </param>
        /// <param name="friendlyName"> The friendly_name </param>
        /// <param name="activitySid"> The activity_sid </param>
        /// <param name="attributes"> The attributes </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Worker </returns>
        public static WorkerResource Create(string pathWorkspaceSid, string friendlyName, string activitySid = null, string attributes = null, ITwilioRestClient client = null)
        {
            var options = new CreateWorkerOptions(pathWorkspaceSid, friendlyName)
            {
                ActivitySid = activitySid, Attributes = attributes
            };

            return(Create(options, client));
        }
 private static Request BuildCreateRequest(CreateWorkerOptions options, ITwilioRestClient client)
 {
     return(new Request(
                HttpMethod.Post,
                Rest.Domain.Taskrouter,
                "/v1/Workspaces/" + options.PathWorkspaceSid + "/Workers",
                postParams: options.GetParams()
                ));
 }