com.ingenico.connect.gateway.sdk.java.MetaDataProviderBuilder Maven / Gradle / Ivy
package com.ingenico.connect.gateway.sdk.java;
import java.util.ArrayList;
import java.util.List;
import com.ingenico.connect.gateway.sdk.java.domain.metadata.ShoppingCartExtension;
/**
* Builder for a {@link MetaDataProvider} object.
*/
public class MetaDataProviderBuilder {
final String integrator;
ShoppingCartExtension shoppingCartExtension;
final List additionalRequestHeaders = new ArrayList();
/**
* @param integrator The integrator to use.
*/
public MetaDataProviderBuilder(String integrator) {
this.integrator = integrator;
}
/**
* Sets the shopping cart extension to use.
*/
public MetaDataProviderBuilder withShoppingCartExtension(ShoppingCartExtension shoppingCartExtension) {
this.shoppingCartExtension = shoppingCartExtension;
return this;
}
/**
* Adds an additional request header.
* The following names are prohibited in these additional request headers, because these will be set automatically
* as needed:
*
* - X-GCS-ServerMetaInfo
* - X-GCS-ClientMetaInfo
* - X-GCS-Idempotence-Key
* - Date
* - Content-Type
* - Authorization
*
*/
public MetaDataProviderBuilder withAdditionalRequestHeader(RequestHeader additionalRequestHeader) {
MetaDataProvider.validateAdditionalRequestHeader(additionalRequestHeader);
additionalRequestHeaders.add(additionalRequestHeader);
return this;
}
/**
* Creates a fully initialized {@link MetaDataProvider} object.
*/
public MetaDataProvider build() {
return new MetaDataProvider(this);
}
}