Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mattapayne
Created June 4, 2009 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattapayne/123700 to your computer and use it in GitHub Desktop.
Save mattapayne/123700 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using Jambase4Net;
public class App
{
public static void Main(String[] args)
{
//You can use the default configuration, which reads from app.config or web.config
//To do this, just start using the API object
IList<IEvent> events = API.Instance.Search().ByBand("A Band").List();
//Or, you can use a delegate
API.Configure(conf => {
conf.APIKey = "Your Jambase API key";
});
//Or, you can use your own implementation of the IConfigurator interface, which means you must create
//a class that defines a public method called Configure that takes an instance of a class implementing
//the IAPI interface
private class MyCustomConfigurator : IConfigurator
{
void IConfigurator.Configure(IAPI api)
{
//do configuration here
}
}
//To configure the API object with your custom configurator:
API.Configure(new MyCustomConfigurator());
//Additionally, within the Configure method, you can override the default way in which the API is
//called by providing your own implementation of IWebConnection that requires you to create a class
//that defines a method called MakeRequest(String url)
//As well, you can override the default way in which events are built by defining your own
//implementation of IEventBuilder, which requires that you define a method called Build(String xml),
//that returns an IList of IEvent objects.
//This sort of customization would look like this:
API.Configure(conf => {
conf.APIKey = "Your Jambase API key";
conf.Builder = new YourCustomBuilder();
conf.Connection = new YourCustomConnection();
});
//To make use of the library after configuration, it's quite straightforward:
//By Band
IList<IEvent> eventsByBand = API.Instance.Search().ByBand("Some Band").List();
//By User
IList<IEvent> eventsByUser = API.Instance.Search().ByUser("A User").List();
//By zip/postal code
IList<IEvent> eventsByZip = API.Instance.Search().ByZipCode("90210").List();
//By radius - distance from a specified postal code
IList<IEvent> eventsByZipAndRadius = API.Instance.Search().ByZipCode("90210").ByRadius(50).List();
//By zip/postal code, band and user
IList<IEvent> event = API.Instance.Search().ByZipCode("90210").ByBand("A Band").ByUser("A
User").List();
//All calls to List() return an IList<IEvent> (although it may be an empty list, if there are no
//results)
//Events have a Venue and a collection of Artists
foreach(IEvent evt in events)
{
Console.WriteLine("EventID: {0}", evt.ID);
Console.WriteLine("Venue Name: {0}", evt.Venue.Name);
foreach(IArtist artist in evt.Artists)
{
Console.WriteLine("Artist: {0}", artist.Name);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment