package com.fear1ess.reyunaditool.adsfinder;

import com.fear1ess.reyunaditool.HttpParser;
import com.fear1ess.reyunaditool.IDoCommandService;

import java.util.HashMap;
import java.util.Map;

public class IronSourceFinder extends Finder {
    public IronSourceFinder(String adsClassName, String adsName, ClassLoader cl, IDoCommandService service) {
        super(adsClassName, adsName, cl, service);
    }

    @Override
    public void hookAdsApi() {
        registerSSLHook(new SSLOutputStreamHookedCallback() {
            @Override
            public void onSSLOutputStreamHooked(HttpParser hp) {
                if(!hp.getMethod().equals("GET")) return;
                if(!hp.getPath().contains("/gateway/sdk/request")) return;
                String applicationKey = hp.getUrlParam("applicationKey");
                if(applicationKey != null) {
                    Map<String,String> map = new HashMap<>();
                    map.put("applicationKey", applicationKey);
                    uploadAdsData(map);
                }
            }
        });
    }
}
