forked from Sensis/SAPI-Cocoa-SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metatdata endpoint all working (actually haven't tested the last chan…
…ge due to hitting the rate limit for now)
- Loading branch information
Showing
12 changed files
with
227 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// SAPIMetadataResult.h | ||
// Sensis SAPI | ||
// | ||
// Created by Mark Aufflick on 22/03/12. | ||
// Copyright (c) 2012 Pumptheory Pty Ltd. All rights reserved. | ||
// | ||
|
||
#import "SAPIResult.h" | ||
|
||
@interface SAPIMetadataResult : SAPIResult | ||
|
||
@property (retain) NSArray * categories; // populated if you requested category metadata | ||
@property (retain) NSArray * categoryGroups; // populated if you requested categoryGroup metadata | ||
@property (retain) NSArray * groups; // an alias for categoryGroups (the SAPI docs are ambiguous, so we support both keys) | ||
// NB: this alias is not KVO compliant | ||
|
||
// also time, code and possibly details -- defined in the baseclass SAPIResult | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// SAPIMetadataResult.m | ||
// Sensis SAPI | ||
// | ||
// Created by Mark Aufflick on 22/03/12. | ||
// Copyright (c) 2012 Pumptheory Pty Ltd. All rights reserved. | ||
// | ||
|
||
#import "SAPIMetadataResult.h" | ||
|
||
@implementation SAPIMetadataResult | ||
|
||
@synthesize categories; | ||
@synthesize categoryGroups; | ||
|
||
- (void)dealloc | ||
{ | ||
[categoryGroups release]; | ||
[categories release]; | ||
|
||
[super dealloc]; | ||
} | ||
|
||
- (NSArray *)groups | ||
{ | ||
return self.categoryGroups; | ||
} | ||
|
||
- (void)setGroups:(NSArray *)groups | ||
{ | ||
self.categoryGroups = groups; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// Sensis_SAPI_MetadataTests.h | ||
// Sensis SAPI | ||
// | ||
// Created by Mark Aufflick on 22/03/12. | ||
// Copyright (c) 2012 Pumptheory Pty Ltd. All rights reserved. | ||
// | ||
|
||
// Application unit tests contain unit test code that must be injected into an application to run correctly. | ||
// See Also: http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/135-Unit_Testing_Applications/unit_testing_applications.html | ||
|
||
#import <SenTestingKit/SenTestingKit.h> | ||
|
||
@interface Sensis_SAPI_MetadataTests : SenTestCase | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// | ||
// Sensis_SAPI_MetadataTests.m | ||
// Sensis SAPI | ||
// | ||
// Created by Mark Aufflick on 22/03/12. | ||
// Copyright (c) 2012 Pumptheory Pty Ltd. All rights reserved. | ||
// | ||
|
||
#import "Sensis_SAPI_MetadataTests.h" | ||
|
||
#import "SAPI.h" | ||
#import "SAPIAccountKey.h" | ||
#import "SAPIMetadata.h" | ||
|
||
@implementation Sensis_SAPI_MetadataTests | ||
|
||
- (void)setUp | ||
{ | ||
[super setUp]; | ||
|
||
[SAPI setKey:SAPI_KEY]; | ||
[SAPI setEnvironment:SAPI_ENVIRONMENT]; | ||
|
||
// we need to stay slow so the tests can succeed in SAPI test environment due to rate limit | ||
sleep(1); | ||
} | ||
|
||
- (void)tearDown | ||
{ | ||
// Tear-down code here. | ||
|
||
[super tearDown]; | ||
} | ||
|
||
- (void)testCategories | ||
{ | ||
SAPIMetadata * metadataQuery = [[SAPIMetadata alloc] init]; | ||
metadataQuery.dataType = SAPIMetadataCategoriesKey; | ||
SAPIError * error = nil; | ||
SAPIMetadataResult * res = [metadataQuery performQueryWithError:&error]; | ||
|
||
STAssertNotNil(res, [NSString stringWithFormat:@"Categories query returned no results (%@)", error]); | ||
STAssertTrue([res.categories isKindOfClass:[NSArray class]], @"Returned results are not NSArray"); | ||
STAssertFalse([res.categories count] == 0, @"We expect a categories query to have > 0 results"); | ||
|
||
NSDictionary * firstResult = [res.categories objectAtIndex:0]; | ||
STAssertTrue([firstResult isKindOfClass:[NSDictionary class]], @"first result entry is not a dictionary"); | ||
STAssertTrue([[firstResult objectForKey:@"id"] isKindOfClass:[NSNumber class]], @"id key is not a number"); | ||
STAssertTrue([[firstResult objectForKey:@"name"] isKindOfClass:[NSString class]], @"id key is not a string"); | ||
|
||
[metadataQuery release]; | ||
} | ||
|
||
- (void)testCategoryGroups | ||
{ | ||
SAPIMetadata * metadataQuery = [[SAPIMetadata alloc] init]; | ||
metadataQuery.dataType = SAPIMetadataCategoryGroupsKey; | ||
SAPIError * error = nil; | ||
SAPIMetadataResult * res = [metadataQuery performQueryWithError:&error]; | ||
|
||
STAssertNotNil(res, [NSString stringWithFormat:@"CategoryGroups query returned no results (%@)", error]); | ||
STAssertTrue([res.categoryGroups isKindOfClass:[NSArray class]], @"Returned results are not NSArray"); | ||
STAssertFalse([res.categoryGroups count] == 0, @"We expect a categoryGroups query to have > 0 results"); | ||
|
||
[metadataQuery release]; | ||
} | ||
|
||
|
||
@end |