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

Explore the source code of the class SendDocumentRequest.java

package com.antonioaltieri.telegram.botapi.requests;

import com.antonioaltieri.telegram.botapi.types.Message;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class SendDocumentRequest implements ApiRequest {

    private Map args = new HashMap<>();
    private RequestStrategy requestStrategy;

    public SendDocumentRequest(long chatId, File document) {
        this(chatId, document, null);
    }

    public SendDocumentRequest(long chatId, File document, OptionalArgs optionalArgs) {
        args.put("chat_id", String.valueOf(chatId));

        if (optionalArgs != null)
            args.putAll(optionalArgs.options());

        requestStrategy = new MultipartStrategy(document, "document");
    }

    public SendDocumentRequest(long chatId, String document) {
        this(chatId, document, null);
    }

    public SendDocumentRequest(long chatId, String document, OptionalArgs optionalArgs) {
        args.put("chat_id", String.valueOf(chatId));
        args.put("document", document);

        if (optionalArgs != null)
            args.putAll(optionalArgs.options());

        requestStrategy = new PostStrategy();
    }

    @Override
    public String getMethodName() {
        return "sendDocument";
    }

    @Override
    public ResultTypes getResultType() {
        return ResultTypes.MESSAGE;
    }

    @Override
    public Map getArgs() {
        return args;
    }

    @Override
    public RequestStrategy getRequestStrategy() {
        return requestStrategy;
    }

    @Override
    public String toString() {
        return "SendDocumentRequest{" +
                "args=" + args +
                ", requestStrategy=" + requestStrategy +
                '}';
    }
}