package leigh.esp.goryu.service;

import leigh.eo.EO;
import leigh.eo.io.EOInputStream;
import leigh.esp.goryu.sdk.schema.v1.QueryElementDAO;
import leigh.esp.sdk.ESPClient;
import leigh.esp.sdk.link23.Link23Response;
import leigh.mecha.log.MechaLogger;
import leigh.mecha.log.MechaLoggerFactory;

public class ClientTester {
    private static final MechaLogger logger = MechaLoggerFactory.getLogger(ClientTester.class);

    public static void main(String[] args) throws Exception {
        ESPClient esp = new ESPClient("https://leigh-co.com");
        EO query = QueryElementDAO.create();
        QueryElementDAO.setQuery(query, "SELECT * FROM discounts");
        Link23Response response = esp.link23Request("/goryu_test", query);
        EOInputStream input = response.getResponseEoStream();
        while (true) {
            EO obj = input.readEo();
            if (obj == null) break;
            logger.info("Read response object: {}", obj);
        }
    }
}
