Chilkat Online Tools

Objective-C / Egyptian eInvoicing SDK R1.5 / 5.1 Request Document Package as intermediary

Back to Collection Items

#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoHttpResponse.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;

// Use this online tool to generate code from sample JSON: Generate Code to Create JSON

// The following JSON is sent in the request body.

// {
//   "type": "Full",
//   "format": "XML",
//   "queryParameters": {
//     "dateFrom": "2021-01-01T00:00:00.000Z",
//     "dateTo": "2021-01-31T00:00:00.000Z",
//     "statuses": [
//       "Valid"
//     ],
//     "productsInternalCodes": [
//     ],
//     "receiverSenderType": "0",
//     "documentTypeNames": [
//       "C",
//       "D",
//       "I"
//     ],
//     "representedTaxpayerFilterType": "1",
//     "representeeRin": "",
//     "branchNumber": "",
//     "itemCodes": [
//       {
//         "codeValue": "",
//         "codeType": ""
//       }
//     ]
//   }
// }

CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"type" value: @"Full"];
[json UpdateString: @"format" value: @"XML"];
[json UpdateString: @"queryParameters.dateFrom" value: @"2021-01-01T00:00:00.000Z"];
[json UpdateString: @"queryParameters.dateTo" value: @"2021-01-31T00:00:00.000Z"];
[json UpdateString: @"queryParameters.statuses[0]" value: @"Valid"];
[json UpdateNewArray: @"queryParameters.productsInternalCodes"];
[json UpdateString: @"queryParameters.receiverSenderType" value: @"0"];
[json UpdateString: @"queryParameters.documentTypeNames[0]" value: @"C"];
[json UpdateString: @"queryParameters.documentTypeNames[1]" value: @"D"];
[json UpdateString: @"queryParameters.documentTypeNames[2]" value: @"I"];
[json UpdateString: @"queryParameters.representedTaxpayerFilterType" value: @"1"];
[json UpdateString: @"queryParameters.representeeRin" value: @""];
[json UpdateString: @"queryParameters.branchNumber" value: @""];
[json UpdateString: @"queryParameters.itemCodes[0].codeValue" value: @""];
[json UpdateString: @"queryParameters.itemCodes[0].codeType" value: @""];

// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = @"<access_token>";

CkoHttpResponse *resp = [http PostJson3: @"https://domain.com/api/v1/documentPackages/requests" contentType: @"application/json" json: json];
if (http.LastMethodSuccess == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

NSLog(@"%d",[resp.StatusCode intValue]);
NSLog(@"%@",resp.BodyStr);

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-d '{
    "type": "Full",
    "format": "XML",
    "queryParameters": {
        "dateFrom": "2021-01-01T00:00:00.000Z",
        "dateTo": "2021-01-31T00:00:00.000Z",
        "statuses": [
            "Valid"
        ],
        "productsInternalCodes": [],
        "receiverSenderType": "0",
        "documentTypeNames": [
            "C",
            "D",
            "I"
        ],
        "representedTaxpayerFilterType": "1",
        "representeeRin": "",
        "branchNumber": "",
        "itemCodes": [
            {
                "codeValue": "",
                "codeType": ""
            }
        ]
    }
}'
https://domain.com/api/v1/documentPackages/requests

Postman Collection Item JSON

{
  "name": "5.1 Request Document Package as intermediary",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{generatedAccessToken}}",
          "type": "string"
        }
      ]
    },
    "method": "POST",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "{\r\n    \"type\": \"Full\",\r\n    \"format\": \"XML\",\r\n    \"queryParameters\": {\r\n        \"dateFrom\": \"2021-01-01T00:00:00.000Z\",\r\n        \"dateTo\": \"2021-01-31T00:00:00.000Z\",\r\n        \"statuses\": [\r\n            \"Valid\"\r\n        ],\r\n        \"productsInternalCodes\": [],\r\n        \"receiverSenderType\": \"0\",\r\n        \"documentTypeNames\": [\r\n            \"C\",\r\n            \"D\",\r\n            \"I\"\r\n        ],\r\n        \"representedTaxpayerFilterType\": \"1\",\r\n        \"representeeRin\": \"\",\r\n        \"branchNumber\": \"\",\r\n        \"itemCodes\": [\r\n            {\r\n                \"codeValue\": \"\",\r\n                \"codeType\": \"\"\r\n            }\r\n        ]\r\n    }\r\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{apiBaseUrl}}/api/v1/documentPackages/requests",
      "host": [
        "{{apiBaseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "documentPackages",
        "requests"
      ]
    }
  },
  "response": [
  ]
}