All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.shib.java.lib.telegram.bot.service.BotServiceWrapper Maven / Gradle / Ivy

There is a newer version: 1.3.7
Show newest version
package me.shib.java.lib.telegram.bot.service;

import me.shib.java.lib.common.utils.JsonLib;
import me.shib.java.lib.rest.client.Parameter;
import me.shib.java.lib.rest.client.ServiceAdapter;
import me.shib.java.lib.rest.client.ServiceResponse;

import java.io.IOException;
import java.util.ArrayList;

public class BotServiceWrapper {

    private ServiceAdapter serviceAdapter;
    private JsonLib jsonLib;
    public BotServiceWrapper(String endPoint, JsonLib jsonLib) {
        serviceAdapter = new ServiceAdapter(endPoint);
        this.jsonLib = jsonLib;
    }

    public BotServiceResponse post(String apiName, ArrayList params) throws IOException {
        ServiceResponse serviceResponse = serviceAdapter.post(apiName, params);
        if (serviceResponse.getStatusCode() != 200) {
            return null;
        }
        return jsonLib.fromJson(serviceResponse.getResponse(), BotServiceResponse.class);
    }

    public class BotServiceResponse {
        private boolean ok;
        private Object result;

        private BotServiceResponse() {
            this.ok = false;
            this.result = null;
        }

        public boolean isOk() {
            return ok;
        }

        public Object getResult() {
            return result;
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy