import http from '@ohos:net.http';
import { UPResponse } from '@package:pkg_modules/.ohpm/uppayment@gx7nzjcazfb3kvk6jc+phqy7h84=/pkg_modules/uppayment/src/main/ets/network/response/UPResponse';
import UPConstant from '@package:pkg_modules/.ohpm/uppayment@gx7nzjcazfb3kvk6jc+phqy7h84=/pkg_modules/uppayment/src/main/ets/common/UPConstant';
import UPLogger from '@package:pkg_modules/.ohpm/uppayment@gx7nzjcazfb3kvk6jc+phqy7h84=/pkg_modules/uppayment/src/main/ets/utils/UPLogger';
export class UPHttpManager {
    sendMessage(t) {
        return new Promise((v, w) => {
        });
    }
    sendGetRequest(p) {
        return new Promise((r, s) => {
        });
    }
    sendPostRequest(a) {
        return new Promise((c, d) => {
            let e = http.createHttp();
            let f = a.path;
            let g = {
                method: http.RequestMethod.POST,
                extraData: a.bodyStr,
                header: a.header
            };
            let h = new UPResponse();
            let i = e.request(f, g);
            i.then((m) => {
                let n = {
                    code: UPConstant.INTERNAL_ERROR_CODE,
                    name: UPConstant.ERROR_NAME,
                    message: UPConstant.INTERNAL_ERROR_MSG
                };
                if (m.responseCode === UPConstant.HTTP_CODE_200) {
                    let o = JSON.parse(m.result);
                    if (o.configs && o.sign) {
                        h.configs = o.configs;
                        h.sign = o.sign;
                        c(h);
                        return;
                    }
                }
                else {
                    n.code = m.responseCode;
                    n.message = m.result;
                }
                UPLogger.error('后台业务报错：' + JSON.stringify(n));
                d(n);
            }).catch((l) => {
                UPLogger.error('网络报错：' + JSON.stringify(l));
                d(l);
            });
        });
    }
}
