/// <summary>
        /// Look up a coupon for an account
        /// </summary>
        /// <param name="accountCode">Account code</param>
        /// <returns></returns>
        public static RecurlyAccountCoupon Get(string appName, string accountCode)
        {
            RecurlyAccountCoupon coupon = new RecurlyAccountCoupon();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(appName, RecurlyClient.HttpRequestMethod.Get,
                CouponUrl(accountCode),
                new RecurlyClient.ReadXmlDelegate(coupon.ReadXml));

            if (statusCode == HttpStatusCode.NotFound)
                return null;

            return coupon;
        }
        /// <summary>
        /// Redeem a coupon on an account.
        /// </summary>
        /// <param name="accountCode"></param>
        /// <param name="couponCode"></param>
        /// <returns></returns>
        public static RecurlyAccountCoupon Redeem(string accountCode, string couponCode)
        {
            RecurlyAccountCoupon coupon = new RecurlyAccountCoupon();

            coupon.AccountCode = accountCode;
            coupon.CouponCode  = couponCode;

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post,
                                                                     CouponUrl(coupon.AccountCode),
                                                                     new RecurlyClient.WriteXmlDelegate(coupon.WriteXml),
                                                                     new RecurlyClient.ReadXmlDelegate(coupon.ReadXml));

            return(coupon);
        }
        /// <summary>
        /// Look up a coupon for an account
        /// </summary>
        /// <param name="accountCode">Account code</param>
        /// <returns></returns>
        public static RecurlyAccountCoupon Get(string accountCode)
        {
            RecurlyAccountCoupon coupon = new RecurlyAccountCoupon();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                                     CouponUrl(accountCode),
                                                                     new RecurlyClient.ReadXmlDelegate(coupon.ReadXml));

            if (statusCode == HttpStatusCode.NotFound)
            {
                return(null);
            }

            return(coupon);
        }
        /// <summary>
        /// Redeem a coupon on an account.
        /// </summary>
        /// <param name="accountCode"></param>
        /// <param name="couponCode"></param>
        /// <returns></returns>
        public static RecurlyAccountCoupon Redeem(string appName, string accountCode, string couponCode)
        {
            RecurlyAccountCoupon coupon = new RecurlyAccountCoupon();
            coupon.AccountCode = accountCode;
            coupon.CouponCode = couponCode;

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(appName, RecurlyClient.HttpRequestMethod.Post,
                CouponUrl(coupon.AccountCode),
                new RecurlyClient.WriteXmlDelegate(coupon.WriteXml),
                new RecurlyClient.ReadXmlDelegate(coupon.ReadXml));

            return coupon;
        }
 public bool Equals(RecurlyAccountCoupon coupon)
 {
     return this.AccountCode == coupon.AccountCode && this.CouponCode == coupon.CouponCode;
 }
 public bool Equals(RecurlyAccountCoupon coupon)
 {
     return(this.AccountCode == coupon.AccountCode && this.CouponCode == coupon.CouponCode);
 }
 /// <summary>
 /// Redeem a coupon on the account.
 /// </summary>
 /// <param name="couponCode"></param>
 /// <returns></returns>
 public RecurlyAccountCoupon RedeemCoupon(string couponCode)
 {
     return(RecurlyAccountCoupon.Redeem(this.AccountCode, couponCode));
 }
 /// <summary>
 /// Lookup the active coupon for this account.
 /// </summary>
 /// <returns></returns>
 public RecurlyAccountCoupon GetActiveCoupon()
 {
     return(RecurlyAccountCoupon.Get(this.AccountCode));
 }