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

io.blockfrost.sdk.impl.MetricsServiceImpl Maven / Gradle / Ivy

There is a newer version: 0.1.3
Show newest version
package io.blockfrost.sdk.impl;

import io.blockfrost.sdk.api.MetricsService;
import io.blockfrost.sdk.api.exception.APIException;
import io.blockfrost.sdk.api.model.EndpointUsageMetric;
import io.blockfrost.sdk.api.model.UsageMetric;
import io.blockfrost.sdk.impl.retrofit.MetricsApi;
import retrofit2.Call;
import retrofit2.Response;

import java.io.IOException;
import java.util.List;

public class MetricsServiceImpl extends BaseService implements MetricsService {

    private MetricsApi metricsApi;

    public MetricsServiceImpl(String baseUrl, String projectId) {
        super(baseUrl, projectId);
        metricsApi = getRetrofit().create(MetricsApi.class);
    }

    @Override
    public List getUsageMetrics() throws APIException {
        Call> usageMetricsCall = metricsApi.metricsGet(getProjectId());

        try {
            Response> usageMetricsResponse = usageMetricsCall.execute();
            return processResponse(usageMetricsResponse);
        } catch (IOException exp) {
            throw new APIException("Exception while fetching usage metrics", exp);
        }
    }

    @Override
    public List getEndpointUsageMetrics() throws APIException {
        Call> endpointUsageMetricsCall = metricsApi.metricsEndpointsGet(getProjectId());

        try {
            Response> endpointUsageMetricsResponse = endpointUsageMetricsCall.execute();
            return processResponse(endpointUsageMetricsResponse);
        } catch (IOException exp) {
            throw new APIException("Exception while fetching endpoint usage metrics", exp);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy