Integration
Sequencing.com has already everything to simplify integration of AppChains API into your Objective-C based project.
There are 2 ways of achiving this:
- Get code from our GitHub repository and paste it into your project
- Integrate using our Cocoapod artifacts
For Cocoapods integration please follow next steps
1) If you are new to CocoaPods, check general "Getting started" guide
2) Create Podfile in your project directory:
$ pod init
3) Specify following parameters in Podfile:
pod 'sequencing-app-chains-api-objc', '~> 1.1.0'
4) Install the dependency in your project:
$ pod install
5) Always open the Xcode workspace instead of the project file.
$ open *.xcworkspace
Objective-C module API
Method | Purpose | Arguments | Description |
---|---|---|---|
- (instancetype)initWithToken:(NSString *)token | Constructor |
|
|
- (instancetype)initWithToken:(NSString *)token withHostName:(NSString *)hostName | Constructor |
|
Constructor used for creating AppChains class instance in case reporting API is needed and where security token is required |
- (void)getReportWithApplicationMethodName:(NSString *)applicationMethodName withDatasourceId:(NSString *)datasourceId withSuccessBlock:(void (^)(Report *result))success withFailureBlock:(void (^)(NSError *error))failure; | Reporting API |
|
|
- (void)getBatchReportWithApplicationMethodName:(NSArray *)appChainsParams withSuccessBlock:(ReportsArray)success withFailureBlock:(void (^)(NSError *error))failure; | Reporting API |
|
Code snippet
Single App Chain retrieval example
AppChains *appChains = [[AppChains alloc] initWithToken:@"<yourAccessToken>" withHostName:@"api.sequencing.com"];
[appChains getReportWithApplicationMethodName:@"<chain id>"
withDatasourceId:@"<file id>"
withSuccessBlock:^(Report *result) {
for (Result *obj in [result getResults]) {
ResultValue *frv = [obj getValue];
if ([frv getType] == kResultTypeText) {
NSLog(@"\nvalue %@ = %@\n", [obj getName], [(TextResultValue *)frv getData]);
}
}
}
withFailureBlock:^(NSError *error) {
NSLog(@"Error occured: %@", [error description]);
}];
Batch App Chain retrieval example
AppChains *appChains = [[AppChains alloc] initWithToken:yourAccessToken withHostName:@"api.sequencing.com"];
// parameters array for batch request as example
NSArray *appChainsForRequest = @[
@[@"<chain id>", @"<file id>"],
@[@"<chain id>", @"<file id>"]
];
[appChains getBatchReportWithApplicationMethodName:appChainsForRequest
withSuccessBlock:^(NSArray *reportResultsArray) {
// @reportResultsArray - result of reports (Report object) for batch request, it's an array of dictionaries
// each dictionary has following keys: "appChainID": appChainID string, "report": *Report object
for (NSDictionary *appChainReportDict in reportResultsArray) {
Report *result = [appChainReportDict objectForKey:@"report"];
NSString *appChainID = [appChainReportDict objectForKey:@"appChainID"];
NSLog(@"\n\n appChainID: %@\n", appChainID);
for (Result *obj in [result getResults]) {
ResultValue *frv = [obj getValue];
if ([frv getType] == kResultTypeText) {
NSLog(@"\nvalue %@ = %@\n", [obj getName], [(TextResultValue *)frv getData]);
}
}
}
}
withFailureBlock:^(NSError *error) {
NSLog(@"batch request error: %@", error);
}];