XeroAPI.Net icon indicating copy to clipboard operation
XeroAPI.Net copied to clipboard

Enumerations for options that are Strings

Open amhed opened this issue 11 years ago • 0 comments

Instead of declaring string properties that are string constants like this:

var invoice = new Invoice
{
    Type = "ACCREC",
    Status = "DRAFT",
    Contact = contact
    ...
}

Why not something like this:

var invoice = new Invoice
{
    Type = InvoiceType.AccountsReceivable,
    Status = InvoiceStatus.Draft,
    Contact = contact
    ...
}

Implementation could be something like this:

namespace XeroApi.Model.Constants
{
        public class InvoiceType
    {
        public static string AccountsReceivable {
            get {return "ACCREC"};
        }

        public static string AccountsPayable {
            get {return "ACCPAY"};
        }
    }
}

Let me know if you guys think its a good idea and I'll submit a pull request :)

amhed avatar Jul 18 '13 12:07 amhed