package com.base.scanqrclear.otherscan

import okhttp3.MediaType.Companion.toMediaType
import okhttp3.MultipartBody
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File

class CoinScan {


    fun coinScan(file1: String, file2: String) {


        val client = OkHttpClient()

        val mediaType = "multipart/form-data".toMediaType()
        val body = MultipartBody.Builder().setType(MultipartBody.FORM)
            .addFormDataPart(
                "token",
                "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIzZjc3ZmI3My00MjRkLTRiZmQtOTJiZi1kNWQ4NTI3OWUxOTEiLCJpYXQiOjE3MzcxMDUxOTYsInN1YiI6IjEyNzkyNDYifQ.4tIzKxyoZelPOOBjTIi9FFIoC4ednEvnYWy-ixXl2zw"
            )
            .addFormDataPart("device_id", "00197a13-b91d-456c-a6f4-1b30af93575b")
            .addFormDataPart("app_version", "10012500")
            .addFormDataPart("package_name", "com.healthapplines.scanner.ai")
            .addFormDataPart("lang", "en")
            .addFormDataPart("category", "banknote")
            .addFormDataPart("mime_type", "image/jpeg")
            .addFormDataPart(
                "file1", "dollar1.jpg",
                File("xxxxxxxxx.jpg").asRequestBody("image/jpeg".toMediaType())
            )
            .addFormDataPart(
                "file2", "dollar2.jpg",
                File("xxxxxxx.jpg").asRequestBody("image/jpeg".toMediaType())
            )
            .build()

        val request = Request.Builder()
            .url("https://api.qrbs.healthapplines.com/api/image/coinCheck")
            .post(body)
            .addHeader("User-Agent", "okhttp/4.10.0")
            .addHeader("Accept-Encoding", "gzip")
            .addHeader(
                "base",
                "{\"device_id\":\"00197a13-b91d-456c-a6f4-1b30af93575b\",\"platform\":\"1\",\"device_model\":\"Xiaomi MI 8 Lite\",\"app_lang\":\"en\",\"sys_lang\":\"en\",\"client_version\":\"1.25.0\",\"inner_version\":10012500,\"sys_version\":\"9\",\"channel\":\"\",\"country\":\"US\",\"time_zone\":\"GMT-6\",\"package_name\":\"com.healthapplines.scanner.ai\",\"guid\":\"00197a13-b91d-456c-a6f4-1b30af93575b\",\"network_type\":\"NETWORK_WIFI\"}"
            )
            .addHeader("version", "10001")
            .addHeader("nonce", "f1fuPCiqRq")
            .addHeader("timestamp", "1737355412033")
            .addHeader(
                "token",
                "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIzZjc3ZmI3My00MjRkLTRiZmQtOTJiZi1kNWQ4NTI3OWUxOTEiLCJpYXQiOjE3MzcxMDUxOTYsInN1YiI6IjEyNzkyNDYifQ.4tIzKxyoZelPOOBjTIi9FFIoC4ednEvnYWy-ixXl2zw"
            )
            .addHeader("sign", "31A65DEECDC49CDA7A0B81AFAAAB3B73")
            .addHeader("content-type", "multipart/form-data; boundary=d7998c33-276d-4954-90eb-206aa9a0abf7")
            .build()

        val response = client.newCall(request).execute()
    }
}