package com.nokia.domainb.capability;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

@Slf4j
class QryOweFeeTest {
    @Test
    void testQuery() {
        QryOweFee qryOweFee = new QryOweFee();
        String result = qryOweFee.query("18622305641", "13");
        JsonObject jsonObject = JsonParser.parseString(result).getAsJsonObject();
        JsonObject rsp = jsonObject.getAsJsonObject("UNI_BSS_BODY")
                .getAsJsonObject("QRY_OWE_FEE_RSP")
                .getAsJsonObject("RSP");
//        String rspCode = rsp.get("RSP_CODE").getAsString();
//        if (!"0000".equals(rspCode)) {
//            String rspDesc = rsp.get("RSP_DESC").getAsString();
//            return R.error().message(rspDesc);
//        }

        JsonObject data = rsp.getAsJsonArray("DATA").get(0).getAsJsonObject();
        JsonObject oweFeeInfo = data.getAsJsonObject("OWE_FEE_INFO");
//        if (oweFeeInfo == null) {
//            String detail = data.get("detail").getAsString();
//            return R.error().message(detail);
//        }
        String payFee = oweFeeInfo.get("PAY_FEE").getAsString();
        String balanceFee = oweFeeInfo.get("BALANCE_FEE").getAsString();
        String realFee = oweFeeInfo.get("REAL_FEE").getAsString();
        System.out.println(payFee);
        System.out.println(balanceFee);
        System.out.println(realFee);
    }

    @AllArgsConstructor
    @NoArgsConstructor
    @Data
    static class Dto {
        private String data;
    }
}
