public NewIncomingPhoneNumber(string phoneNumber, IncomingPhoneNumberOptions options) : base()
 {
     if (options != null)
     {
         this.setAlias(options.getAlias);
         this.setApplicationId(options.getApplicationId);
     }
     this.phoneNumber = phoneNumber;
 }
Example #2
0
        /// <summary>
        /// Update a single incomingPhoneNumber.
        /// </summary>
        /// <param name="phoneNumberId">The phoneNumberId of the target incomingPhoneNumber.</param>
        /// <param name="options">Optional IncomingPhoneNumberOptions instance to be used when updating an IncomingPhoneNumber.</param>
        /// <returns>The updated IncomingPhoneNumber matching the phoneNumberId provided.</returns>
        /// <exception cref="PersyException">Thrown upon failed request.</exception>
        public IncomingPhoneNumber update(string phoneNumberId, IncomingPhoneNumberOptions options)
        {
            string json = base.POST(String.Format("{0}/{1}", this.path, phoneNumberId), options.toJson());

            if (string.IsNullOrEmpty(json) == true)
            {
                throw new PersyException(String.Format("Failed to update incomingphonenumber {0} information", phoneNumberId));
            }

            return(IncomingPhoneNumber.fromJson(json));
        }
Example #3
0
        /// <summary>
        /// Create a new incomingPhoneNumber through the Persephony API
        /// </summary>
        /// <param name="phoneNumber">the phone number of the incomingPhoneNumber to be created.</param>
        /// <param name="options">Optional IncomingPhoneNumberOptions instance to be used when creating an incomingPhoneNumber.</param>
        /// <returns>An IncomingPhoneNumber object returned by Persephony that represents the incomingPhoneNumber that was created.</returns>
        /// <exception cref="PersyException">Thrown upon failed request.</exception>
        /// <see cref="IncomingPhoneNumberOptions">IncomingPhoneNumberOptions class.</see>
        public IncomingPhoneNumber create(string phoneNumber, IncomingPhoneNumberOptions options = null)
        {
            NewIncomingPhoneNumber newPhone = new NewIncomingPhoneNumber(phoneNumber, options);
            string json = base.POST(this.path, newPhone.toJson());

            if (string.IsNullOrEmpty(json) == true)
            {
                throw new PersyException(String.Format("Failed to create IncomingPhoneNumber with options {0}. PhoneNumber: {1}", ((options != null) ? options.toJson() : string.Empty), phoneNumber));
            }

            return(IncomingPhoneNumber.fromJson(json));
        }