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

com.github.jamesnetherton.zulip.client.api.stream.request.GetStreamIdApiRequest Maven / Gradle / Ivy

The newest version!
package com.github.jamesnetherton.zulip.client.api.stream.request;

import static com.github.jamesnetherton.zulip.client.api.stream.request.StreamRequestConstants.STREAM_ID;

import com.github.jamesnetherton.zulip.client.api.core.ExecutableApiRequest;
import com.github.jamesnetherton.zulip.client.api.core.ZulipApiRequest;
import com.github.jamesnetherton.zulip.client.api.stream.response.GetStreamIdApiResponse;
import com.github.jamesnetherton.zulip.client.exception.ZulipClientException;
import com.github.jamesnetherton.zulip.client.http.ZulipHttpClient;

/**
 * Zulip API request builder for getting the id of a stream.
 *
 * @see https://zulip.com/api/get-stream-id
 */
public class GetStreamIdApiRequest extends ZulipApiRequest implements ExecutableApiRequest {

    public static final String STREAM = "stream";

    /**
     * Constructs a {@link GetStreamsApiRequest}.
     *
     * @param client The Zulip HTTP client
     * @param stream The name of the stream
     */
    public GetStreamIdApiRequest(ZulipHttpClient client, String stream) {
        super(client);
        putParam(STREAM, stream);
    }

    /**
     * Executes the Zulip API request for getting the id of a stream.
     *
     * @return                      The stream id
     * @throws ZulipClientException if the request was not successful
     */
    @Override
    public Long execute() throws ZulipClientException {
        return client().get(STREAM_ID, getParams(), GetStreamIdApiResponse.class).getStreamId();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy