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

io.getstream.core.options.RankingVars Maven / Gradle / Ivy

There is a newer version: 3.15.0
Show newest version
package io.getstream.core.options;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.getstream.core.http.Request;
import java8.util.concurrent.CompletionException;

import java.io.IOException;
import java.util.Map;

public final class RankingVars implements RequestOption{

    private final String rankingVarsJSON;

    public RankingVars(Map externalVars) {
        String rankingVarsJSON;
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            rankingVarsJSON = objectMapper.writeValueAsString(externalVars);
        }
        catch (IOException e){
            throw new CompletionException(e);
        }

        this.rankingVarsJSON = rankingVarsJSON;
    }

    public String getRankingVars() {
        return rankingVarsJSON;
    }

    @Override
    public void apply(Request.Builder builder) {
        builder.addQueryParameter("ranking_vars", rankingVarsJSON);
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy