Back to Collection Items
#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoHttpResponse.h>
#import <CkoStringBuilder.h>
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoHttp *http = [[CkoHttp alloc] init];
BOOL success;
CkoJsonObject *queryParams = [[CkoJsonObject alloc] init];
[queryParams UpdateString: @"start_date" value: @"2019-01-01"];
[queryParams UpdateString: @"end_date" value: @"2019-12-31"];
[queryParams UpdateString: @"currency_code" value: @"USD"];
[queryParams UpdateInt: @"clientids" value: [NSNumber numberWithInt: 31006]];
[queryParams UpdateString: @"item_names" value: @"Fanny Pack"];
[queryParams UpdateString: @"statusids" value: @"paid"];
// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = @"<access_token>";
CkoHttpResponse *resp = [http QuickRequestParams: @"GET" url: @"https://api.freshbooks.com/accounting/account/wkMd2g/reports/accounting/item_sales" json: queryParams];
if (http.LastMethodSuccess == NO) {
NSLog(@"%@",http.LastErrorText);
return;
}
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
[resp GetBodySb: sbResponseBody];
CkoJsonObject *jResp = [[CkoJsonObject alloc] init];
[jResp LoadSb: sbResponseBody];
jResp.EmitCompact = NO;
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[jResp Emit]);
int respStatusCode = [resp.StatusCode intValue];
NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
if (respStatusCode >= 400) {
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",resp.Header);
NSLog(@"%@",@"Failed.");
return;
}
Curl Command
curl -G -d "start_date=2019-01-01"
-d "end_date=2019-12-31"
-d "currency_code=USD"
-d "clientids=31006"
-d "item_names=Fanny%20Pack"
-d "statusids=paid"
-H "Authorization: Bearer <access_token>"
https://api.freshbooks.com/accounting/account/wkMd2g/reports/accounting/item_sales
Postman Collection Item JSON
{
"name": "Item Sales",
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.freshbooks.com/accounting/account/wkMd2g/reports/accounting/item_sales?start_date=2019-01-01&end_date=2019-12-31¤cy_code=USD&clientids=31006&item_names=Fanny Pack&statusids=paid",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"accounting",
"account",
"wkMd2g",
"reports",
"accounting",
"item_sales"
],
"query": [
{
"key": "start_date",
"value": "2019-01-01",
"description": "created during or after the given date i.e. `2019-01-01`"
},
{
"key": "end_date",
"value": "2019-12-31",
"description": "created during or before the given date i.e. `2019-12-31`"
},
{
"key": "currency_code",
"value": "USD"
},
{
"key": "clientids",
"value": "31006"
},
{
"key": "item_names",
"value": "Fanny Pack"
},
{
"key": "statusids",
"value": "paid"
}
]
},
"description": "See how much money you're making from each item to sell."
},
"response": [
{
"name": "Item Sales",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.freshbooks.com/accounting/account/wkMd2g/reports/accounting/item_sales?start_date=2019-01-01&end_date=2019-12-31¤cy_code=USD&clientids=31006&item_names=Fanny Pack&statusids=paid",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"accounting",
"account",
"wkMd2g",
"reports",
"accounting",
"item_sales"
],
"query": [
{
"key": "start_date",
"value": "2019-01-01",
"description": "created during or after the given date i.e. `2019-01-01`"
},
{
"key": "end_date",
"value": "2019-12-31",
"description": "created during or before the given date i.e. `2019-12-31`"
},
{
"key": "currency_code",
"value": "USD"
},
{
"key": "clientids",
"value": "31006"
},
{
"key": "item_names",
"value": "Fanny Pack"
},
{
"key": "statusids",
"value": "paid"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "nginx"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "X-NewRelic-App-Data",
"value": "PxQBWV5TCBABVlVSAwEOVlcTGhE1AwE2QgNWEVlbQFtcCxYnRA9QFg1ZWU4DFVdfRgFPCkNFR0gWVEZcEBIQWFEBWw1NVkBbXQJLBEEOQRYXFBtRSlMWAgBTU1UDAQJTUAkGCldRU1EcTwlOGgkMBVJTXVZUUQdbUQAEVF9BFFVRCBIHag=="
},
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Expires",
"value": "Tue, 24 Apr 2018 18:30:47 GMT"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Via",
"value": "1.1 google"
},
{
"key": "Via",
"value": "1.1 varnish"
},
{
"key": "Accept-Ranges",
"value": "bytes"
},
{
"key": "Accept-Ranges",
"value": "bytes"
},
{
"key": "Age",
"value": "0"
},
{
"key": "Age",
"value": "0"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
},
{
"key": "Date",
"value": "Wed, 24 Apr 2019 18:30:47 GMT"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "X-Served-By",
"value": "cache-mdw17369-MDW"
},
{
"key": "X-Cache",
"value": "MISS"
},
{
"key": "X-Cache-Hits",
"value": "0"
},
{
"key": "Vary",
"value": "Accept-Encoding"
},
{
"key": "Country",
"value": "CA"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=31536000; includeSubDomains; preload"
}
],
"cookie": [
],
"body": "{\n \"response\": {\n \"result\": {\n \"item_sales\": {\n \"clientids\": [],\n \"company_name\": \"Postman Sandbox\",\n \"currency_code\": \"USD\",\n \"download_token\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50aWQiOiJ3a01kMmciLCJ1c2VyaWQiOjEsImNvbnRhY3RpZCI6LTEsImxldmVsIjozLCJ0eXBlIjoicmVwb3J0Iiwib2JqZWN0aWQiOiJpdGVtX3NhbGVzIiwicGFyYW1zIjp7InN0YXJ0X2RhdGUiOiIyMDE5LTAxLTAxIiwiZW5kX2RhdGUiOiIyMDE5LTEyLTMxIiwiY3VycmVuY3lfY29kZSI6IlVTRCIsImNsaWVudGlkcyI6bnVsbCwic3RhdHVzaWRzIjpbXSwiaXRlbV9uYW1lcyI6W119LCJpYXQiOjE1NTYxMzA2NDcsImV4cCI6MTU1ODcyMjY0N30.h4AnC-DagiYu5Qp-qdFfa7DD5lZVJmYbUEnWTbuKoQc\",\n \"end_date\": \"2019-12-31\",\n \"item_names\": [],\n \"items\": [\n {\n \"invoices\": [\n {\n \"amount\": {\n \"amount\": \"2800.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Nicolas\",\n \"invoice_number\": \"0000005\",\n \"invoiceid\": 26398,\n \"lname\": \"one\",\n \"organization\": \"first company\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"2800.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"overdue\"\n },\n {\n \"amount\": {\n \"amount\": \"2800.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Nicolas\",\n \"invoice_number\": \"0000008\",\n \"invoiceid\": 28006,\n \"lname\": \"one\",\n \"organization\": \"first company\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"2800.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"draft\"\n }\n ],\n \"name\": \"Acting Services\",\n \"total\": {\n \"amount\": \"5600.00\",\n \"code\": \"USD\"\n },\n \"total_discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"total_qty\": \"2\"\n },\n {\n \"invoices\": [\n {\n \"amount\": {\n \"amount\": \"100.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Beaufort\",\n \"invoice_number\": \"0000010\",\n \"invoiceid\": 29610,\n \"lname\": \"Michelin\",\n \"organization\": \"Witting, McDermott and Gutmann\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"100.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"draft\"\n },\n {\n \"amount\": {\n \"amount\": \"100.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Tarra\",\n \"invoice_number\": \"0000011\",\n \"invoiceid\": 29616,\n \"lname\": \"Arblaster\",\n \"organization\": \"Hermann-Jast\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"100.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"draft\"\n },\n {\n \"amount\": {\n \"amount\": \"100.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Nicolas\",\n \"invoice_number\": \"0000012\",\n \"invoiceid\": 29618,\n \"lname\": \"one\",\n \"organization\": \"first company\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"100.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"overdue\"\n },\n {\n \"amount\": {\n \"amount\": \"100.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Nicolas\",\n \"invoice_number\": \"0000013\",\n \"invoiceid\": 34420,\n \"lname\": \"one\",\n \"organization\": \"first company\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"100.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"paid\"\n }\n ],\n \"name\": \"Belay Device\",\n \"total\": {\n \"amount\": \"400.00\",\n \"code\": \"USD\"\n },\n \"total_discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"total_qty\": \"4\"\n },\n {\n \"invoices\": [\n {\n \"amount\": {\n \"amount\": \"500.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Nicolas\",\n \"invoice_number\": \"0000005\",\n \"invoiceid\": 26398,\n \"lname\": \"one\",\n \"organization\": \"first company\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"500.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"overdue\"\n }\n ],\n \"name\": \"Celebration\",\n \"total\": {\n \"amount\": \"500.00\",\n \"code\": \"USD\"\n },\n \"total_discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"total_qty\": \"1\"\n },\n {\n \"invoices\": [\n {\n \"amount\": {\n \"amount\": \"500.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Nicolas\",\n \"invoice_number\": \"0000008\",\n \"invoiceid\": 28006,\n \"lname\": \"one\",\n \"organization\": \"first company\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"500.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"draft\"\n },\n {\n \"amount\": {\n \"amount\": \"80.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Beaufort\",\n \"invoice_number\": \"0000010\",\n \"invoiceid\": 29610,\n \"lname\": \"Michelin\",\n \"organization\": \"Witting, McDermott and Gutmann\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"80.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"draft\"\n },\n {\n \"amount\": {\n \"amount\": \"80.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Tarra\",\n \"invoice_number\": \"0000011\",\n \"invoiceid\": 29616,\n \"lname\": \"Arblaster\",\n \"organization\": \"Hermann-Jast\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"80.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"draft\"\n },\n {\n \"amount\": {\n \"amount\": \"80.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Nicolas\",\n \"invoice_number\": \"0000012\",\n \"invoiceid\": 29618,\n \"lname\": \"one\",\n \"organization\": \"first company\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"80.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"overdue\"\n },\n {\n \"amount\": {\n \"amount\": \"80.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Nicolas\",\n \"invoice_number\": \"0000013\",\n \"invoiceid\": 34420,\n \"lname\": \"one\",\n \"organization\": \"first company\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"80.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"paid\"\n }\n ],\n \"name\": \"Climbing Helmet\",\n \"total\": {\n \"amount\": \"820.00\",\n \"code\": \"USD\"\n },\n \"total_discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"total_qty\": \"5\"\n },\n {\n \"invoices\": [\n {\n \"amount\": {\n \"amount\": \"500.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-18\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Nicolas\",\n \"invoice_number\": \"0000001\",\n \"invoiceid\": 24042,\n \"lname\": \"one\",\n \"organization\": \"first company\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"500.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"sent\"\n }\n ],\n \"name\": \"Computer Hardware\",\n \"total\": {\n \"amount\": \"500.00\",\n \"code\": \"USD\"\n },\n \"total_discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"total_qty\": \"1\"\n },\n {\n \"invoices\": [\n {\n \"amount\": {\n \"amount\": \"500.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-18\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Nicolas\",\n \"invoice_number\": \"0000001\",\n \"invoiceid\": 24042,\n \"lname\": \"one\",\n \"organization\": \"first company\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"500.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"sent\"\n }\n ],\n \"name\": \"Computer Hardware 1\",\n \"total\": {\n \"amount\": \"500.00\",\n \"code\": \"USD\"\n },\n \"total_discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"total_qty\": \"1\"\n },\n {\n \"invoices\": [\n {\n \"amount\": {\n \"amount\": \"50.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-19\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Myrta\",\n \"invoice_number\": \"0000003\",\n \"invoiceid\": 26250,\n \"lname\": \"Westhofer\",\n \"organization\": \"Prosacco Group\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"50.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"paid\"\n },\n {\n \"amount\": {\n \"amount\": \"50.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Myrta\",\n \"invoice_number\": \"0000007\",\n \"invoiceid\": 28002,\n \"lname\": \"Westhofer\",\n \"organization\": \"Prosacco Group\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"50.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"draft\"\n }\n ],\n \"name\": \"Fanny Pack\",\n \"total\": {\n \"amount\": \"100.00\",\n \"code\": \"USD\"\n },\n \"total_discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"total_qty\": \"2\"\n },\n {\n \"invoices\": [\n {\n \"amount\": {\n \"amount\": \"5000.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Nicolas\",\n \"invoice_number\": \"0000002\",\n \"invoiceid\": 24068,\n \"lname\": \"one\",\n \"organization\": \"first company\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"5000.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"paid\"\n },\n {\n \"amount\": {\n \"amount\": \"4100.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Nicolas\",\n \"invoice_number\": \"0000004\",\n \"invoiceid\": 26384,\n \"lname\": \"one\",\n \"organization\": \"first company\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"4100.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"draft\"\n }\n ],\n \"name\": \"Paperwork\",\n \"total\": {\n \"amount\": \"9100.00\",\n \"code\": \"USD\"\n },\n \"total_discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"total_qty\": \"2\"\n },\n {\n \"invoices\": [\n {\n \"amount\": {\n \"amount\": \"3000.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Nicolas\",\n \"invoice_number\": \"0000002\",\n \"invoiceid\": 24068,\n \"lname\": \"one\",\n \"organization\": \"first company\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"3000.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"paid\"\n },\n {\n \"amount\": {\n \"amount\": \"2800.00\",\n \"code\": \"USD\"\n },\n \"create_date\": \"2019-04-20\",\n \"discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"fname\": \"Nicolas\",\n \"invoice_number\": \"0000004\",\n \"invoiceid\": 26384,\n \"lname\": \"one\",\n \"organization\": \"first company\",\n \"qty\": \"1\",\n \"unit_cost\": {\n \"amount\": \"2800.00\",\n \"code\": \"USD\"\n },\n \"v3_status\": \"draft\"\n }\n ],\n \"name\": \"TV Ads\",\n \"total\": {\n \"amount\": \"5800.00\",\n \"code\": \"USD\"\n },\n \"total_discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"total_qty\": \"2\"\n }\n ],\n \"start_date\": \"2019-01-01\",\n \"statusids\": [],\n \"total\": {\n \"amount\": \"23320.00\",\n \"code\": \"USD\"\n },\n \"total_discount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"total_qty\": \"20\"\n }\n }\n }\n}"
}
]
}