package com.qmth.boot.core.solar.config;

import com.qmth.boot.core.retrofit.interfaces.CustomizeRetrofitConfiguration;
import com.qmth.boot.core.retrofit.interfaces.SignatureProvider;
import com.qmth.boot.tools.signature.SignatureType;

public class SolarApiConfiguration implements CustomizeRetrofitConfiguration {

    private SolarProperties solarProperties;

    public SolarApiConfiguration(SolarProperties solarProperties) {
        this.solarProperties = solarProperties;
    }

    public String getBaseUrl() {
        return solarProperties.getServer() + "/api/open/";
    }

    public SignatureProvider getSignature() {
        return new SignatureProvider() {

            @Override
            public SignatureType getType() {
                return SignatureType.SECRET;
            }

            @Override
            public String getIdentity() {
                return solarProperties.getAccessKey();
            }

            @Override
            public String getSecret() {
                return solarProperties.getAccessSecret();
            }
        };
    }
}
