Create a CustomsInfo object.
curl -X POST https://api.easypost.com/v2/customs_infos \
-u <YOUR_TEST/PRODUCTION_API_KEY>: \
-d 'customs_info[customs_certify]=true' \
-d 'customs_info[customs_signer]=Steve Brule' \
-d 'customs_info[contents_type]=merchandise' \
-d 'customs_info[contents_explanation]=' \
-d 'customs_info[restriction_type]=none' \
-d 'customs_info[eel_pfc]=NOEEI 30.37(a)' \
-d 'customs_info[customs_items][0][id]=cstitem_...' \
-d 'customs_info[customs_items][1][description]=Sweet shirts' \
-d 'customs_info[customs_items][1][quantity]=2' \
-d 'customs_info[customs_items][1][value]=23' \
-d 'customs_info[customs_items][1][weight]=11' \
-d 'customs_info[customs_items][1][hs_tariff_number]=654321' \
-d 'customs_info[customs_items][1][origin_country]=US'
var
rest: HCkRest;
success: Boolean;
bTls: Boolean;
port: Integer;
bAutoReconnect: Boolean;
strResponseBody: PWideChar;
jsonResponse: HCkJsonObject;
id: PWideChar;
object: PWideChar;
contents_explanation: Boolean;
contents_type: PWideChar;
customs_certify: Boolean;
customs_signer: PWideChar;
eel_pfc: PWideChar;
non_delivery_option: PWideChar;
restriction_comments: Boolean;
restriction_type: PWideChar;
created_at: PWideChar;
updated_at: PWideChar;
i: Integer;
count_i: Integer;
description: PWideChar;
hs_tariff_number: PWideChar;
origin_country: PWideChar;
quantity: Integer;
value: Integer;
weight: Integer;
begin
rest := CkRest_Create();
// URL: https://api.easypost.com/v2/customs_infos
bTls := True;
port := 443;
bAutoReconnect := True;
success := CkRest_Connect(rest,'api.easypost.com',port,bTls,bAutoReconnect);
if (success <> True) then
begin
Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(CkRest_getConnectFailReason(rest)));
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
CkRest_SetAuthBasic(rest,'<YOUR_TEST/PRODUCTION_API_KEY>','');
CkRest_AddQueryParam(rest,'customs_info[customs_certify]','true');
CkRest_AddQueryParam(rest,'customs_info[customs_signer]','Steve Brule');
CkRest_AddQueryParam(rest,'customs_info[contents_type]','merchandise');
CkRest_AddQueryParam(rest,'customs_info[contents_explanation]','');
CkRest_AddQueryParam(rest,'customs_info[restriction_type]','none');
CkRest_AddQueryParam(rest,'customs_info[eel_pfc]','NOEEI 30.37(a)');
CkRest_AddQueryParam(rest,'customs_info[customs_items][0][id]','cstitem_...');
CkRest_AddQueryParam(rest,'customs_info[customs_items][1][description]','Sweet shirts');
CkRest_AddQueryParam(rest,'customs_info[customs_items][1][quantity]','2');
CkRest_AddQueryParam(rest,'customs_info[customs_items][1][value]','23');
CkRest_AddQueryParam(rest,'customs_info[customs_items][1][weight]','11');
CkRest_AddQueryParam(rest,'customs_info[customs_items][1][hs_tariff_number]','654321');
CkRest_AddQueryParam(rest,'customs_info[customs_items][1][origin_country]','US');
strResponseBody := CkRest__fullRequestFormUrlEncoded(rest,'POST','/v2/customs_infos');
if (CkRest_getLastMethodSuccess(rest) <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
jsonResponse := CkJsonObject_Create();
CkJsonObject_Load(jsonResponse,strResponseBody);
id := CkJsonObject__stringOf(jsonResponse,'id');
object := CkJsonObject__stringOf(jsonResponse,'object');
contents_explanation := CkJsonObject_IsNullOf(jsonResponse,'contents_explanation');
contents_type := CkJsonObject__stringOf(jsonResponse,'contents_type');
customs_certify := CkJsonObject_BoolOf(jsonResponse,'customs_certify');
customs_signer := CkJsonObject__stringOf(jsonResponse,'customs_signer');
eel_pfc := CkJsonObject__stringOf(jsonResponse,'eel_pfc');
non_delivery_option := CkJsonObject__stringOf(jsonResponse,'non_delivery_option');
restriction_comments := CkJsonObject_IsNullOf(jsonResponse,'restriction_comments');
restriction_type := CkJsonObject__stringOf(jsonResponse,'restriction_type');
created_at := CkJsonObject__stringOf(jsonResponse,'created_at');
updated_at := CkJsonObject__stringOf(jsonResponse,'updated_at');
i := 0;
count_i := CkJsonObject_SizeOfArray(jsonResponse,'customs_items');
while i < count_i do
begin
CkJsonObject_putI(jsonResponse,i);
id := CkJsonObject__stringOf(jsonResponse,'customs_items[i].id');
object := CkJsonObject__stringOf(jsonResponse,'customs_items[i].object');
description := CkJsonObject__stringOf(jsonResponse,'customs_items[i].description');
hs_tariff_number := CkJsonObject__stringOf(jsonResponse,'customs_items[i].hs_tariff_number');
origin_country := CkJsonObject__stringOf(jsonResponse,'customs_items[i].origin_country');
quantity := CkJsonObject_IntOf(jsonResponse,'customs_items[i].quantity');
value := CkJsonObject_IntOf(jsonResponse,'customs_items[i].value');
weight := CkJsonObject_IntOf(jsonResponse,'customs_items[i].weight');
created_at := CkJsonObject__stringOf(jsonResponse,'customs_items[i].created_at');
updated_at := CkJsonObject__stringOf(jsonResponse,'customs_items[i].updated_at');
i := i + 1;
end;
CkRest_Dispose(rest);
CkJsonObject_Dispose(jsonResponse);
{
"id": "cstinfo_zN5tbjEd",
"object": "CustomsInfo",
"contents_explanation": null,
"contents_type": "merchandise",
"customs_certify": true,
"customs_signer": "Steve Brule",
"eel_pfc": "NOEEI 30.37(a)",
"non_delivery_option": "return",
"restriction_comments": null,
"restriction_type": "none",
"customs_items": [
{
"id": "cstitem_OpPpXeny",
"object": "CustomsItem",
"description": "T-Shirt",
"hs_tariff_number": "123456",
"origin_country": "US",
"quantity": 1,
"value": 10,
"weight": 5,
"created_at": "2013-04-22T07:17:51Z",
"updated_at": "2013-04-22T07:17:51Z"
},
{
"id": "cstitem_VklGOHPs",
"object": "CustomsItem",
"description": "Sweet shirts",
"hs_tariff_number": "654321",
"origin_country": "US",
"quantity": 2,
"value": 23,
"weight": 11,
"created_at": "2013-04-22T07:17:51Z",
"updated_at": "2013-04-22T07:17:51Z"
}
],
"created_at": "2013-04-22T07:17:51Z",
"updated_at": "2013-04-22T07:17:51Z"
}