Objective-C
Objective-C
Bluzone Get Project Details
See more Bluzone Examples
Get a project by its idChilkat Objective-C Downloads
#import <CkoHttp.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>
BOOL success = NO;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoHttp *http = [[CkoHttp alloc] init];
// Implements the following CURL command:
// curl -X GET \
// https://bluzone.io/portal/papis/v1/projects/YOUR_PROJECT_ID_HERE/ \
// -H 'bzid: YOUR_API_KEY_HERE'
[http SetRequestHeader: @"bzid" value: @"YOUR_API_KEY_HERE"];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [http QuickGetSb: @"https://bluzone.io/portal/papis/v1/projects/YOUR_PROJECT_ID_HERE/" sbContent: sbResponseBody];
if (success == NO) {
NSLog(@"%@",http.LastErrorText);
return;
}
CkoJsonObject *jResp = [[CkoJsonObject alloc] init];
[jResp LoadSb: sbResponseBody];
jResp.EmitCompact = NO;
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[jResp Emit]);
int respStatusCode = [http.LastStatus intValue];
NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
if (respStatusCode >= 400) {
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",http.LastHeader);
NSLog(@"%@",@"Failed.");
return;
}
// Sample JSON response:
// {
// "projectId": 36845,
// "name": "My Project",
// "description": "Default Project for admin@chilkatsoft.com, created on Thu Jun 06 17:18:11 GMT 2019.",
// "status": null,
// "owner": {
// "username": "admin@chilkatsoft.com",
// "emailAddress": null
// },
// "defaultUuidValue": "1b4b243c-59aa-405f-90b5-0c434cac1345",
// "enableLocusMaps": false,
// "mapProviderType": "GOOGLE",
// "enableAdvancedPackets": false,
// "enabledPacketTypes": "sBv2",
// "enableDataUnload": false,
// "enableScanConsumer": false,
// "enablePolicyConsumer": false,
// "enableLocationConsumer": false,
// "enableEmail": true,
// "firmwareUpdateStrategy": "MANUAL",
// "deviceJobConcurrency": -1,
// "mapProviderApiKey": null,
// "wakeupUuid": null,
// "reportEmailList": [
// ],
// "reportTimezone": "Etc/GMT",
// "language": "en",
// "blufiHostnameNaming": "DEFAULT",
// "dateCreated": 1559841491000,
// "dateUpdated": 1559841491000,
// "enableStreamProducer": true,
// "enableMetricStorage": true
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
int projectId;
NSString *name = 0;
NSString *description = 0;
NSString *status = 0;
NSString *ownerUsername = 0;
NSString *ownerEmailAddress = 0;
NSString *defaultUuidValue = 0;
BOOL enableLocusMaps;
NSString *mapProviderType = 0;
BOOL enableAdvancedPackets;
NSString *enabledPacketTypes = 0;
BOOL enableDataUnload;
BOOL enableScanConsumer;
BOOL enablePolicyConsumer;
BOOL enableLocationConsumer;
BOOL enableEmail;
NSString *firmwareUpdateStrategy = 0;
int deviceJobConcurrency;
NSString *mapProviderApiKey = 0;
NSString *wakeupUuid = 0;
NSString *reportTimezone = 0;
NSString *language = 0;
NSString *blufiHostnameNaming = 0;
int dateCreated;
int dateUpdated;
BOOL enableStreamProducer;
BOOL enableMetricStorage;
int i;
int count_i;
projectId = [[jResp IntOf: @"projectId"] intValue];
name = [jResp StringOf: @"name"];
description = [jResp StringOf: @"description"];
status = [jResp StringOf: @"status"];
ownerUsername = [jResp StringOf: @"owner.username"];
ownerEmailAddress = [jResp StringOf: @"owner.emailAddress"];
defaultUuidValue = [jResp StringOf: @"defaultUuidValue"];
enableLocusMaps = [jResp BoolOf: @"enableLocusMaps"];
mapProviderType = [jResp StringOf: @"mapProviderType"];
enableAdvancedPackets = [jResp BoolOf: @"enableAdvancedPackets"];
enabledPacketTypes = [jResp StringOf: @"enabledPacketTypes"];
enableDataUnload = [jResp BoolOf: @"enableDataUnload"];
enableScanConsumer = [jResp BoolOf: @"enableScanConsumer"];
enablePolicyConsumer = [jResp BoolOf: @"enablePolicyConsumer"];
enableLocationConsumer = [jResp BoolOf: @"enableLocationConsumer"];
enableEmail = [jResp BoolOf: @"enableEmail"];
firmwareUpdateStrategy = [jResp StringOf: @"firmwareUpdateStrategy"];
deviceJobConcurrency = [[jResp IntOf: @"deviceJobConcurrency"] intValue];
mapProviderApiKey = [jResp StringOf: @"mapProviderApiKey"];
wakeupUuid = [jResp StringOf: @"wakeupUuid"];
reportTimezone = [jResp StringOf: @"reportTimezone"];
language = [jResp StringOf: @"language"];
blufiHostnameNaming = [jResp StringOf: @"blufiHostnameNaming"];
dateCreated = [[jResp IntOf: @"dateCreated"] intValue];
dateUpdated = [[jResp IntOf: @"dateUpdated"] intValue];
enableStreamProducer = [jResp BoolOf: @"enableStreamProducer"];
enableMetricStorage = [jResp BoolOf: @"enableMetricStorage"];
i = 0;
count_i = [[jResp SizeOfArray: @"reportEmailList"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
i = i + 1;
}