Chilkat Online Tools

C / EDS API / Transakciju pārskats (no 01.01.2021).

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
#include <C_CkStringBuilder.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkJsonObject queryParams;
    HCkHttpResponse resp;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jResp;
    int respStatusCode;
    const char *Datums;
    const char *SaistibasDokumentaNr;
    const char *Aprekins;
    const char *AprekinaPamatojums;
    const char *SaistibasVeids;
    const char *IenemumuVeids;
    const char *BudzetaKlasifikacijasKods;
    const char *SummasVeids;
    const char *Summa;
    const char *MaksajumaUzdevumaNr;
    const char *SaistitaDokumentaNr;
    const char *Info;
    const char *PeriodsNo;
    const char *PeriodsLidz;
    int i;
    int count_i;

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

    http = CkHttp_Create();

    queryParams = CkJsonObject_Create();
    CkJsonObject_UpdateString(queryParams,"periodsNo","nisi cillum sed");
    CkJsonObject_UpdateString(queryParams,"periodsLidz","nisi cillum sed");
    CkJsonObject_UpdateString(queryParams,"saistibasDokumentaNr","qui sed");
    CkJsonObject_UpdateString(queryParams,"maksajumaUzdevumaNr","qui sed");
    CkJsonObject_UpdateInt(queryParams,"izlaistIerakstus",25210683);
    CkJsonObject_UpdateInt(queryParams,"atgrieztIerakstus",25210683);

    CkHttp_SetRequestHeader(http,"Accept","application/json");

    resp = CkHttp_QuickRequestParams(http,"GET","https://eds.vid.gov.lv/api/reports/paymenttransactions",queryParams);
    if (CkHttp_getLastMethodSuccess(http) == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkJsonObject_Dispose(queryParams);
        return;
    }

    sbResponseBody = CkStringBuilder_Create();
    CkHttpResponse_GetBodySb(resp,sbResponseBody);

    jResp = CkJsonObject_Create();
    CkJsonObject_LoadSb(jResp,sbResponseBody);
    CkJsonObject_putEmitCompact(jResp,FALSE);

    printf("Response Body:\n");
    printf("%s\n",CkJsonObject_emit(jResp));

    respStatusCode = CkHttpResponse_getStatusCode(resp);
    printf("Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        printf("Response Header:\n");
        printf("%s\n",CkHttpResponse_header(resp));
        printf("Failed.\n");
        CkHttpResponse_Dispose(resp);
        CkHttp_Dispose(http);
        CkJsonObject_Dispose(queryParams);
        CkStringBuilder_Dispose(sbResponseBody);
        CkJsonObject_Dispose(jResp);
        return;
    }

    CkHttpResponse_Dispose(resp);

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

    // {
    //   "Transakcijas": [
    //     {
    //       "Datums": "2000-01-31T00:00:00",
    //       "SaistibasDokumentaNr": "occaec",
    //       "Aprekins": "deserunt consequat laborum officia",
    //       "AprekinaPamatojums": "ut et exercitation",
    //       "SaistibasVeids": "ea enim aliquip do ullamco",
    //       "IenemumuVeids": "ut eu exercitation",
    //       "BudzetaKlasifikacijasKods": "exercitation anim",
    //       "SummasVeids": "sit ullamco irure",
    //       "Summa": 24341259.51378028,
    //       "MaksajumaUzdevumaNr": "veniam quis incididun",
    //       "SaistitaDokumentaNr": "sit cupidatat dolor fugiat",
    //       "Info": "ea quis",
    //       "PeriodsNo": "2000-01-31T00:00:00",
    //       "PeriodsLidz": "2000-01-31T00:00:00"
    //     },
    //     {
    //       "Datums": "2000-01-31T00:00:00",
    //       "SaistibasDokumentaNr": "dolore proident sed",
    //       "Aprekins": "minim sint non",
    //       "AprekinaPamatojums": "Lorem minim id",
    //       "SaistibasVeids": "commodo velit et",
    //       "IenemumuVeids": "est sint",
    //       "BudzetaKlasifikacijasKods": "elit minim proident",
    //       "SummasVeids": "in qui",
    //       "Summa": -45694443.17825795,
    //       "MaksajumaUzdevumaNr": "tempor officia",
    //       "SaistitaDokumentaNr": "ipsum",
    //       "Info": "nulla ad",
    //       "PeriodsNo": "2000-01-31T00:00:00",
    //       "PeriodsLidz": "2000-01-31T00:00:00"
    //     }
    //   ]
    // }

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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"Transakcijas");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        Datums = CkJsonObject_stringOf(jResp,"Transakcijas[i].Datums");
        SaistibasDokumentaNr = CkJsonObject_stringOf(jResp,"Transakcijas[i].SaistibasDokumentaNr");
        Aprekins = CkJsonObject_stringOf(jResp,"Transakcijas[i].Aprekins");
        AprekinaPamatojums = CkJsonObject_stringOf(jResp,"Transakcijas[i].AprekinaPamatojums");
        SaistibasVeids = CkJsonObject_stringOf(jResp,"Transakcijas[i].SaistibasVeids");
        IenemumuVeids = CkJsonObject_stringOf(jResp,"Transakcijas[i].IenemumuVeids");
        BudzetaKlasifikacijasKods = CkJsonObject_stringOf(jResp,"Transakcijas[i].BudzetaKlasifikacijasKods");
        SummasVeids = CkJsonObject_stringOf(jResp,"Transakcijas[i].SummasVeids");
        Summa = CkJsonObject_stringOf(jResp,"Transakcijas[i].Summa");
        MaksajumaUzdevumaNr = CkJsonObject_stringOf(jResp,"Transakcijas[i].MaksajumaUzdevumaNr");
        SaistitaDokumentaNr = CkJsonObject_stringOf(jResp,"Transakcijas[i].SaistitaDokumentaNr");
        Info = CkJsonObject_stringOf(jResp,"Transakcijas[i].Info");
        PeriodsNo = CkJsonObject_stringOf(jResp,"Transakcijas[i].PeriodsNo");
        PeriodsLidz = CkJsonObject_stringOf(jResp,"Transakcijas[i].PeriodsLidz");
        i = i + 1;
    }



    CkHttp_Dispose(http);
    CkJsonObject_Dispose(queryParams);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jResp);

    }

Curl Command

curl -G -d "periodsNo=nisi%20cillum%20sed"
	-d "periodsLidz=nisi%20cillum%20sed"
	-d "saistibasDokumentaNr=qui%20sed"
	-d "maksajumaUzdevumaNr=qui%20sed"
	-d "izlaistIerakstus=25210683"
	-d "atgrieztIerakstus=25210683"
	-H "Accept: application/json"
https://eds.vid.gov.lv/api/reports/paymenttransactions

Postman Collection Item JSON

{
  "name": "Transakciju pārskats (no 01.01.2021).",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/reports/paymenttransactions?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&saistibasDokumentaNr=qui sed&maksajumaUzdevumaNr=qui sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "reports",
        "paymenttransactions"
      ],
      "query": [
        {
          "key": "periodsNo",
          "value": "nisi cillum sed",
          "description": "(Required) Periods no."
        },
        {
          "key": "periodsLidz",
          "value": "nisi cillum sed",
          "description": "(Required) Periods līdz."
        },
        {
          "key": "saistibasDokumentaNr",
          "value": "qui sed",
          "description": "Saistības dokumenta Nr."
        },
        {
          "key": "maksajumaUzdevumaNr",
          "value": "qui sed",
          "description": "Maksājuma uzdevuma Nr."
        },
        {
          "key": "izlaistIerakstus",
          "value": "25210683",
          "description": "(Required) No rezultāta izlaižamo ierakstu skaits."
        },
        {
          "key": "atgrieztIerakstus",
          "value": "25210683",
          "description": "(Required) Atgriežamo ierakstu skaits."
        }
      ]
    }
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/reports/paymenttransactions?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&saistibasDokumentaNr=qui sed&maksajumaUzdevumaNr=qui sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "paymenttransactions"
          ],
          "query": [
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "saistibasDokumentaNr",
              "value": "qui sed"
            },
            {
              "key": "maksajumaUzdevumaNr",
              "value": "qui sed"
            },
            {
              "key": "izlaistIerakstus",
              "value": "25210683"
            },
            {
              "key": "atgrieztIerakstus",
              "value": "25210683"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"Transakcijas\": [\n    {\n      \"Datums\": \"2000-01-31T00:00:00\",\n      \"SaistibasDokumentaNr\": \"occaec\",\n      \"Aprekins\": \"deserunt consequat laborum officia\",\n      \"AprekinaPamatojums\": \"ut et exercitation\",\n      \"SaistibasVeids\": \"ea enim aliquip do ullamco\",\n      \"IenemumuVeids\": \"ut eu exercitation\",\n      \"BudzetaKlasifikacijasKods\": \"exercitation anim\",\n      \"SummasVeids\": \"sit ullamco irure\",\n      \"Summa\": 24341259.51378028,\n      \"MaksajumaUzdevumaNr\": \"veniam quis incididun\",\n      \"SaistitaDokumentaNr\": \"sit cupidatat dolor fugiat\",\n      \"Info\": \"ea quis\",\n      \"PeriodsNo\": \"2000-01-31T00:00:00\",\n      \"PeriodsLidz\": \"2000-01-31T00:00:00\"\n    },\n    {\n      \"Datums\": \"2000-01-31T00:00:00\",\n      \"SaistibasDokumentaNr\": \"dolore proident sed\",\n      \"Aprekins\": \"minim sint non\",\n      \"AprekinaPamatojums\": \"Lorem minim id\",\n      \"SaistibasVeids\": \"commodo velit et\",\n      \"IenemumuVeids\": \"est sint\",\n      \"BudzetaKlasifikacijasKods\": \"elit minim proident\",\n      \"SummasVeids\": \"in qui\",\n      \"Summa\": -45694443.17825795,\n      \"MaksajumaUzdevumaNr\": \"tempor officia\",\n      \"SaistitaDokumentaNr\": \"ipsum\",\n      \"Info\": \"nulla ad\",\n      \"PeriodsNo\": \"2000-01-31T00:00:00\",\n      \"PeriodsLidz\": \"2000-01-31T00:00:00\"\n    }\n  ]\n}"
    },
    {
      "name": "Lietotājs nav autentificēts.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/reports/paymenttransactions?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&saistibasDokumentaNr=qui sed&maksajumaUzdevumaNr=qui sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "paymenttransactions"
          ],
          "query": [
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "saistibasDokumentaNr",
              "value": "qui sed"
            },
            {
              "key": "maksajumaUzdevumaNr",
              "value": "qui sed"
            },
            {
              "key": "izlaistIerakstus",
              "value": "25210683"
            },
            {
              "key": "atgrieztIerakstus",
              "value": "25210683"
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Lietotājam nav tiesību veikt šo darbību.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/reports/paymenttransactions?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&saistibasDokumentaNr=qui sed&maksajumaUzdevumaNr=qui sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "paymenttransactions"
          ],
          "query": [
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "saistibasDokumentaNr",
              "value": "qui sed"
            },
            {
              "key": "maksajumaUzdevumaNr",
              "value": "qui sed"
            },
            {
              "key": "izlaistIerakstus",
              "value": "25210683"
            },
            {
              "key": "atgrieztIerakstus",
              "value": "25210683"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Pārsniegts izsaukumu skaita ierobežojums.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/reports/paymenttransactions?periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&saistibasDokumentaNr=qui sed&maksajumaUzdevumaNr=qui sed&izlaistIerakstus=25210683&atgrieztIerakstus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "paymenttransactions"
          ],
          "query": [
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "saistibasDokumentaNr",
              "value": "qui sed"
            },
            {
              "key": "maksajumaUzdevumaNr",
              "value": "qui sed"
            },
            {
              "key": "izlaistIerakstus",
              "value": "25210683"
            },
            {
              "key": "atgrieztIerakstus",
              "value": "25210683"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}