Esempio n. 1
0
        /// <summary>
        /// Retrieve a single CallingNumber from FreeClimb.
        /// </summary>
        /// <param name="id">The callingNumberId of the target resource.</param>
        /// <returns>The CallingNumber matching the id provided.</returns>
        /// <exception cref="FreeClimbException">Thrown upon failed request.</exception>
        public CallingNumber 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 CallingNumber {0} information", id ?? ""));
            }

            return(CallingNumber.fromJson(json));
        }
Esempio n. 2
0
        /// <summary>
        /// Update a single callingNumber.
        /// </summary>
        /// <param name="callingNumberId">The callingNumberId of the target callingNumber.</param>
        /// <param name="options">Optional CallingNumberOptions instance to be used when updating an callingNumber.</param>
        /// <returns>The updated callingNumber matching the callingNumberId provided.</returns>
        /// <exception cref="FreeClimbException">Thrown upon failed request.</exception>
        public CallingNumber update(string callingNumberId, CallingNumberOptions options)
        {
            string json = base.POST(String.Format("{0}/{1}", this.path, callingNumberId), options.toJson());

            if (string.IsNullOrEmpty(json) == true)
            {
                throw new FreeClimbException(String.Format("Failed to update CallingNumber {0} information", callingNumberId));
            }

            return(CallingNumber.fromJson(json));
        }
Esempio n. 3
0
        /// <summary>
        /// Create a new CallingNumber through the FreeClimb API
        /// </summary>
        /// <param name="options">Optional CallingNumberOptions instance to be used when creating an CallingNumber.</param>
        /// <param name="phoneNumber">The phoneNumber of the CallingNumber to create.</param>
        /// <returns>A CallingNumber object returned by FreeClimb that represents the CallingNumber that was created.</returns>
        /// <exception cref="FreeClimbException">Thrown upon failed request.</exception>
        /// <see cref="CallingNumberOptions">CallingNumberOptions class.</see>
        public CallingNumber create(string phoneNumber, CallingNumberOptions options = null)
        {
            NewCallingNumber newPhone = new NewCallingNumber(phoneNumber, options);
            string           json     = base.POST(this.path, newPhone.toJson());

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

            return(CallingNumber.fromJson(json));
        }