Skip to content

Commit 88e9850

Browse files
committed
Pet Implementation Part 2
Completed implementation of battle pet api calls.
1 parent 841eb90 commit 88e9850

File tree

7 files changed

+119
-5
lines changed

7 files changed

+119
-5
lines changed

Diff for: Explorers.Test/Explorers.Test.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<Compile Include="DataTests.cs" />
5555
<Compile Include="ItemTests.cs" />
5656
<Compile Include="GuildTests.cs" />
57+
<Compile Include="PetTests.cs" />
5758
<Compile Include="Properties\AssemblyInfo.cs" />
5859
<Compile Include="RealmTests.cs" />
5960
<Compile Include="TestStrings.Designer.cs">

Diff for: Explorers.Test/PetTests.cs

+30
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,36 @@ public static void ClassInit(TestContext context)
1919
[TestMethod]
2020
public void Get_Pet_List()
2121
{
22+
var pets = explorer.GetPets();
23+
Assert.IsTrue(pets.Any());
24+
}
25+
26+
[TestMethod]
27+
public void Get_Pet_Ability_Details()
28+
{
29+
var ability = explorer.GetPetAbilityDetails(640);
30+
Assert.IsNotNull(ability);
31+
}
32+
33+
[TestMethod]
34+
public void Get_Pet_Species()
35+
{
36+
var species = explorer.GetPetSpeciesDetails(258);
37+
Assert.IsNotNull(species);
38+
}
39+
40+
[TestMethod]
41+
public void Get_Pet_Stats()
42+
{
43+
var stats = explorer.GetPetStats(258, 25, 5, 4);
44+
Assert.IsNotNull(stats);
45+
}
46+
47+
[TestMethod]
48+
public void Get_Pet_Types()
49+
{
50+
var types = explorer.GetPetTypes();
51+
Assert.IsTrue(types.Any());
2252
}
2353
}
2454
}

Diff for: Explorers/Explorers.csproj

+8-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
<Compile Include="Models\CharacterFeed.cs" />
7676
<Compile Include="Models\CharacterPets.cs" />
7777
<Compile Include="Models\CharacterPetSlot.cs" />
78-
<Compile Include="Models\CharacterPetStats.cs" />
7978
<Compile Include="Models\CharacterRatedBattleground.cs" />
8079
<Compile Include="Models\CharacterRatedBattlegrounds.cs" />
8180
<Compile Include="Models\CharacterPVP.cs" />
@@ -91,7 +90,6 @@
9190
<Compile Include="Models\Auctions.cs" />
9291
<Compile Include="Models\CharacterClassInfo.cs" />
9392
<Compile Include="Models\CharacterClassesData.cs" />
94-
<Compile Include="Models\CharacterPet.cs" />
9593
<Compile Include="Models\CharacterRaceInfo.cs" />
9694
<Compile Include="Models\CharacterRacesData.cs" />
9795
<Compile Include="Models\GuildPerkInfo.cs" />
@@ -116,6 +114,14 @@
116114
<Compile Include="Models\ItemUpgrade.cs" />
117115
<Compile Include="Models\ItemWeaponDamage.cs" />
118116
<Compile Include="Models\ItemWeaponInfo.cs" />
117+
<Compile Include="Models\Pet.cs" />
118+
<Compile Include="Models\PetAbility.cs" />
119+
<Compile Include="Models\PetAbilityDetails.cs" />
120+
<Compile Include="Models\PetList.cs" />
121+
<Compile Include="Models\PetSpecies.cs" />
122+
<Compile Include="Models\PetStats.cs" />
123+
<Compile Include="Models\PetType.cs" />
124+
<Compile Include="Models\PetTypeData.cs" />
119125
<Compile Include="Models\PvpStats.cs" />
120126
<Compile Include="Models\Leaderboard.cs" />
121127
<Compile Include="Utilities\JsonUtility.cs" />

Diff for: Explorers/Models/PetAbilityDetails.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class PetAbilityDetails
1313
public int AbilityId { get; set; }
1414

1515
[DataMember(Name = "name")]
16-
public int Name { get; set; }
16+
public string Name { get; set; }
1717

1818
[DataMember(Name = "icon")]
1919
public string Icon { get; set; }

Diff for: Explorers/Models/PetType.cs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Runtime.Serialization;
5+
using System.Text;
6+
7+
namespace WowDotNetAPI.Models
8+
{
9+
[DataContract]
10+
public class PetType
11+
{
12+
[DataMember(Name = "id")]
13+
public int PetTypeId { get; set; }
14+
15+
[DataMember(Name = "key")]
16+
public string Key { get; set; }
17+
18+
[DataMember(Name = "name")]
19+
public string Name { get; set; }
20+
21+
[DataMember(Name = "typeAbilityId")]
22+
public int TypeAbilityId { get; set; }
23+
24+
[DataMember(Name = "strongAgainstId")]
25+
public int StrongAgainstId { get; set; }
26+
27+
[DataMember(Name = "weakAgainstId")]
28+
public int WeakAgainstId { get; set; }
29+
}
30+
}

Diff for: Explorers/Models/PetTypeData.cs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Runtime.Serialization;
5+
using System.Text;
6+
7+
namespace WowDotNetAPI.Models
8+
{
9+
[DataContract]
10+
public class PetTypeData
11+
{
12+
[DataMember(Name = "petTypes")]
13+
public IEnumerable<PetType> PetTypes { get; set; }
14+
}
15+
}

Diff for: Explorers/WowExplorer.cs

+34-2
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ public Guild GetGuild(Region region, string realm, string name, GuildOptions rea
182182
/// Gets a list of all battle pets
183183
/// </summary>
184184
/// <returns>PetList object containing an IEnumerable of Pet objects</returns>
185-
public PetList GetPets()
185+
public IEnumerable<Pet> GetPets()
186186
{
187187
PetList pets;
188188

189189
TryGetData<PetList>(string.Format(@"{0}/wow/pet/?locale={1}&apikey={2}", Host, Locale, APIKey),
190190
out pets);
191191

192-
return pets;
192+
return pets.Pets;
193193
}
194194

195195
/// <summary>
@@ -222,6 +222,38 @@ public PetSpecies GetPetSpeciesDetails(int id)
222222
return species;
223223
}
224224

225+
/// <summary>
226+
/// Retrieve detailed information about a given species of pet.
227+
/// </summary>
228+
/// <param name="speciesId">The pet's species ID. This can be found by querying a users' list of pets via the Character Profile API.</param>
229+
/// <param name="level">The pet's level. Pet levels max out at 25. If omitted the API assumes a default value of 1.</param>
230+
/// <param name="breedId">The pet's breed. Retrievable via the Character Profile API. If omitted the API assumes a default value of 3.</param>
231+
/// <param name="qualityId">The pet's quality. Retrievable via the Character Profile API. Pet quality can range from 0 to 5 (0 is poor quality and 5 is legendary). If omitted the API will assume a default value of 1.</param>
232+
/// <returns></returns>
233+
public PetStats GetPetStats(int speciesId, int level, int breedId, int qualityId)
234+
{
235+
PetStats stats;
236+
237+
TryGetData<PetStats>(string.Format(@"{0}/wow/pet/stats/{1}?level={2}&breedId={3}&qualityId={4}&locale={5}&apikey={6}", Host, speciesId, level, breedId, qualityId, Locale, APIKey),
238+
out stats);
239+
240+
return stats;
241+
}
242+
243+
/// <summary>
244+
/// The different bat pet types (including what they are strong and weak against)
245+
/// </summary>
246+
/// <returns></returns>
247+
public IEnumerable<PetType> GetPetTypes()
248+
{
249+
PetTypeData types;
250+
251+
TryGetData<PetTypeData>(string.Format(@"{0}/wow/data/pet/types?locale={1}&apikey={2}", Host, Locale, APIKey),
252+
out types);
253+
254+
return types.PetTypes.Any() ? types.PetTypes : null;
255+
}
256+
225257
#endregion
226258

227259
#region Realms

0 commit comments

Comments
 (0)