LINE.apk(点击下载) / d.java


package ou1;

import com.google.android.exoplayer.DefaultLoadControl;
import com.google.gson.Gson;
import com.linecorp.line.constants.BuildConfig;
import em3.q;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.util.Objects;
import jz2.b;
import ln.r0;

public final class d {

    /* renamed from: a  reason: collision with root package name */
    public final String f124737a;

    public /* synthetic */ class a {
        public static final /* synthetic */ int[] $EnumSwitchMapping$0;

        static {
            int[] iArr = new int[b.values().length];
            iArr[b.RC.ordinal()] = 1;
            iArr[b.RELEASE.ordinal()] = 2;
            $EnumSwitchMapping$0 = iArr;
        }
    }

    public d() {
        String str = BuildConfig.APP_PHASE;
        q.e(str, "APP_PHASE");
        int i14 = a.$EnumSwitchMapping$0[b.valueOf(str).ordinal()];
        this.f124737a = (i14 == 1 || i14 == 2) ? "https://gw.ipasspay.com.tw/line" : "https://eprelaytest.ipasspay.com.tw/line";
    }

    public final c a(String str, String str2, String str3) {
        HttpURLConnection httpURLConnection = null;
        try {
            HttpURLConnection b14 = b(str);
            b14.setDoOutput(true);
            com.google.gson.d dVar = new com.google.gson.d();
            dVar.f31691m = false;
            String o14 = dVar.a().o(new b(str2, str3));
            q.e(o14, "GsonBuilder().disableHtm…      )\n                )");
            Charset forName = Charset.forName("utf-8");
            q.e(forName, "forName(charsetName)");
            byte[] bytes = o14.getBytes(forName);
            q.e(bytes, "this as java.lang.String).getBytes(charset)");
            b14.getOutputStream().write(bytes);
            b14.getOutputStream().flush();
            Gson gson = new Gson();
            InputStream inputStream = b14.getInputStream();
            q.e(inputStream, "connection.inputStream");
            byte[] c14 = am3.b.c(inputStream);
            Charset forName2 = Charset.forName("utf-8");
            q.e(forName2, "forName(charsetName)");
            c cVar = (c) k1.a.s(c.class).cast(gson.g(new String(c14, forName2), c.class));
            b14.getResponseCode();
            Objects.toString(cVar);
            if (b14.getResponseCode() != 200 || !cVar.c().equals("0000000")) {
                throw new Exception(cVar.d());
            }
            b14.disconnect();
            return cVar;
        } catch (Exception e14) {
            throw e14;
        } catch (Throwable th4) {
            if (0 != 0) {
                httpURLConnection.disconnect();
            }
            throw th4;
        }
    }

    public final HttpURLConnection b(String str) {
        URLConnection openConnection = new URL(r0.a(new StringBuilder(), this.f124737a, "/v1/common/balance-inquiry-not-login")).openConnection();
        Objects.requireNonNull(openConnection, "null cannot be cast to non-null type java.net.HttpURLConnection");
        HttpURLConnection httpURLConnection = (HttpURLConnection) openConnection;
        httpURLConnection.setRequestMethod("POST");
        httpURLConnection.setConnectTimeout(5000);
        httpURLConnection.setReadTimeout(DefaultLoadControl.DEFAULT_HIGH_WATERMARK_MS);
        httpURLConnection.setRequestProperty("X-iPASS-LINEPayUserId", str);
        httpURLConnection.setRequestProperty("X-iPASS-ModuleVersion", "1.1.0");
        httpURLConnection.setRequestProperty("Content-Type", "application/json; charset=utf-8");
        return httpURLConnection;
    }
}