https://github.com/rnystrom/D3Kit
Warning!
D3Kit is still missing Fallen-Hero, Artisan, and Progression support. Coming soon!
D3Kit is an easy to use layer to communicate with the Diablo 3 API maintained by Blizzard Entertainment. D3Kit handles all of the requests and gives you a simple block style callback system for successes and failures. After successful reqeusts are made, D3Kit parses the JSON response from Blizzard and builds NSObjects for you to use in your apps.
Get Started
Installation
To get started, add D3Kit as a submodule to your project. Make sure to add the submodule from the root of your project.
git submodule add git@github.com:rnystrom/D3Kit.git
Then drag D3Kit.xcodeproj
into your project.
Open the Build Phases of your project. Add D3Kit as a Target Dependency.
Then add libD3Kit.a
to Link Binary With Libraries.
In your project, open the Build Settings tab. Search for "User Header Search Paths". Set this value to "${PROJECT_DIR}/D3Kit"
(including quotes). Also set "Always Search User Paths" to YES.
Find the “Other Linker Flags” option, and add the value -ObjC
(no quotes).
In your Prefix.pch file add #import <D3Kit/D3Kit.h>
and you're done!
Overview
The classes that are populated from Blizzard's Diablo 3 API are:
- D3Artisan
- D3Career
- D3Follower
- D3Hero
- D3Item
- D3Rune
- D3Skill
Classes have relationships based on the Blizzard Diablo 3 API. Currently the relations are:
- D3Career
has many
D3Hero - D3Career
has many
D3Artisan - D3Hero
has many
D3Item - D3Hero
has many
D3Skill - D3Hero
has many
D3Follower - D3Item
has one
D3Rune
The class D3HTTPClient
helps retrieve information from Blizzard's Diablo 3 API is a subclass of AFNetworking's AFHTTPClient. All functionality of D3HTTPClient
is available. However there are helper methods included with each class to retrieve:
- Extra information (ie. D3Career call does not fully populate a D3Hero object by nature of the API)
- Images
Career
To load a career and associated objects pass in an account NSString. This string should be in the format battletag#1234
or elsefailure()
will be called. The built-in validation requires a "#" to seperate the account name and number.
[D3Career getCareerForBattletag:account success:^(D3Career *career) {
// ...
} failure:^(NSError *error) {
// ...
}];
Hero
When getCareerForBattletag:success:
is called each hero for the career is insantiated but not fully loaded because of the way the Blizzard Diablo 3 API is implemented (which is a good thing, as it keeps the response size small). To finish loading a D3Hero object, call:
[hero finishLoadingWithSuccess:^(D3Hero *hero) {
// ...
} failure:^(NSError *error) {
// ...
}];
Images
Currently all image requests are instance methods that return a AFImageRequestOperation in the assumption that images will be collected in batches. Ie:
[hero.items enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
D3Item *item = (D3Item*)obj;
AFImageRequestOperation *operation = [correspondingItem requestForItemIconWithImageProcessingBlock:NULL success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
// ...
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
// ...
}];
[mutOperations addObject:operation ];
}];
[[D3HTTPClient sharedClient ] enqueueBatchOfHTTPRequestOperations:mutOperations progressBlock:^(NSUInteger completedOperations, NSUInteger totalOperations){
// ...
}completionBlock:^(NSArray *operations) {
// ...
}];
However it should be trivial to add the AFImageRequestOperation to the queue of D3HTTPClient
.