//---------------------------------------------------------------------------
#pragma hdrstop

#include "CDSAtmpF.h"
#include "AppGlobalF.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

/////////////////////////////////////////////////////////////////////////////
TCDSAtmpManager *CDSAtmpManager = NULL;
//---------------------------------------------------------------------------
int TCDSAtmpManager::Load()
{
    FLists.RemoveAll();

    String apiUri = g_AppCfg.sRestApiUri + "/api/its/common/weather/atmp/list";
    TMcJsonItem *ObjList = NULL;
    try {
        ObjList = TRestObjectManager::RequestGet(apiUri);
        if (ObjList == NULL) {
            return 0;
        }

        for (int ii = 0; ii < ObjList->Count; ii++) {
            String sDelYn = TRestObjectManager::GetValue(ObjList->Items[ii], "del_yn");
            if (sDelYn == "Y") {
                continue;
            }

            TCDSAtmp *pObj = new TCDSAtmp();
            pObj->ATMP_STTN_NMBR = TRestObjectManager::GetValue(ObjList->Items[ii], "atmp_sttn_nmbr");
            pObj->ATMP_STTN_NM   = TRestObjectManager::GetValue(ObjList->Items[ii], "atmp_sttn_nm");
            pObj->VMS_DISP_NM    = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_disp_nm");
            pObj->ATMP_STTN_ADDR = TRestObjectManager::GetValue(ObjList->Items[ii], "atmp_sttn_addr");
            pObj->DEL_YN = sDelYn;

            FLists.Push(pObj->ATMP_STTN_NMBR, pObj);
        }
    } __finally {
        if (ObjList) delete ObjList;
    }
    return FLists.Size();
}
//---------------------------------------------------------------------------
