Chilkat Online Tools

PureBasic / EDS API / Nodokļu maksātājam iesniegto algas nodokļu grāmatiņu dati.

Back to Collection Items

IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"

Procedure ChilkatExample()

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

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    queryParams.i = CkJsonObject::ckCreate()
    If queryParams.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckUpdateString(queryParams,"tikaiIzmainas","true")
    CkJsonObject::ckUpdateString(queryParams,"periodsNo","nisi cillum sed")
    CkJsonObject::ckUpdateString(queryParams,"periodsLidz","nisi cillum sed")
    CkJsonObject::ckUpdateString(queryParams,"iesniedzejs","est i")
    CkJsonObject::ckUpdateInt(queryParams,"pmnmIzmainas",25210683)
    CkJsonObject::ckUpdateInt(queryParams,"neattelotAtvieglojumus",25210683)

    CkHttp::ckSetRequestHeader(http,"Accept","application/json")

    resp.i = CkHttp::ckQuickRequestParams(http,"GET","https://eds.vid.gov.lv/api/reports/taxbooks",queryParams)
    If CkHttp::ckLastMethodSuccess(http) = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(queryParams)
        ProcedureReturn
    EndIf

    sbResponseBody.i = CkStringBuilder::ckCreate()
    If sbResponseBody.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkHttpResponse::ckGetBodySb(resp,sbResponseBody)

    jResp.i = CkJsonObject::ckCreate()
    If jResp.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckLoadSb(jResp,sbResponseBody)
    CkJsonObject::setCkEmitCompact(jResp, 0)

    Debug "Response Body:"
    Debug CkJsonObject::ckEmit(jResp)

    respStatusCode.i = CkHttpResponse::ckStatusCode(resp)
    Debug "Response Status Code = " + Str(respStatusCode)
    If respStatusCode >= 400
        Debug "Response Header:"
        Debug CkHttpResponse::ckHeader(resp)
        Debug "Failed."
        CkHttpResponse::ckDispose(resp)

        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(queryParams)
        CkStringBuilder::ckDispose(sbResponseBody)
        CkJsonObject::ckDispose(jResp)
        ProcedureReturn
    EndIf

    CkHttpResponse::ckDispose(resp)

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

    ; {
    ;   "Gramatinas": [
    ;     {
    ;       "PersonasKods": "incididunt aute laborum sed",
    ;       "VardsUzvards": "reprehenderi",
    ;       "Numurs": "eiusmod sed ut tempor nulla",
    ;       "IzdosanasDatums": "2000-01-31T00:00:00",
    ;       "DatumsNo": "2000-01-31T00:00:00",
    ;       "IzmainuDatums": "2000-01-31T00:00:00",
    ;       "DatumsLidz": "2000-01-31T00:00:00",
    ;       "Apgadajamie": [
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         },
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         }
    ;       ],
    ;       "Pensijas": [
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         },
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         }
    ;       ],
    ;       "PapilduAtvieglojumi": [
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         },
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         }
    ;       ],
    ;       "IinLikmes": [
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         },
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         }
    ;       ],
    ;       "PrognozetaisMinimums": [
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         },
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         }
    ;       ]
    ;     },
    ;     {
    ;       "PersonasKods": "qui cillum fugiat",
    ;       "VardsUzvards": "reprehenderit minim consectetur consequat ea",
    ;       "Numurs": "ut labore mollit",
    ;       "IzdosanasDatums": "2000-01-31T00:00:00",
    ;       "DatumsNo": "2000-01-31T00:00:00",
    ;       "IzmainuDatums": "2000-01-31T00:00:00",
    ;       "DatumsLidz": "2000-01-31T00:00:00",
    ;       "Apgadajamie": [
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         },
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         }
    ;       ],
    ;       "Pensijas": [
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         },
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         }
    ;       ],
    ;       "PapilduAtvieglojumi": [
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         },
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         }
    ;       ],
    ;       "IinLikmes": [
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         },
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         }
    ;       ],
    ;       "PrognozetaisMinimums": [
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         },
    ;         {
    ;           "value": "<Error: Too many levels of nesting to fake this schema>"
    ;         }
    ;       ]
    ;     }
    ;   ]
    ; }

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

    PersonasKods.s
    VardsUzvards.s
    Numurs.s
    IzdosanasDatums.s
    DatumsNo.s
    IzmainuDatums.s
    DatumsLidz.s
    j.i
    count_j.i
    value.s

    i.i = 0
    count_i.i = CkJsonObject::ckSizeOfArray(jResp,"Gramatinas")
    While i < count_i
        CkJsonObject::setCkI(jResp, i)
        PersonasKods = CkJsonObject::ckStringOf(jResp,"Gramatinas[i].PersonasKods")
        VardsUzvards = CkJsonObject::ckStringOf(jResp,"Gramatinas[i].VardsUzvards")
        Numurs = CkJsonObject::ckStringOf(jResp,"Gramatinas[i].Numurs")
        IzdosanasDatums = CkJsonObject::ckStringOf(jResp,"Gramatinas[i].IzdosanasDatums")
        DatumsNo = CkJsonObject::ckStringOf(jResp,"Gramatinas[i].DatumsNo")
        IzmainuDatums = CkJsonObject::ckStringOf(jResp,"Gramatinas[i].IzmainuDatums")
        DatumsLidz = CkJsonObject::ckStringOf(jResp,"Gramatinas[i].DatumsLidz")
        j = 0
        count_j = CkJsonObject::ckSizeOfArray(jResp,"Gramatinas[i].Apgadajamie")
        While j < count_j
            CkJsonObject::setCkJ(jResp, j)
            value = CkJsonObject::ckStringOf(jResp,"Gramatinas[i].Apgadajamie[j].value")
            j = j + 1
        Wend
        j = 0
        count_j = CkJsonObject::ckSizeOfArray(jResp,"Gramatinas[i].Pensijas")
        While j < count_j
            CkJsonObject::setCkJ(jResp, j)
            value = CkJsonObject::ckStringOf(jResp,"Gramatinas[i].Pensijas[j].value")
            j = j + 1
        Wend
        j = 0
        count_j = CkJsonObject::ckSizeOfArray(jResp,"Gramatinas[i].PapilduAtvieglojumi")
        While j < count_j
            CkJsonObject::setCkJ(jResp, j)
            value = CkJsonObject::ckStringOf(jResp,"Gramatinas[i].PapilduAtvieglojumi[j].value")
            j = j + 1
        Wend
        j = 0
        count_j = CkJsonObject::ckSizeOfArray(jResp,"Gramatinas[i].IinLikmes")
        While j < count_j
            CkJsonObject::setCkJ(jResp, j)
            value = CkJsonObject::ckStringOf(jResp,"Gramatinas[i].IinLikmes[j].value")
            j = j + 1
        Wend
        j = 0
        count_j = CkJsonObject::ckSizeOfArray(jResp,"Gramatinas[i].PrognozetaisMinimums")
        While j < count_j
            CkJsonObject::setCkJ(jResp, j)
            value = CkJsonObject::ckStringOf(jResp,"Gramatinas[i].PrognozetaisMinimums[j].value")
            j = j + 1
        Wend
        i = i + 1
    Wend


    CkHttp::ckDispose(http)
    CkJsonObject::ckDispose(queryParams)
    CkStringBuilder::ckDispose(sbResponseBody)
    CkJsonObject::ckDispose(jResp)


    ProcedureReturn
EndProcedure

Curl Command

curl -G -d "tikaiIzmainas=true"
	-d "periodsNo=nisi%20cillum%20sed"
	-d "periodsLidz=nisi%20cillum%20sed"
	-d "iesniedzejs=est%20i"
	-d "pmnmIzmainas=25210683"
	-d "neattelotAtvieglojumus=25210683"
	-H "Accept: application/json"
https://eds.vid.gov.lv/api/reports/taxbooks

Postman Collection Item JSON

{
  "name": "Nodokļu maksātājam iesniegto algas nodokļu grāmatiņu dati.",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/reports/taxbooks?tikaiIzmainas=true&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&iesniedzejs=est i&pmnmIzmainas=25210683&neattelotAtvieglojumus=25210683",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "reports",
        "taxbooks"
      ],
      "query": [
        {
          "key": "tikaiIzmainas",
          "value": "true",
          "description": "Atlasīt tikai tās grāmatiņas kurās veiktas izmaiņas."
        },
        {
          "key": "periodsNo",
          "value": "nisi cillum sed",
          "description": "(Required) Pārskata perioda sākuma datums."
        },
        {
          "key": "periodsLidz",
          "value": "nisi cillum sed",
          "description": "ārskata perioda beigu datums."
        },
        {
          "key": "iesniedzejs",
          "value": "est i",
          "description": "Grāmatiņas iesniedzēja personas kods."
        },
        {
          "key": "pmnmIzmainas",
          "value": "25210683",
          "description": "Iekļaut nodokļu maksātājus, kuriem:\r\n0 - mainījušies algas nodokļa grāmatiņas dati, izņemot prognozēto mēneša neapliekamo minimumu;\r\n1 - mainījušies algas nodokļa grāmatiņas dati, tai skaitā arī prognozētais mēneša neapliekamais minimums;\r\n2 - mainījies tikai prognozētais mēneša neapliekamais minimums."
        },
        {
          "key": "neattelotAtvieglojumus",
          "value": "25210683",
          "description": "Neattēlot nodokļa atvieglojumus, kuri bija spēkā pirms pārskatā norādītā perioda."
        }
      ]
    }
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/reports/taxbooks?tikaiIzmainas=true&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&iesniedzejs=est i&pmnmIzmainas=25210683&neattelotAtvieglojumus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "taxbooks"
          ],
          "query": [
            {
              "key": "tikaiIzmainas",
              "value": "true"
            },
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniedzejs",
              "value": "est i"
            },
            {
              "key": "pmnmIzmainas",
              "value": "25210683"
            },
            {
              "key": "neattelotAtvieglojumus",
              "value": "25210683"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"Gramatinas\": [\n    {\n      \"PersonasKods\": \"incididunt aute laborum sed\",\n      \"VardsUzvards\": \"reprehenderi\",\n      \"Numurs\": \"eiusmod sed ut tempor nulla\",\n      \"IzdosanasDatums\": \"2000-01-31T00:00:00\",\n      \"DatumsNo\": \"2000-01-31T00:00:00\",\n      \"IzmainuDatums\": \"2000-01-31T00:00:00\",\n      \"DatumsLidz\": \"2000-01-31T00:00:00\",\n      \"Apgadajamie\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"Pensijas\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"PapilduAtvieglojumi\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"IinLikmes\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"PrognozetaisMinimums\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ]\n    },\n    {\n      \"PersonasKods\": \"qui cillum fugiat\",\n      \"VardsUzvards\": \"reprehenderit minim consectetur consequat ea\",\n      \"Numurs\": \"ut labore mollit\",\n      \"IzdosanasDatums\": \"2000-01-31T00:00:00\",\n      \"DatumsNo\": \"2000-01-31T00:00:00\",\n      \"IzmainuDatums\": \"2000-01-31T00:00:00\",\n      \"DatumsLidz\": \"2000-01-31T00:00:00\",\n      \"Apgadajamie\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"Pensijas\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"PapilduAtvieglojumi\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"IinLikmes\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ],\n      \"PrognozetaisMinimums\": [\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        },\n        {\n          \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n        }\n      ]\n    }\n  ]\n}"
    },
    {
      "name": "Lietotājs nav autentificēts.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/reports/taxbooks?tikaiIzmainas=true&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&iesniedzejs=est i&pmnmIzmainas=25210683&neattelotAtvieglojumus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "taxbooks"
          ],
          "query": [
            {
              "key": "tikaiIzmainas",
              "value": "true"
            },
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniedzejs",
              "value": "est i"
            },
            {
              "key": "pmnmIzmainas",
              "value": "25210683"
            },
            {
              "key": "neattelotAtvieglojumus",
              "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/taxbooks?tikaiIzmainas=true&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&iesniedzejs=est i&pmnmIzmainas=25210683&neattelotAtvieglojumus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "taxbooks"
          ],
          "query": [
            {
              "key": "tikaiIzmainas",
              "value": "true"
            },
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniedzejs",
              "value": "est i"
            },
            {
              "key": "pmnmIzmainas",
              "value": "25210683"
            },
            {
              "key": "neattelotAtvieglojumus",
              "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/taxbooks?tikaiIzmainas=true&periodsNo=nisi cillum sed&periodsLidz=nisi cillum sed&iesniedzejs=est i&pmnmIzmainas=25210683&neattelotAtvieglojumus=25210683",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "reports",
            "taxbooks"
          ],
          "query": [
            {
              "key": "tikaiIzmainas",
              "value": "true"
            },
            {
              "key": "periodsNo",
              "value": "nisi cillum sed"
            },
            {
              "key": "periodsLidz",
              "value": "nisi cillum sed"
            },
            {
              "key": "iesniedzejs",
              "value": "est i"
            },
            {
              "key": "pmnmIzmainas",
              "value": "25210683"
            },
            {
              "key": "neattelotAtvieglojumus",
              "value": "25210683"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}