Parthis.2091:

Hi,

This is Durmand Priory. An Objective-C API for the Guild Wars 2 REST suite. It’s a little different to a lot of the current API wrappers. It’s a domain-first framework, meaning that you deal with domain objects, not services.

https://github.com/dannywartnaby/DurmandPriory

Durmand Priory uses ARC and has a dependency on AFNetworking. (https://github.com/AFNetworking/AFNetworking).

Why Durmand Priory?
“The Durmand Priory is a scholarly order dedicated to protecting knowledge” wiki

The idea is that you deal with the domain first and foremost for all but the most obscure of services. Services are fully abstracted from the client and you never deal with endpoints, server addresses, rest versions or parameters, unless you really want to. You deal with classes and instances.

For example, fetching all items is simply;

[DurmandPriory fetch:[GW2Item class] completionBlock:^(id domain) {
}];

That’s all you need in order to fetch all items, you provide a block to execute on completion. The GW2Item class holds in memory all items for you. You can ask it for all or any item you wish;

[GW2Item itemById:@"12345"]; // Specific items.
[GW2Item items]; // All items.

As you’ll know the GW2 Rest API for items returns all known item IDs. In order to know about an item you need to hit a different endpoint, passing the item ID. With Durmand Priory you simply pass the instance of the item you want;

GW2Item * item = [GW2Item itemById:@"12345"];
[DurmandPriory fetch:item completionBlock:^(id domain) {

}];

And it’s done. No need to know about endpoints, no worries about parameters, languages and restrictions. This is the pattern employed throughout the framework; pass the CLASS to load data (items, events, recipes, etc) and pass an INSTANCE to get specific details.

For more information please do read the README at https://github.com/dannywartnaby/DurmandPriory – The framework is very flexible, very stable and very consistent in it’s approach and pattern. If you’re looking for a more traditional ‘service orientated’ framework have a look at Rhino’s GW2Kit (https://forum-en.guildwars2.com/forum/community/api/GW2Kit-An-Obj-C-framework-for-iOS-OS-X).

Happy coding!

Killer Rhino.6794:

Great stuff, Parthis. This is a really interesting design, too.

Parthis.2091:

Thanks Rhino.

It’s always interesting to see how different developers tackle the same problem, given the same toolset and language. For everyone else choice of framework is always great.

Small update pushed to github; ‘framework’ code now resides in a subfolder for ease of use. I’m not planning on having the project build a library just yet, atleast not while the codebase is this small and the remote services are still evolving. It’ll be easy to switch to a framework later.

Also updated the README. Lots of useful information in there, so do give it a read chaps.

Now that I have this… time to get on with an app!

Cheers,
p.

Parthis.2091:

A work in progress. It’s a bank holiday, which means some free time in the UK! Spent an hour putting together a quick iPhone app to show you your world’s WubWub scores in almost-realtime. It uses the Durmand Priory ‘fetchCollection:GW2APIDomainCollectionWorldVsWorld’ method to quickly get WvW scores for a world (in this example it’s hardcoded).

Very straight forward;

 [DurmandPriory fetchCollection:GW2APIDomainCollectionWorldVsWorld
                   completionBlock:^(GW2APIDomainCollection collection) {
                       
                       GW2World * activeWorld = [GW2World worldById:@"2003"];
                       [DurmandPriory fetch:activeWorld.matchup completionBlock:^(id domain) {

                           [self.totalChart reloadData];
                           [self.ebChart reloadData];
                           [self.rblChart reloadData];
                           [self.gblChart reloadData];
                           [self.bblChart] reloadData;
                       }];
                   }];

It uses XYPieChart (https://github.com/xyfeng/XYPieChart) and all 5 charts are simply delegates, the data is provided by;

- (CGFloat)pieChart:(XYPieChart *)pieChart valueForSliceAtIndex:(NSUInteger)index {
    GW2MatchScores scores;
    
    if ( pieChart == self.totalChart ) {
        scores = world_.matchup.totalScores;
    }
    if ( pieChart == self.rblChart ) {
        scores = [world_.matchup mapByTypeName:@"RedHome"].scores;
    }
    if ( pieChart == self.gblChart ) {
        scores = [world_.matchup mapByTypeName:@"GreenHome"].scores;
    }
    if ( pieChart == self.bblChart ) {
        scores = [world_.matchup mapByTypeName:@"BlueHome"].scores;
    }
    if ( pieChart == self.ebChart ) {
        scores = [world_.matchup mapByTypeName:@"Center"].scores;
    }
    
    if ( index == 0 ) {
        return scores.red;
    }
    if ( index == 1 ) {
        return scores.green;
    }
    if ( index == 2 ) {
        return scores.blue;
    }
    return 0;
}

And that’s it; a complete WubWub score viewer in <20 lines of app code and a delegate method for a charting framework.

Will polish the app up, make it pretty and push a build to the app store soon.

Parthis.2091:

A small update, and not strictly API related, but just finished my first iPhone app using Durmand Priory. This lead to a few improvements and additions to the API which will be pushed to github tomorrow.

I wanted to start with a simple app to bed-in the API and push something live. The app is called “Stonemist” and is, in essence, the in-game WvW score board but on your iPhone.

I’ve submitted it to Apple for review and will post against when it’s live.

Parthis.2091:

A small update, made another small app as a way of shaping updates to the Durmand Priory API. The app is called “Identified Dye” and runs on iOS. It presents, sorts, allows filtering, previewing and price checking of all dyes in guild wars 2. It will also show the subtle variations in colour when applied to light, medium and heavy armors.

Identified Dye has been submitted to the App Store.

The updates to Durmand Priory will be pushed to the repo in the next day or two, and includes updates to cover all new APIs and also provides a mechanism to access pricing information for items on the trade post. Now that the GW2 API is increasing it’s coverage Durmand Priory builds as a static library. I’ll update the Wiki with integration details shortly.

Thanks to the people using the lib who’ve contacted me with suggestions, ideas and ‘thank yous’ – you’re welcome!

Cheers,
p.