Example #1
0
        /// <summary>
        /// Retrieve a single IncomingPhoneNumber from FreeClimb.
        /// </summary>
        /// <param name="id">The phoneNumberId of the target resource.</param>
        /// <returns>The IncomingPhoneNumber matching the id provided.</returns>
        /// <exception cref="FreeClimbException">Thrown upon failed request.</exception>
        public IncomingPhoneNumber get(string id)
        {
            string json = base.GET(String.Format("{0}/{1}", this.path, id));

            if (string.IsNullOrEmpty(json) == true)
            {
                throw new FreeClimbException(String.Format("Failed to get incomingPhoneNumber {0} information", id ?? ""));
            }

            return(IncomingPhoneNumber.fromJson(json));
        }
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="FreeClimbException">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 FreeClimbException(String.Format("Failed to update incomingphonenumber {0} information", phoneNumberId));
            }

            return(IncomingPhoneNumber.fromJson(json));
        }
Example #3
0
        /// <summary>
        /// Create a new incomingPhoneNumber through the FreeClimb 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 FreeClimb that represents the incomingPhoneNumber that was created.</returns>
        /// <exception cref="FreeClimbException">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 FreeClimbException(String.Format("Failed to create IncomingPhoneNumber with options {0}. PhoneNumber: {1}", ((options != null) ? options.toJson() : string.Empty), phoneNumber));
            }

            return(IncomingPhoneNumber.fromJson(json));
        }