/// <summary>
        /// Create an Invoice if there are outstanding charges on an account. If there are no outstanding
        /// charges, null is returned.
        /// </summary>
        /// <param name="accountCode">Account code</param>
        /// <returns></returns>
        public static RecurlyInvoice Create(string accountCode)
        {
            RecurlyInvoice invoice = new RecurlyInvoice();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post,
                "/accounts/" + System.Web.HttpUtility.UrlEncode(accountCode) + UrlPrefix,
                new RecurlyClient.ReadXmlDelegate(invoice.ReadXml));

            if ((int)statusCode == ValidationException.HttpStatusCode)
                return null;

            return invoice;
        }
        /// <summary>
        /// Look up an Invoice.
        /// </summary>
        /// <param name="invoiceId">Invoice ID</param>
        /// <returns></returns>
        public static RecurlyInvoice Get(string invoiceId)
        {
            RecurlyInvoice invoice = new RecurlyInvoice();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                UrlPrefix + System.Web.HttpUtility.UrlEncode(invoiceId),
                new RecurlyClient.ReadXmlDelegate(invoice.ReadXml));

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

            return invoice;
        }
        /// <summary>
        /// Create an Invoice if there are outstanding charges on an account. If there are no outstanding
        /// charges, null is returned.
        /// </summary>
        /// <param name="accountCode">Account code</param>
        /// <returns></returns>
        public static RecurlyInvoice Create(string accountCode)
        {
            RecurlyInvoice invoice = new RecurlyInvoice();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post,
                                                                     "/accounts/" + System.Web.HttpUtility.UrlEncode(accountCode) + UrlPrefix,
                                                                     new RecurlyClient.ReadXmlDelegate(invoice.ReadXml));

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

            return(invoice);
        }
        /// <summary>
        /// Look up an Invoice.
        /// </summary>
        /// <param name="invoiceId">Invoice ID</param>
        /// <returns></returns>
        public static RecurlyInvoice Get(string invoiceId)
        {
            RecurlyInvoice invoice = new RecurlyInvoice();

            HttpStatusCode statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                                     UrlPrefix + System.Web.HttpUtility.UrlEncode(invoiceId),
                                                                     new RecurlyClient.ReadXmlDelegate(invoice.ReadXml));

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

            return(invoice);
        }
 public bool Equals(RecurlyInvoice invoice)
 {
     return(this.Id == invoice.Id);
 }
 public bool Equals(RecurlyInvoice invoice)
 {
     return this.Id == invoice.Id;
 }
        /// <summary>
        /// Create an Invoice if there are outstanding charges on an account. If there are no outstanding
        /// charges, null is returned.
        /// </summary>
        /// <param name="accountCode">Account code</param>
        /// <returns></returns>
        public static RecurlyInvoice InvoicePendingCharges(string accountCode)
        {
            var invoice = new RecurlyInvoice();

            var statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Post,
                String.Format(Settings.Default.PathAccountInvoicePendingCharges,accountCode.UrlEncode()),
                invoice.ReadXml);

            return statusCode == HttpStatusCode.OK ? invoice : null;
        }
        /// <summary>
        /// Look up an Invoice.
        /// </summary>
        /// <param name="invoiceNumber">Invoice Number</param>
        /// <returns></returns>
        public static RecurlyInvoice Get(int invoiceNumber)
        {
            var invoice = new RecurlyInvoice();

            var statusCode = RecurlyClient.PerformRequest(RecurlyClient.HttpRequestMethod.Get,
                                                          String.Format(Settings.Default.PathInvoiceGet, invoiceNumber),
                invoice.ReadXml);

            return statusCode == HttpStatusCode.OK ? invoice : null;
        }