diff --git a/Entities/Answer.cs b/Entities/Answer.cs new file mode 100644 index 0000000..2255cfe --- /dev/null +++ b/Entities/Answer.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace EventbriteNET.Entities +{ + public class Answer : EntityBase + { + public string id, question, answer; + public Answer(EventbriteContext context) : base(context) { } + } +} diff --git a/Entities/Attendee.cs b/Entities/Attendee.cs index 0802046..2b8c6bb 100755 --- a/Entities/Attendee.cs +++ b/Entities/Attendee.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace EventbriteNET.Entities { @@ -60,6 +61,30 @@ public class Attendee : EntityBase public DateTime? BirthDate; public int? Age; + private List _barcodes; + public List Barcodes + { + get + { + return _barcodes ?? new List(); + } + set + { + if(_barcodes == null) _barcodes =new List(); + _barcodes = value; + } + } + + private List _answers; + public List Answers + { + get { return _answers ?? new List();} + set { + if (_answers == null) _answers = new List(); + _answers = value; + } + } + public Attendee(EventbriteContext context) : base(context) { } } } diff --git a/Entities/Barcode.cs b/Entities/Barcode.cs new file mode 100644 index 0000000..7caf543 --- /dev/null +++ b/Entities/Barcode.cs @@ -0,0 +1,12 @@ +namespace EventbriteNET.Entities +{ + public class Barcode : EntityBase + + { + public Barcode(EventbriteContext context): base(context) { } + + + public string Id; + public string Status; + } +} \ No newline at end of file diff --git a/Entities/User.cs b/Entities/User.cs new file mode 100644 index 0000000..c1fa6fc --- /dev/null +++ b/Entities/User.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using EventbriteNET.HttpApi; + +namespace EventbriteNET.Entities +{ + public class User + { + EventbriteContext _context; + + public User(EventbriteContext context) + { + this._context = context; + } + + private IDictionary userevents; + public IDictionary Events + { + get + { + if (userevents == null) + { + userevents = new Dictionary(); + var eventArray = new UserEventsRequest(_context).GetResponse(); + foreach (var eventEntity in eventArray) + { + userevents.Add(eventEntity.Id, eventEntity); + } + } + return userevents; + } + + } + } +} diff --git a/Entities/Venue.cs b/Entities/Venue.cs new file mode 100644 index 0000000..78ec811 --- /dev/null +++ b/Entities/Venue.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace EventbriteNET.Entities +{ + /// + /// venue + /// The event venue with the following structure: + /// + public class Venue : EntityBase + { + + public Venue(EventbriteContext context) + : base(context) + { + } + + /// + ///id integer + ///The venue ID. + /// + public long Id { get; set; } + + /// + /// name string - The venue name. + /// + public string Name { get; set; } + + /// + /// address string - The venue address. + /// + public string Address { get; set; } + + /// + /// address_2 string - The venue address (continued). + /// + public string Address2 { get; set; } + + /// + /// city string - The venue city. + /// + public string City { get; set; } + + /// + /// region string - The venue state/province/county depending on the country. + /// + public string Region { get; set; } + + /// + /// postal_code string - The venue postal code. + /// + public string PostalCode { get; set; } + + /// + /// country string - The venue country name. + /// + public string Country { get; set; } + + /// + /// country_code string - The venue country code, in 2-letter ISO 3166 format (e.g., “US”). + /// + public string CountryCode { get; set; } + + /// + /// longitude float - The venue GeoLocation in WGS84 (Longitude). + /// + public decimal Longitude { get; set; } + + /// + /// latitude float - The venue GeoLocation in WGS84 (Latitude). + /// + public decimal Latitude { get; set; } + + /// + /// Lat-Long string - The venue GeoLocation in WGS84 (Latitude/Longitude). + /// + public string LatLong { get; set; } + + public override string ToString() + { + var address = Address + (!String.IsNullOrEmpty(Address2) ? "," + Address2 : String.Empty); + var cityregion = City + (!String.IsNullOrEmpty(Region) ? "," + Region : String.Empty); + return String.Format("{0} {1} {2} {3}", Name, address, cityregion, CountryCode); + } + } +} \ No newline at end of file diff --git a/EventbriteContext.cs b/EventbriteContext.cs index 1e87059..7460950 100755 --- a/EventbriteContext.cs +++ b/EventbriteContext.cs @@ -11,6 +11,8 @@ public class EventbriteContext public string UserKey; public string Host = "https://www.eventbrite.com/xml/"; + public bool ShowFullBarcodes { get; set; } + public EventbriteContext(string appKey, string userKey = null) { this.AppKey = appKey; @@ -30,4 +32,4 @@ public Event GetEvent(long id) return new EventRequest(id, this).GetResponse(); } } -} +} \ No newline at end of file diff --git a/HttpApi/UserEventsRequest.cs b/HttpApi/UserEventsRequest.cs new file mode 100644 index 0000000..494abf6 --- /dev/null +++ b/HttpApi/UserEventsRequest.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using EventbriteNET.Entities; +using EventbriteNET.Xml; + +namespace EventbriteNET.HttpApi +{ + public class UserEventsRequest: RequestBase + { + const string PATH = "user_list_events"; + + public UserEventsRequest( EventbriteContext context, string[] statuses =null) + : base(PATH, context) + { + //statuses = statuses ?? new string[] {"live", "started"}; + //this.AddGet("event_statuses", String.Join(",", statuses)); + } + + public Event[] GetResponse() + { + return new UserEventsBuilder(this.Context).Build(base.GetResponse()); + } + + } +} diff --git a/Xml/AnswerBuilder.cs b/Xml/AnswerBuilder.cs new file mode 100644 index 0000000..d22ace9 --- /dev/null +++ b/Xml/AnswerBuilder.cs @@ -0,0 +1,30 @@ +using EventbriteNET.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml; + +namespace EventbriteNET.Xml +{ + class AnswerBuilder : BuilderBase + { + public AnswerBuilder(EventbriteContext context) : base(context) { } + + public Answer Build(string xmlString) + { + this.Validate(xmlString); + + var toReturn = new Answer(this.Context); + + var doc = new XmlDocument(); + doc.LoadXml(xmlString); + + toReturn.id = TryGetElementValue("question_id", doc); + toReturn.question = TryGetElementValue("question", doc); + toReturn.answer = TryGetElementValue("answer_text", doc); + + return toReturn; + } + } +} diff --git a/Xml/BarcodeBuilder.cs b/Xml/BarcodeBuilder.cs new file mode 100644 index 0000000..32775c6 --- /dev/null +++ b/Xml/BarcodeBuilder.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml; +using EventbriteNET.Entities; + +namespace EventbriteNET.Xml +{ + class BarcodeBuilder : BuilderBase + { + public BarcodeBuilder(EventbriteContext context) : base(context) { } + + public Barcode Build(string xmlString) + { + this.Validate(xmlString); + + var toReturn = new Barcode(this.Context); + + var doc = new XmlDocument(); + doc.LoadXml(xmlString); + + toReturn.Id = TryGetElementValue("id", doc); + toReturn.Status = TryGetElementValue("status", doc); + + return toReturn; + } + } +} diff --git a/Xml/UserEventsBuilder.cs b/Xml/UserEventsBuilder.cs new file mode 100644 index 0000000..8e57fb5 --- /dev/null +++ b/Xml/UserEventsBuilder.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using EventbriteNET.Entities; +using System.IO; +using System.Xml; + +namespace EventbriteNET.Xml +{ + class UserEventsBuilder : BuilderBase + { + public UserEventsBuilder(EventbriteContext context) : base(context) { } + + public Event[] Build(string xmlString) + { + this.Validate(xmlString); + + var stringReader = new StringReader(xmlString); + + var toReturn = new List(); + + var doc = new XmlDocument(); + doc.LoadXml(xmlString); + + var events = doc.GetElementsByTagName("event"); + var builder = new EventBuilder(this.Context); + foreach (XmlNode eventNode in events) + { + var eventEntity = builder.Build(eventNode.OuterXml); + toReturn.Add(eventEntity); + } + + return toReturn.ToArray(); + } + } +} diff --git a/Xml/VenueBuilder.cs b/Xml/VenueBuilder.cs new file mode 100644 index 0000000..01a77aa --- /dev/null +++ b/Xml/VenueBuilder.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using EventbriteNET.Entities; +using System.IO; +using System.Xml; + +namespace EventbriteNET.Xml +{ + class VenueBuilder : BuilderBase + { + public VenueBuilder(EventbriteContext context) : base(context) { } + + public Venue Build(string xmlString) + { + this.Validate(xmlString); + + var stringReader = new StringReader(xmlString); + + var toReturn = new Venue(this.Context); + + var doc = new XmlDocument(); + doc.LoadXml(xmlString); + + try + { + toReturn.Id = long.Parse(doc.GetElementsByTagName("id")[0].InnerText); + toReturn.Name = doc.GetElementsByTagName("name")[0].InnerText.Trim(); + toReturn.Address = doc.GetElementsByTagName("address")[0].InnerText.Trim(); + toReturn.Address2 = doc.GetElementsByTagName("address_2")[0].InnerText.Trim(); + toReturn.City = doc.GetElementsByTagName("city")[0].InnerText.Trim(); + toReturn.Region = doc.SelectSingleNode("region") != null ? doc.GetElementsByTagName("region")[0].InnerText.Trim() : String.Empty; + toReturn.PostalCode = doc.GetElementsByTagName("postal_code")[0].InnerText.Trim(); + toReturn.Country = doc.GetElementsByTagName("country")[0].InnerText.Trim(); + toReturn.CountryCode = doc.GetElementsByTagName("country_code")[0].InnerText.Trim(); + toReturn.Longitude = decimal.Parse(doc.GetElementsByTagName("longitude")[0].InnerText.Trim()); + toReturn.Latitude = decimal.Parse(doc.GetElementsByTagName("latitude")[0].InnerText.Trim()); + toReturn.LatLong = doc.GetElementsByTagName("Lat-Long")[0].InnerText.Trim(); + } + catch (Exception) + { + //swallow it. + //TODO: Fix this. + } + + return toReturn; + } + + + } +}