There isn't much setup that needs to be done at all. Just merge the App.config into either your App.config or your Web.config, and enter your authorization keys if you have them. If you don't have authorization keys, you can either leave them blank, or remove the attributes from the config file.

By default, the CurrentRegionKey is set to the default value defined in the configuration file, and the CurrentLocale is set to null. Setting CurrentRegionKey to any value, will also reset CurrentLocale back to null.

Here is some sample code to test each of the methods:

foreach (RegionElement region in WorldOfWarcraftSection.Instance.Regions)
{
	Debug.WriteLine("Region: Key = {0}, Name = {1}, Host = {2}", region.Key, region.Name, region.Host);

	foreach (LocaleElement locale in region.Locales)
	{
		Debug.WriteLine(">>> Locale: Key = {0}, Name = {1}", locale.Key, locale.Name);
	}
}

CommunityPlatformClient client = new CommunityPlatformClient();
//client.CurrentRegionKey = WorldOfWarcraftSection.Instance.Regions.Default;
//client.CurrentLocale = "es_MX";

// The following example shows the use of the Raw method calls which get the JSON
// response and don't do any additional processing (i.e. no deserialization).
// These methods are best used when you only need to retrieve the RAW JSON string
// and send it to the web client.
string jsonResponse = client.GetBattlegroupsRaw();
JsonTextBox.Text = jsonResponse;

// The deserialization methods have been left in tact.  They can be used to
// deserialize responses that have been received from the web client.
BattlegroupsResponse battlegroupsList = client.DeserializeBattlegroupsResponse(jsonResponse);
JsonTextBox.Text = battlegroupsList.JsonResponse;

DataAchievementsResponse characterAchievementsResponse = client.GetCharacterAchievements();
JsonTextBox.Text = characterAchievementsResponse.JsonResponse;

CharacterClassesResponse characterClassesResponse = client.GetCharacterClasses();
JsonTextBox.Text = characterClassesResponse.JsonResponse;

CharacterRacesResponse characterRacesResponse = client.GetCharacterRaces();
JsonTextBox.Text = characterRacesResponse.JsonResponse;

DataAchievementsResponse guildAchievements = client.GetGuildAchievements();
JsonTextBox.Text = guildAchievements.JsonResponse;

GuildPerksResponse guildPerksResponse = client.GetGuildPerks();
JsonTextBox.Text = guildPerksResponse.JsonResponse;

GuildRewardsResponse guildRewardsResponse = client.GetGuildRewards();
JsonTextBox.Text = guildRewardsResponse.JsonResponse;

ItemClassesResponse itemClassesResponse = client.GetItemClasses();
JsonTextBox.Text = itemClassesResponse.JsonResponse;

PetTypesResponse petTypesResponse = client.GetPetTypes();
JsonTextBox.Text = petTypesResponse.JsonResponse;

TalentsResponse talentsResponse = client.GetTalents();
JsonTextBox.Text = talentsResponse.JsonResponse;

AchievementResponse achievementResponse = client.GetAchievement(2144);
JsonTextBox.Text = achievementResponse.JsonResponse;

ArenaLadderResponse arenaLadderResponse = client.GetArenaLadder("Ruin", ArenaTeamSizeEnum.Arena2v2, 1, 1, true);
JsonTextBox.Text = arenaLadderResponse.JsonResponse;

arenaLadderResponse = client.GetArenaLadder("Ruin", ArenaTeamSizeEnum.Arena2v2, 2, 1, true);
JsonTextBox.Text = arenaLadderResponse.JsonResponse;

ArenaTeamResponse arenaTeamResponse = client.GetArenaTeam("Bonechewer", ArenaTeamSizeEnum.Arena2v2, "Samurai Jack");
JsonTextBox.Text = arenaTeamResponse.JsonResponse;

AuctionDataStatusResponse auctionDataStatusResponse = client.GetAuctionDataStatus("lothar");
JsonTextBox.Text = auctionDataStatusResponse.JsonResponse;

foreach (AuctionDataStatus auctionData in auctionDataStatusResponse.Files)
{
	try
	{
		auctionData.Data = client.GetAuctionDataFile(auctionData.Url);
		JsonTextBox.Text = auctionData.Data.JsonResponse;
	}
	catch (WorldOfWarcraftApiException ex)
	{
		Debug.WriteLine("WorldOfWarcraftApiException:\n\tGetAuctionDataFile: {0}\n\tStatus: {1}\n\tMessage: {2}", auctionData.Url, ex.Status, ex.Message);
	}
	catch (Exception ex)
	{
		Debug.WriteLine("WorldOfWarcraftApiException:\n\tGetAuctionDataFile: {0}\\n\tMessage: {1}", auctionData.Url, ex.Message);
	}
}

BattlePetAbilityResponse battlePetAbilityResponse = client.GetBattlePetAbility(640);
JsonTextBox.Text = battlePetAbilityResponse.JsonResponse;

BattlePetSpeciesResponse battlePetSpeciesResponse = client.GetBattlePetSpecies(258);
JsonTextBox.Text = battlePetSpeciesResponse.JsonResponse;

BattlePetStatsResponse battlePetStatsResponse = client.GetBattlePetStats(258, 25, 5, 4);
JsonTextBox.Text = battlePetStatsResponse.JsonResponse;

RealmChallengeResponse realmChallengeResponse = client.GetRealmChallenge("Lothar");
JsonTextBox.Text = realmChallengeResponse.JsonResponse;

CharacterProfileResponse characterProfileResponse = client.GetCharacterProfile("lothar", "Kaelum", CharacterProfileOptionalFieldsEnum.All);
JsonTextBox.Text = characterProfileResponse.JsonResponse;

characterProfileResponse = client.GetCharacterProfile("lothar", "Kailor", CharacterProfileOptionalFieldsEnum.All);
JsonTextBox.Text = characterProfileResponse.JsonResponse;

characterProfileResponse = client.GetCharacterProfile("lothar", "Grewl", CharacterProfileOptionalFieldsEnum.Talents);
JsonTextBox.Text = characterProfileResponse.JsonResponse;

GuildProfileResponse guildProfileResponse = client.GetGuildProfile("lothar", "Genus Order", GuildProfileOptionalFieldsEnum.All);
JsonTextBox.Text = guildProfileResponse.JsonResponse;

guildProfileResponse = client.GetGuildProfile("lothar", "Triple Threat", GuildProfileOptionalFieldsEnum.News);
JsonTextBox.Text = guildProfileResponse.JsonResponse;

ItemResponse itemResponse = client.GetItem(18803);
JsonTextBox.Text = itemResponse.JsonResponse;

itemResponse = client.GetItem(60244);
JsonTextBox.Text = itemResponse.JsonResponse;

itemResponse = client.GetItem(60245);
JsonTextBox.Text = itemResponse.JsonResponse;

itemResponse = client.GetItem(62386);
JsonTextBox.Text = itemResponse.JsonResponse;

itemResponse = client.GetItem(70142);
JsonTextBox.Text = itemResponse.JsonResponse;

ItemSetResponse itemSetResponse = client.GetItemSet(931);
JsonTextBox.Text = itemSetResponse.JsonResponse;

itemSetResponse = client.GetItemSet(1060);
JsonTextBox.Text = itemSetResponse.JsonResponse;

for (int i = 1; i < 100; i++)
{
	// The following try-catch block shows how to use WorldOfWarcraftApiException to
	// catch exceptions.  This applies to all of the API method calls.
	try
	{
		QuestResponse questResponse = client.GetQuest(i);
		JsonTextBox.Text = questResponse.JsonResponse;
	}
	catch (WorldOfWarcraftApiException ex)
	{
		Debug.WriteLine("Quest({0}): WorldOfWarcraftApiException:\n\tStatus: {1}\n\tMessage: {2}", i, ex.Status, ex.Message);
	}
	catch (Exception ex)
	{
		Debug.WriteLine("Quest({0}): Exception:\n\tMessage: {1}", i, ex.Message);
	}
}

RatedBattlegroundLadderResponse ratedBattlegroundLadderResponse = client.GetRatedBattlegroundLadder(1, 1, true);
JsonTextBox.Text = ratedBattlegroundLadderResponse.JsonResponse;

ratedBattlegroundLadderResponse = client.GetRatedBattlegroundLadder(2, 1, true);
JsonTextBox.Text = ratedBattlegroundLadderResponse.JsonResponse;

RealmStatusResponse realmStatusResponse = client.GetRealmStatus("lothar,blackrock");

RecipeResponse recipeResponse = client.GetRecipe(33994);
JsonTextBox.Text = recipeResponse.JsonResponse;

SpellResponse spellResponse = client.GetSpell(8056);
JsonTextBox.Text = spellResponse.JsonResponse;


If you have any questions or discover a bug, please create a discussion post.

Last edited Oct 20, 2012 at 10:56 PM by KaelumYodi, version 7

Comments

No comments yet.