Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C++) Cerved API Advanced Entity SearchThe "Advanced Entity Search" API allows you to find subjects in the Cerved database that meet specific search criteria, specified through the parameters provided as input to the service. For more information, see https://apps-developer.cerved.com/
#include <CkHttpW.h> #include <CkJsonObjectW.h> #include <CkHttpResponseW.h> #include <CkStringBuilderW.h> void ChilkatSample(void) { // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttpW http; bool success; // Implements the following CURL command: // curl -X POST \ // https://api.cerved.com/cervedApi/v1/entitySearch/advanced \ // -H 'accept: application/json' \ // -H 'apikey: ********************************' \ // -d '{ // "search_text": "string", // "activity_status_codes": [ // "A", // "C", // "D", // "F", // "I", // "L", // "N", // "P", // "R", // "S", // "T" // ], // "birth_date": "string", // "name": "string", // "subject_types": [ // "PERSON", // "INDIVIDUAL_COMPANY", // "COMPANY", // "FOREIGN", // "OTHER" // ], // "tax_code": "string", // "vat_number": "string", // "rea": { // "cciaa": "string", // "rea_number": 0 // }, // "city_istat_code": "string", // "province_code": "string" // }' // Use the following online tool to generate HTTP code from a CURL command // Convert a cURL Command to HTTP Source Code // Use this online tool to generate code from sample JSON: // Generate Code to Create JSON // The following JSON is sent in the request body. // { // "search_text": "string", // "activity_status_codes": [ // "A", // "C", // "D", // "F", // "I", // "L", // "N", // "P", // "R", // "S", // "T" // ], // "birth_date": "string", // "name": "string", // "subject_types": [ // "PERSON", // "INDIVIDUAL_COMPANY", // "COMPANY", // "FOREIGN", // "OTHER" // ], // "tax_code": "string", // "vat_number": "string", // "rea": { // "cciaa": "string", // "rea_number": 0 // }, // "city_istat_code": "string", // "province_code": "string" // } CkJsonObjectW json; // IMPORTANT: Only include the lines for the search criteria you wish to include. json.UpdateString(L"search_text",L"string"); json.UpdateString(L"activity_status_codes[0]",L"A"); json.UpdateString(L"activity_status_codes[1]",L"C"); json.UpdateString(L"activity_status_codes[2]",L"D"); json.UpdateString(L"activity_status_codes[3]",L"F"); json.UpdateString(L"activity_status_codes[4]",L"I"); json.UpdateString(L"activity_status_codes[5]",L"L"); json.UpdateString(L"activity_status_codes[6]",L"N"); json.UpdateString(L"activity_status_codes[7]",L"P"); json.UpdateString(L"activity_status_codes[8]",L"R"); json.UpdateString(L"activity_status_codes[9]",L"S"); json.UpdateString(L"activity_status_codes[10]",L"T"); json.UpdateString(L"birth_date",L"string"); json.UpdateString(L"name",L"string"); json.UpdateString(L"subject_types[0]",L"PERSON"); json.UpdateString(L"subject_types[1]",L"INDIVIDUAL_COMPANY"); json.UpdateString(L"subject_types[2]",L"COMPANY"); json.UpdateString(L"subject_types[3]",L"FOREIGN"); json.UpdateString(L"subject_types[4]",L"OTHER"); json.UpdateString(L"tax_code",L"string"); json.UpdateString(L"vat_number",L"string"); json.UpdateString(L"rea.cciaa",L"string"); json.UpdateInt(L"rea.rea_number",0); json.UpdateString(L"city_istat_code",L"string"); json.UpdateString(L"province_code",L"string"); http.SetRequestHeader(L"accept",L"application/json"); http.SetRequestHeader(L"apikey",L"********************************"); CkHttpResponseW *resp = http.PostJson3(L"https://api.cerved.com/cervedApi/v1/entitySearch/advanced",L"application/json",json); if (http.get_LastMethodSuccess() == false) { wprintf(L"%s\n",http.lastErrorText()); return; } CkStringBuilderW sbResponseBody; resp->GetBodySb(sbResponseBody); CkJsonObjectW jResp; jResp.LoadSb(sbResponseBody); jResp.put_EmitCompact(false); wprintf(L"Response Body:\n"); wprintf(L"%s\n",jResp.emit()); int respStatusCode = resp->get_StatusCode(); wprintf(L"Response Status Code = %d\n",respStatusCode); if (respStatusCode >= 400) { wprintf(L"Response Header:\n"); wprintf(L"%s\n",resp->header()); wprintf(L"Failed.\n"); delete resp; return; } delete resp; // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "subjects": [ // { // "subject_id": "string", // "subject_type": "string", // "tax_code": "string", // "address": { // "street": { // "description": "string" // }, // "city": { // "code": "string", // "istat_code": "string", // "description": "string" // }, // "province": { // "code": "string", // "description": "string" // }, // "postal_code": "string", // "country": { // "code": "string", // "description": "string" // } // }, // "company_info": { // "legal_form": { // "code": "string", // "description": "string", // "class_code": "string" // }, // "activity_status": { // "code": "string", // "description": "string" // }, // "business_name": "string", // "economic_activity": { // "ateco": { // "code": "string", // "description": "string" // } // }, // "head_office": "true", // "lei_code": "string", // "operational_flag": "true", // "public_administration": { // "pa_subject": "true", // "pa_supplier": "true", // "pa_owned": "true" // }, // "rea_code": { // "cciaa": "string", // "rea_number": 0, // "registration_date": "string" // }, // "vat_number": "string", // "no_rea_data": { // "form_code": "string", // "form_description": "string" // } // }, // "person_info": { // "first_name": "string", // "last_name": "string", // "name": "string", // "birth_date": "string", // "birth_place": { // "street": { // "description": "string" // }, // "city": { // "code": "string", // "istat_code": "string", // "description": "string" // }, // "province": { // "code": "string", // "description": "string" // }, // "postal_code": "string", // "country": { // "code": "string", // "description": "string" // } // } // } // } // ], // "subjects_total_number": 0 // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat. // See this example explaining how this memory should be used: const char * functions. const wchar_t *subject_id = 0; const wchar_t *subject_type = 0; const wchar_t *tax_code = 0; const wchar_t *addressStreetDescription = 0; const wchar_t *addressCityCode = 0; const wchar_t *addressCityIstat_code = 0; const wchar_t *addressCityDescription = 0; const wchar_t *addressProvinceCode = 0; const wchar_t *addressProvinceDescription = 0; const wchar_t *addressPostal_code = 0; const wchar_t *addressCountryCode = 0; const wchar_t *addressCountryDescription = 0; const wchar_t *company_infoLegal_formCode = 0; const wchar_t *company_infoLegal_formDescription = 0; const wchar_t *company_infoLegal_formClass_code = 0; const wchar_t *company_infoActivity_statusCode = 0; const wchar_t *company_infoActivity_statusDescription = 0; const wchar_t *company_infoBusiness_name = 0; const wchar_t *company_infoEconomic_activityAtecoCode = 0; const wchar_t *company_infoEconomic_activityAtecoDescription = 0; const wchar_t *company_infoHead_office = 0; const wchar_t *company_infoLei_code = 0; const wchar_t *company_infoOperational_flag = 0; const wchar_t *company_infoPublic_administrationPa_subject = 0; const wchar_t *company_infoPublic_administrationPa_supplier = 0; const wchar_t *company_infoPublic_administrationPa_owned = 0; const wchar_t *company_infoRea_codeCciaa = 0; int company_infoRea_codeRea_number; const wchar_t *company_infoRea_codeRegistration_date = 0; const wchar_t *company_infoVat_number = 0; const wchar_t *company_infoNo_rea_dataForm_code = 0; const wchar_t *company_infoNo_rea_dataForm_description = 0; const wchar_t *person_infoFirst_name = 0; const wchar_t *person_infoLast_name = 0; const wchar_t *person_infoName = 0; const wchar_t *person_infoBirth_date = 0; const wchar_t *person_infoBirth_placeStreetDescription = 0; const wchar_t *person_infoBirth_placeCityCode = 0; const wchar_t *person_infoBirth_placeCityIstat_code = 0; const wchar_t *person_infoBirth_placeCityDescription = 0; const wchar_t *person_infoBirth_placeProvinceCode = 0; const wchar_t *person_infoBirth_placeProvinceDescription = 0; const wchar_t *person_infoBirth_placePostal_code = 0; const wchar_t *person_infoBirth_placeCountryCode = 0; const wchar_t *person_infoBirth_placeCountryDescription = 0; int subjects_total_number = jResp.IntOf(L"subjects_total_number"); int i = 0; int count_i = jResp.SizeOfArray(L"subjects"); while (i < count_i) { jResp.put_I(i); subject_id = jResp.stringOf(L"subjects[i].subject_id"); subject_type = jResp.stringOf(L"subjects[i].subject_type"); tax_code = jResp.stringOf(L"subjects[i].tax_code"); addressStreetDescription = jResp.stringOf(L"subjects[i].address.street.description"); addressCityCode = jResp.stringOf(L"subjects[i].address.city.code"); addressCityIstat_code = jResp.stringOf(L"subjects[i].address.city.istat_code"); addressCityDescription = jResp.stringOf(L"subjects[i].address.city.description"); addressProvinceCode = jResp.stringOf(L"subjects[i].address.province.code"); addressProvinceDescription = jResp.stringOf(L"subjects[i].address.province.description"); addressPostal_code = jResp.stringOf(L"subjects[i].address.postal_code"); addressCountryCode = jResp.stringOf(L"subjects[i].address.country.code"); addressCountryDescription = jResp.stringOf(L"subjects[i].address.country.description"); company_infoLegal_formCode = jResp.stringOf(L"subjects[i].company_info.legal_form.code"); company_infoLegal_formDescription = jResp.stringOf(L"subjects[i].company_info.legal_form.description"); company_infoLegal_formClass_code = jResp.stringOf(L"subjects[i].company_info.legal_form.class_code"); company_infoActivity_statusCode = jResp.stringOf(L"subjects[i].company_info.activity_status.code"); company_infoActivity_statusDescription = jResp.stringOf(L"subjects[i].company_info.activity_status.description"); company_infoBusiness_name = jResp.stringOf(L"subjects[i].company_info.business_name"); company_infoEconomic_activityAtecoCode = jResp.stringOf(L"subjects[i].company_info.economic_activity.ateco.code"); company_infoEconomic_activityAtecoDescription = jResp.stringOf(L"subjects[i].company_info.economic_activity.ateco.description"); company_infoHead_office = jResp.stringOf(L"subjects[i].company_info.head_office"); company_infoLei_code = jResp.stringOf(L"subjects[i].company_info.lei_code"); company_infoOperational_flag = jResp.stringOf(L"subjects[i].company_info.operational_flag"); company_infoPublic_administrationPa_subject = jResp.stringOf(L"subjects[i].company_info.public_administration.pa_subject"); company_infoPublic_administrationPa_supplier = jResp.stringOf(L"subjects[i].company_info.public_administration.pa_supplier"); company_infoPublic_administrationPa_owned = jResp.stringOf(L"subjects[i].company_info.public_administration.pa_owned"); company_infoRea_codeCciaa = jResp.stringOf(L"subjects[i].company_info.rea_code.cciaa"); company_infoRea_codeRea_number = jResp.IntOf(L"subjects[i].company_info.rea_code.rea_number"); company_infoRea_codeRegistration_date = jResp.stringOf(L"subjects[i].company_info.rea_code.registration_date"); company_infoVat_number = jResp.stringOf(L"subjects[i].company_info.vat_number"); company_infoNo_rea_dataForm_code = jResp.stringOf(L"subjects[i].company_info.no_rea_data.form_code"); company_infoNo_rea_dataForm_description = jResp.stringOf(L"subjects[i].company_info.no_rea_data.form_description"); person_infoFirst_name = jResp.stringOf(L"subjects[i].person_info.first_name"); person_infoLast_name = jResp.stringOf(L"subjects[i].person_info.last_name"); person_infoName = jResp.stringOf(L"subjects[i].person_info.name"); person_infoBirth_date = jResp.stringOf(L"subjects[i].person_info.birth_date"); person_infoBirth_placeStreetDescription = jResp.stringOf(L"subjects[i].person_info.birth_place.street.description"); person_infoBirth_placeCityCode = jResp.stringOf(L"subjects[i].person_info.birth_place.city.code"); person_infoBirth_placeCityIstat_code = jResp.stringOf(L"subjects[i].person_info.birth_place.city.istat_code"); person_infoBirth_placeCityDescription = jResp.stringOf(L"subjects[i].person_info.birth_place.city.description"); person_infoBirth_placeProvinceCode = jResp.stringOf(L"subjects[i].person_info.birth_place.province.code"); person_infoBirth_placeProvinceDescription = jResp.stringOf(L"subjects[i].person_info.birth_place.province.description"); person_infoBirth_placePostal_code = jResp.stringOf(L"subjects[i].person_info.birth_place.postal_code"); person_infoBirth_placeCountryCode = jResp.stringOf(L"subjects[i].person_info.birth_place.country.code"); person_infoBirth_placeCountryDescription = jResp.stringOf(L"subjects[i].person_info.birth_place.country.description"); i = i + 1; } } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.