Chilkat Online Tools

Node.js / Belvo API Docs / Detail

Back to Collection Items

var os = require('os');
if (os.platform() == 'win32') {  
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node21-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node21-win64'); 
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node21-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node21-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node21-linux64');
    }
} else if (os.platform() == 'darwin') {
    if (os.arch() == 'arm64') {
        var chilkat = require('@chilkat/ck-node21-mac-m1');
    } else {
        var chilkat = require('@chilkat/ck-node21-macosx');
    }
}


function chilkatExample() {

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    var http = new chilkat.Http();
    var success;

    http.BasicAuth = true;
    http.Login = "{{secretId}}";
    http.Password = "{{secretPassword}}";

    var sbResponseBody = new chilkat.StringBuilder();
    success = http.QuickGetSb("https://domain.com/api/tax-status/:id/",sbResponseBody);
    if (success == false) {
        console.log(http.LastErrorText);
        return;
    }

    var jResp = new chilkat.JsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.EmitCompact = false;

    console.log("Response Body:");
    console.log(jResp.Emit());

    var respStatusCode = http.LastStatus;
    console.log("Response Status Code = " + respStatusCode);
    if (respStatusCode >= 400) {
        console.log("Response Header:");
        console.log(http.LastHeader);
        console.log("Failed.");
        return;
    }

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "id": "<uuid>",
    //   "link": "<uuid>",
    //   "collected_at": "<dateTime>",
    //   "place_and_date_of_issuance": "<string>",
    //   "official_name": "<string>",
    //   "id_cif": "<string>",
    //   "tax_payer_information": {
    //     "rfc": "<string>",
    //     "curp": "<string>",
    //     "name": "<string>",
    //     "first_last_name": "<string>",
    //     "second_last_name": "<string>",
    //     "start_operations_date": "<string>",
    //     "status_padron": "<string>",
    //     "last_status_change_date": "<string>",
    //     "commercial_name": "<string>",
    //     "social_name": "<string>",
    //     "email": "<string>",
    //     "phone": "<string>"
    //   },
    //   "address": {
    //     "postal_code": "<string>",
    //     "street_type": "<string>",
    //     "street": "<string>",
    //     "exterior_number": "<string>",
    //     "interior_number": "<string>",
    //     "suburb": "<string>",
    //     "locality": "<string>",
    //     "municipality": "<string>",
    //     "state": "<string>",
    //     "between_street": {
    //       "value": "<Error: Too many levels of nesting to fake this schema>"
    //     }
    //   },
    //   "economic_activity": [
    //     {
    //       "economic_activity": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       },
    //       "end_date": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       },
    //       "initial_date": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       },
    //       "order": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       },
    //       "percentage": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       }
    //     },
    //     {
    //       "economic_activity": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       },
    //       "end_date": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       },
    //       "initial_date": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       },
    //       "order": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       },
    //       "percentage": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       }
    //     }
    //   ],
    //   "regimens": [
    //     {
    //       "end_date": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       },
    //       "initial_date": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       },
    //       "regimen": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       }
    //     },
    //     {
    //       "end_date": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       },
    //       "initial_date": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       },
    //       "regimen": {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       }
    //     }
    //   ],
    //   "obligations": {
    //     "obligation": "<string>",
    //     "expiration": "<string>",
    //     "initial_date": "<string>",
    //     "end_date": "<string>"
    //   },
    //   "personal_information": "<object>",
    //   "digital_stamp": "<string>",
    //   "digital_stamp_chain": "<string>",
    //   "pdf": "<binary>"
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    var economic_activityValue;
    var end_dateValue;
    var initial_dateValue;
    var orderValue;
    var percentageValue;
    var regimenValue;

    var id = jResp.StringOf("id");
    var link = jResp.StringOf("link");
    var collected_at = jResp.StringOf("collected_at");
    var place_and_date_of_issuance = jResp.StringOf("place_and_date_of_issuance");
    var official_name = jResp.StringOf("official_name");
    var id_cif = jResp.StringOf("id_cif");
    var Rfc = jResp.StringOf("tax_payer_information.rfc");
    var Curp = jResp.StringOf("tax_payer_information.curp");
    var Name = jResp.StringOf("tax_payer_information.name");
    var First_last_name = jResp.StringOf("tax_payer_information.first_last_name");
    var Second_last_name = jResp.StringOf("tax_payer_information.second_last_name");
    var Start_operations_date = jResp.StringOf("tax_payer_information.start_operations_date");
    var Status_padron = jResp.StringOf("tax_payer_information.status_padron");
    var Last_status_change_date = jResp.StringOf("tax_payer_information.last_status_change_date");
    var Commercial_name = jResp.StringOf("tax_payer_information.commercial_name");
    var Social_name = jResp.StringOf("tax_payer_information.social_name");
    var v_Email = jResp.StringOf("tax_payer_information.email");
    var Phone = jResp.StringOf("tax_payer_information.phone");
    var Postal_code = jResp.StringOf("address.postal_code");
    var Street_type = jResp.StringOf("address.street_type");
    var Street = jResp.StringOf("address.street");
    var Exterior_number = jResp.StringOf("address.exterior_number");
    var Interior_number = jResp.StringOf("address.interior_number");
    var Suburb = jResp.StringOf("address.suburb");
    var Locality = jResp.StringOf("address.locality");
    var Municipality = jResp.StringOf("address.municipality");
    var State = jResp.StringOf("address.state");
    var Value = jResp.StringOf("address.between_street.value");
    var Obligation = jResp.StringOf("obligations.obligation");
    var Expiration = jResp.StringOf("obligations.expiration");
    var Initial_date = jResp.StringOf("obligations.initial_date");
    var End_date = jResp.StringOf("obligations.end_date");
    var personal_information = jResp.StringOf("personal_information");
    var digital_stamp = jResp.StringOf("digital_stamp");
    var digital_stamp_chain = jResp.StringOf("digital_stamp_chain");
    var pdf = jResp.StringOf("pdf");
    var i = 0;
    var count_i = jResp.SizeOfArray("economic_activity");
    while (i < count_i) {
        jResp.I = i;
        economic_activityValue = jResp.StringOf("economic_activity[i].economic_activity.value");
        end_dateValue = jResp.StringOf("economic_activity[i].end_date.value");
        initial_dateValue = jResp.StringOf("economic_activity[i].initial_date.value");
        orderValue = jResp.StringOf("economic_activity[i].order.value");
        percentageValue = jResp.StringOf("economic_activity[i].percentage.value");
        i = i+1;
    }

    i = 0;
    count_i = jResp.SizeOfArray("regimens");
    while (i < count_i) {
        jResp.I = i;
        end_dateValue = jResp.StringOf("regimens[i].end_date.value");
        initial_dateValue = jResp.StringOf("regimens[i].initial_date.value");
        regimenValue = jResp.StringOf("regimens[i].regimen.value");
        i = i+1;
    }


}

chilkatExample();

Curl Command

curl -X GET
	-u '{{secretId}}:{{secretPassword}}'
https://domain.com/api/tax-status/:id/

Postman Collection Item JSON

{
  "name": "Detail",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/tax-status/:id/",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "tax-status",
        ":id",
        ""
      ],
      "variable": [
        {
          "key": "id",
          "value": "consequa",
          "description": "(Required) The `tax-status.id` you want to get detailed information about."
        }
      ]
    },
    "description": "Get the details of a specific tax status."
  },
  "response": [
    {
      "name": "Ok",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/tax-status/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "tax-status",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n\t\"id\": \"<uuid>\",\n\t\"link\": \"<uuid>\",\n\t\"collected_at\": \"<dateTime>\",\n\t\"place_and_date_of_issuance\": \"<string>\",\n\t\"official_name\": \"<string>\",\n\t\"id_cif\": \"<string>\",\n\t\"tax_payer_information\": {\n\t\t\"rfc\": \"<string>\",\n\t\t\"curp\": \"<string>\",\n\t\t\"name\": \"<string>\",\n\t\t\"first_last_name\": \"<string>\",\n\t\t\"second_last_name\": \"<string>\",\n\t\t\"start_operations_date\": \"<string>\",\n\t\t\"status_padron\": \"<string>\",\n\t\t\"last_status_change_date\": \"<string>\",\n\t\t\"commercial_name\": \"<string>\",\n\t\t\"social_name\": \"<string>\",\n\t\t\"email\": \"<string>\",\n\t\t\"phone\": \"<string>\"\n\t},\n\t\"address\": {\n\t\t\"postal_code\": \"<string>\",\n\t\t\"street_type\": \"<string>\",\n\t\t\"street\": \"<string>\",\n\t\t\"exterior_number\": \"<string>\",\n\t\t\"interior_number\": \"<string>\",\n\t\t\"suburb\": \"<string>\",\n\t\t\"locality\": \"<string>\",\n\t\t\"municipality\": \"<string>\",\n\t\t\"state\": \"<string>\",\n\t\t\"between_street\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t}\n\t},\n\t\"economic_activity\": [\n\t\t{\n\t\t\t\"economic_activity\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"end_date\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"initial_date\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"order\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"percentage\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"economic_activity\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"end_date\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"initial_date\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"order\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"percentage\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t}\n\t\t}\n\t],\n\t\"regimens\": [\n\t\t{\n\t\t\t\"end_date\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"initial_date\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"regimen\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"end_date\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"initial_date\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"regimen\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t}\n\t\t}\n\t],\n\t\"obligations\": {\n\t\t\"obligation\": \"<string>\",\n\t\t\"expiration\": \"<string>\",\n\t\t\"initial_date\": \"<string>\",\n\t\t\"end_date\": \"<string>\"\n\t},\n\t\"personal_information\": \"<object>\",\n\t\"digital_stamp\": \"<string>\",\n\t\"digital_stamp_chain\": \"<string>\",\n\t\"pdf\": \"<binary>\"\n}"
    },
    {
      "name": "Unauthorized",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/tax-status/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "tax-status",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "[\n\t{\n\t\t\"code\": \"<string>\",\n\t\t\"message\": \"<string>\",\n\t\t\"request_id\": \"<string>\"\n\t},\n\t{\n\t\t\"code\": \"<string>\",\n\t\t\"message\": \"<string>\",\n\t\t\"request_id\": \"<string>\"\n\t}\n]"
    },
    {
      "name": "Too Many Sessions",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/tax-status/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "tax-status",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "[\n\t{\n\t\t\"code\": \"<string>\",\n\t\t\"message\": \"<string>\",\n\t\t\"request_id\": \"<string>\"\n\t},\n\t{\n\t\t\"code\": \"<string>\",\n\t\t\"message\": \"<string>\",\n\t\t\"request_id\": \"<string>\"\n\t}\n]"
    }
  ]
}