Retrieve VAT liabilities
curl -X GET https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/liabilities?from=2018-06-25&to=2019-02-17 \
-H 'Authorization: Bearer HMRC_ACCESS_TOKEN' \
-H 'Accept: application/vnd.hmrc.1.0+json'
#import <CkoRest.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>
CkoRest *rest = [[CkoRest alloc] init];
BOOL success;
// URL: https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/liabilities?from=2018-06-25&to=2019-02-17
BOOL bTls = YES;
int port = 443;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"test-api.service.hmrc.gov.uk" port: [NSNumber numberWithInt: port] tls: bTls autoReconnect: bAutoReconnect];
if (success != YES) {
NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
NSLog(@"%@",rest.LastErrorText);
return;
}
[rest AddHeader: @"Authorization" value: @"Bearer HMRC_ACCESS_TOKEN"];
[rest AddHeader: @"Accept" value: @"application/vnd.hmrc.1.0+json"];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"GET" uriPath: @"/organisations/vat/MY_HMRC_VRN/liabilities?from=2018-06-25&to=2019-02-17" sb: sbResponseBody];
if (success != YES) {
NSLog(@"%@",rest.LastErrorText);
return;
}
int respStatusCode = [rest.ResponseStatusCode intValue];
if (respStatusCode >= 400) {
NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",rest.ResponseHeader);
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[sbResponseBody GetAsString]);
return;
}
CkoJsonObject *jsonResponse = [[CkoJsonObject alloc] init];
[jsonResponse LoadSb: sbResponseBody];
// See the Online Tool for Generating JSON Parse Code
int i;
int count_i;
NSString *taxPeriodFrom = 0;
NSString *taxPeriodTo = 0;
NSString *type = 0;
NSString *originalAmount = 0;
NSString *outstandingAmount = 0;
NSString *due = 0;
i = 0;
count_i = [[jsonResponse SizeOfArray: @"liabilities"] intValue];
while (i < count_i) {
jsonResponse.I = [NSNumber numberWithInt: i];
taxPeriodFrom = [jsonResponse StringOf: @"liabilities[i].taxPeriod.from"];
taxPeriodTo = [jsonResponse StringOf: @"liabilities[i].taxPeriod.to"];
type = [jsonResponse StringOf: @"liabilities[i].type"];
originalAmount = [jsonResponse StringOf: @"liabilities[i].originalAmount"];
outstandingAmount = [jsonResponse StringOf: @"liabilities[i].outstandingAmount"];
due = [jsonResponse StringOf: @"liabilities[i].due"];
i = i + 1;
}
{
"liabilities": [
{
"taxPeriod": {
"from": "2018-04-06",
"to": "2018-07-06"
},
"type": "VAT ...",
"originalAmount": 6000.3,
"outstandingAmount": 100.51,
"due": "2018-07-06"
}
]
}