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

com.wallee.sdk.DefaultHeaders Maven / Gradle / Ivy

There is a newer version: 8.1.1
Show newest version
package com.wallee.sdk;

import com.google.api.client.http.HttpExecuteInterceptor;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpRequest;

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

/**
* Default headers interceptor
*/
public class DefaultHeaders {

    private final Map defaultHeaders;

    /**
    *
    * @param defaultHeaders default headers
    */
    public DefaultHeaders(Map defaultHeaders) {
        this.defaultHeaders = defaultHeaders;
    }

    /**
    * Intercept given http request
    * @param request
    * @throws IOException
    */
    public void intercept(HttpRequest request) throws IOException {
        request.getHeaders().putAll(getDefaultHeaders());
        defaultHeaders.forEach((key, value) -> request.getHeaders().putIfAbsent(key, value));
    }

    private HttpHeaders getDefaultHeaders() {
        HttpHeaders headers = new HttpHeaders();
        headers.put("x-meta-sdk-version", "6.0.3");
        headers.put("x-meta-sdk-language", "java");
        headers.put("x-meta-sdk-provider", "wallee");
        headers.put("x-meta-sdk-language-version", System.getProperty("java.version"));
        return headers;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy