$kind: http-request
description: |-
  Get list of all Regions

   **On Success**
      
      ``` Json
        { 
            "statusCode": 8000, 
            "data": [
                      {
                          "uid": "b9b9ebe8-63d8-420e-ae38-ab4a72948518",
                          "regionName": "Pwani",
                          "regionCode": "PWN"
                      }
            ],
            "message": "Success"
        }
url: "{{csmisUrl}}/supervision/financial-report/submit-filled-items"
method: POST
headers:
  cooperativeApiToken: "{{SACCOApiToken}}"
body:
  type: json
  content: "{\r

    \  \"formUid\": \"formUid_8cc812abd127\",\r

    \  // for financial and non financial position use this \r

    \  \"financialPositionItemAmounts\": [\r

    \    {\r

    \      \"uid\": \"uid_06cf9b2721f4\",\r

    \      \"amount\": 0.00,\r

    \      \"comment\": \"comment_357a6680e428\"\r

    \    }\r

    \  ],\r

    \    // for financial and non financial position use this \r

    \  \"comprehensiveIncomeItemAmounts\": [\r

    \    {\r

    \      \"uid\": \"uid_94bd90f42227\",\r

    \      \"amount\": 0.00,\r

    \      \"comment\": \"comment_474fe12a5a18\"\r

    \    }\r

    \  ],\r

    \  \"depositLoanItemAmounts\": [\r

    \    {\r

    \      \"uid\": \"uid_fafcdf1151cf\",\r

    \      \"deposit\": 0.00,\r

    \      \"loan\": 0.00\r

    \    }\r

    \  ],\r

    \  \"complaintItemValues\": [\r

    \    {\r

    \      \"uid\": \"uid_a16757f1be6a\",\r

    \      \"number\": 0,\r

    \      \"value\": 0.00,\r

    \      \"interestRate\": 0,\r

    \      \"agreements\": 0,\r

    \      \"repayments\": 0,\r

    \      \"loanStatements\": 0,\r

    \      \"loanProcessing\": 0,\r

    \      \"others\": 0\r

    \    }\r

    \  ],\r

    \  \"loanInsiderValues\": [\r

    \    {\r

    \      \"uid\": \"uid_6fb0713b8d53\",\r

    \      \"numberLoans\": 0,\r

    \      \"loanAmount\": 0.00,\r

    \      \"savingAmount\": 0.00,\r

    \      \"depositAmount\": 0.00,\r

    \      \"voluntaryShareAmount\": 0.00\r

    \    }\r

    \  ],\r

    \  \"disbursedItemValues\": [\r

    \    {\r

    \      \"uid\": \"uid_d10c63ab122f\",\r

    \      \"numberFemale\": 0,\r

    \      \"amountFemale\": 0.00,\r

    \      \"numberMale\": 0,\r

    \      \"amountMale\": 0.00\r

    \    }\r

    \  ],\r

    \  \"geographicalDistributionValues\": [\r

    \    {\r

    \      \"uid\": \"uid_c6b7e339f64f\",\r

    \      \"numberOfEmployee\": 0,\r

    \      \"numberOfFemaleBorrowersUpTo35\": 0,\r

    \      \"numberOfMaleBorrowersUpTo35\": 0,\r

    \      \"numberOfFemaleBorrowersAbove35\": 0,\r

    \      \"numberOfMaleBorrowersAbove35\": 0,\r

    \      \"numberOfFemaleLoansUpTo35\": 0,\r

    \      \"numberOfMaleLoansUpTo35\": 0,\r

    \      \"numberOfFemaleLoansAbove35\": 0,\r

    \      \"numberOfMaleLoansAbove35\": 0,\r

    \      \"outstandingLoansOfFemaleUpTo35\": 0.00,\r

    \      \"outstandingLoansOfMaleUpTo35\": 0.00,\r

    \      \"outstandingLoansOfFemaleAbove35\": 0.00,\r

    \      \"outstandingLoansOfMaleAbove35\": 0.00\r

    \    }\r

    \  ],\r

    \  \"interestRateItemValues\": [\r

    \    {\r

    \      \"uid\": \"uid_273196a81241\",\r

    \      \"outstandingLoan\": 0.00,\r

    \      \"highInterestRate\": 0.00,\r

    \      \"lowInterestRate\": 0.00\r

    \    }\r

    \  ],\r

    \  \"sectorialItemAmounts\": [\r

    \    {\r

    \      \"numberOfBorrowers\": 0,\r

    \      \"uid\": \"uid_2debe0b485f4\",\r

    \      \"current\": 0.00,\r

    \      \"esm\": 0.00,\r

    \      \"substandard\": 0.00,\r

    \      \"doubtful\": 0.00,\r

    \      \"loss\": 0.00,\r

    \      \"writeOffs\": 0.00,\r

    \      \"recovery\": 0.00\r

    \    }\r

    \  ]\r

    }"
scripts:
  - type: afterResponse
    code: >-
      pm.test("Response status code is 200", function () {
          pm.expect(pm.response.code).to.equal(200);
      });



      pm.test("Response has the required fields", function () {
          const responseData = pm.response.json();

          pm.expect(responseData).to.have.property('statusCode');
          pm.expect(responseData).to.have.property('data');
          pm.expect(responseData).to.have.property('message');
      });



      pm.test("Validate the data object within the response", function () {
          const responseData = pm.response.json();
          
          pm.expect(responseData).to.be.an('object');
          pm.expect(responseData.data).to.exist.and.to.be.an('array');
          responseData.data.forEach(function(item) {
              pm.expect(item).to.have.property('uid').that.is.a('string');
              pm.expect(item).to.have.property('regionName').that.is.a('string');
              pm.expect(item).to.have.property('regionCode').that.is.a('string');
          });
      });



      pm.test("Data array is present and contains the expected number of
      elements", function () {
          const responseData = pm.response.json();
          
          pm.expect(responseData).to.have.property('data').that.is.an('array').with.lengthOf(1);
      });



      pm.test("Validate data properties", function () {
          const responseData = pm.response.json();
          
          pm.expect(responseData).to.be.an('object');
          
          responseData.data.forEach(function(region) {
              pm.expect(region.uid).to.be.a('string').and.to.have.lengthOf.at.least(1, "uid should be a non-empty string");
              pm.expect(region.regionName).to.be.a('string').and.to.have.lengthOf.at.least(1, "regionName should be a non-empty string");
              pm.expect(region.regionCode).to.be.a('string').and.to.have.lengthOf.at.least(1, "regionCode should be a non-empty string");
          });
      });
    language: text/javascript
order: 4000
