Skip to content

Attendee Custom Answers implemented #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Entities/Answer.cs
Original file line number Diff line number Diff line change
@@ -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) { }
}
}
25 changes: 25 additions & 0 deletions Entities/Attendee.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;

namespace EventbriteNET.Entities
{
Expand Down Expand Up @@ -60,6 +61,30 @@ public class Attendee : EntityBase
public DateTime? BirthDate;
public int? Age;

private List<Barcode> _barcodes;
public List<Barcode> Barcodes
{
get
{
return _barcodes ?? new List<Barcode>();
}
set
{
if(_barcodes == null) _barcodes =new List<Barcode>();
_barcodes = value;
}
}

private List<Answer> _answers;
public List<Answer> Answers
{
get { return _answers ?? new List<Answer>();}
set {
if (_answers == null) _answers = new List<Answer>();
_answers = value;
}
}

public Attendee(EventbriteContext context) : base(context) { }
}
}
12 changes: 12 additions & 0 deletions Entities/Barcode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace EventbriteNET.Entities
{
public class Barcode : EntityBase

{
public Barcode(EventbriteContext context): base(context) { }


public string Id;
public string Status;
}
}
37 changes: 37 additions & 0 deletions Entities/User.cs
Original file line number Diff line number Diff line change
@@ -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<long, Event> userevents;
public IDictionary<long, Event> Events
{
get
{
if (userevents == null)
{
userevents = new Dictionary<long, Event>();
var eventArray = new UserEventsRequest(_context).GetResponse();
foreach (var eventEntity in eventArray)
{
userevents.Add(eventEntity.Id, eventEntity);
}
}
return userevents;
}

}
}
}
88 changes: 88 additions & 0 deletions Entities/Venue.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EventbriteNET.Entities
{
/// <summary>
/// venue
/// The event venue with the following structure:
/// </summary>
public class Venue : EntityBase
{

public Venue(EventbriteContext context)
: base(context)
{
}

/// <summary>
///id integer
///The venue ID.
/// </summary>
public long Id { get; set; }

/// <summary>
/// name string - The venue name.
/// </summary>
public string Name { get; set; }

/// <summary>
/// address string - The venue address.
/// </summary>
public string Address { get; set; }

/// <summary>
/// address_2 string - The venue address (continued).
/// </summary>
public string Address2 { get; set; }

/// <summary>
/// city string - The venue city.
/// </summary>
public string City { get; set; }

/// <summary>
/// region string - The venue state/province/county depending on the country.
/// </summary>
public string Region { get; set; }

/// <summary>
/// postal_code string - The venue postal code.
/// </summary>
public string PostalCode { get; set; }

/// <summary>
/// country string - The venue country name.
/// </summary>
public string Country { get; set; }

/// <summary>
/// country_code string - The venue country code, in 2-letter ISO 3166 format (e.g., “US”).
/// </summary>
public string CountryCode { get; set; }

/// <summary>
/// longitude float - The venue GeoLocation in WGS84 (Longitude).
/// </summary>
public decimal Longitude { get; set; }

/// <summary>
/// latitude float - The venue GeoLocation in WGS84 (Latitude).
/// </summary>
public decimal Latitude { get; set; }

/// <summary>
/// Lat-Long string - The venue GeoLocation in WGS84 (Latitude/Longitude).
/// </summary>
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);
}
}
}
4 changes: 3 additions & 1 deletion EventbriteContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,4 +32,4 @@ public Event GetEvent(long id)
return new EventRequest(id, this).GetResponse();
}
}
}
}
27 changes: 27 additions & 0 deletions HttpApi/UserEventsRequest.cs
Original file line number Diff line number Diff line change
@@ -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());
}

}
}
30 changes: 30 additions & 0 deletions Xml/AnswerBuilder.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
29 changes: 29 additions & 0 deletions Xml/BarcodeBuilder.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
37 changes: 37 additions & 0 deletions Xml/UserEventsBuilder.cs
Original file line number Diff line number Diff line change
@@ -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<Event>();

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();
}
}
}
52 changes: 52 additions & 0 deletions Xml/VenueBuilder.cs
Original file line number Diff line number Diff line change
@@ -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;
}


}
}