コード例 #1
0
 public OutboundCall(CallOrigOptions callOptions) : base()
 {
     if (callOptions != null)
     {
         this.setIfMachine(callOptions.getIfMachine);
         this.setSendDigits(callOptions.getSendDigits);
         this.setTimeout(callOptions.getTimeout);
     }
 }
コード例 #2
0
        /// <summary>
        /// Create a new call through the Persephony API using a registered
        /// Persephony application.
        /// </summary>
        /// <param name="to">The number to call out to (DNIS). This can be any valid phone number formatted in E.164 format.</param>
        /// <param name="from">The number to call from (ANI). This must be a number purchase from Persephony or a verified phone number owned by the user.</param>
        /// <param name="applicationId">The applicationId for the registered Persephony application which should handle this call.</param>
        /// <param name="callOptions">Optional CallOrigOptions instance to be used when creating a call.</param>
        /// <returns>A Call object returned by Persephony that represents the call that was created.</returns>
        /// <exception cref="PersyException">Thrown upon failed request.</exception>
        /// <see cref="CallOrigOptions">CallOrigOptions class.</see>
        public Call create(string to, string from, string applicationId, CallOrigOptions callOptions = null)
        {
            OutboundCall outboundCall = new OutboundCall(callOptions);

            outboundCall.setTo(to);
            outboundCall.setFrom(from);
            outboundCall.setApplicationId(applicationId);

            string json = base.POST(this.path, outboundCall.toJson());

            if (string.IsNullOrEmpty(json) == true)
            {
                throw new PersyException(string.Format("Failed to connect to {0} from {1}", to ?? string.Empty, from ?? string.Empty));
            }

            return(Call.fromJson(json));
        }