package com.iqser.red.service.peristence.v1.server.integration.utils;

import org.springframework.stereotype.Component;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.RequiredArgsConstructor;

@Component
@RequiredArgsConstructor
public class FeignRequestInterceptor implements RequestInterceptor {

    private final TokenService tokenService;

    public static final String TENANT_HEADER_NAME = "X-TENANT-ID";


    @Override
    public void apply(RequestTemplate requestTemplate) {

        var token = tokenService.getToken();
        requestTemplate.header("Authorization", "basic " + token);
        requestTemplate.header(TENANT_HEADER_NAME, "redaction");
    }

}
