All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.ingenico.direct.merchant.tokens.TokensClient Maven / Gradle / Ivy
/*
* This class was auto-generated from the API references found at
* https://support.direct.ingenico.com/documentation/api/reference
*/
package com.ingenico.direct.merchant.tokens;
import java.util.Map;
import java.util.TreeMap;
import com.ingenico.direct.ApiException;
import com.ingenico.direct.ApiResource;
import com.ingenico.direct.AuthorizationException;
import com.ingenico.direct.CallContext;
import com.ingenico.direct.DirectException;
import com.ingenico.direct.IdempotenceException;
import com.ingenico.direct.ReferenceException;
import com.ingenico.direct.ResponseException;
import com.ingenico.direct.ValidationException;
import com.ingenico.direct.domain.CreateTokenRequest;
import com.ingenico.direct.domain.CreatedTokenResponse;
import com.ingenico.direct.domain.ErrorResponse;
import com.ingenico.direct.domain.TokenResponse;
/**
* Tokens client. Thread-safe.
*/
public class TokensClient extends ApiResource implements TokensClientInterface {
public TokensClient(ApiResource parent, Map pathContext) {
super(parent, pathContext);
}
/**
* {@inheritDoc}
*/
@Override
public CreatedTokenResponse createToken(CreateTokenRequest body) {
return createToken(body, null);
}
/**
* {@inheritDoc}
*/
@Override
public CreatedTokenResponse createToken(CreateTokenRequest body, CallContext context) {
String uri = instantiateUri("/v2/{merchantId}/tokens", null);
try {
return communicator.post(
uri,
getClientHeaders(),
null,
body,
CreatedTokenResponse.class,
context);
} catch (ResponseException e) {
final Class errorType = ErrorResponse.class;
final Object errorObject = communicator.getMarshaller().unmarshal(e.getBody(), errorType);
throw createException(e.getStatusCode(), e.getBody(), errorObject, context);
}
}
/**
* {@inheritDoc}
*/
@Override
public TokenResponse getToken(String tokenId) {
return getToken(tokenId, null);
}
/**
* {@inheritDoc}
*/
@Override
public TokenResponse getToken(String tokenId, CallContext context) {
Map pathContext = new TreeMap();
pathContext.put("tokenId", tokenId);
String uri = instantiateUri("/v2/{merchantId}/tokens/{tokenId}", pathContext);
try {
return communicator.get(
uri,
getClientHeaders(),
null,
TokenResponse.class,
context);
} catch (ResponseException e) {
final Class errorType = ErrorResponse.class;
final Object errorObject = communicator.getMarshaller().unmarshal(e.getBody(), errorType);
throw createException(e.getStatusCode(), e.getBody(), errorObject, context);
}
}
/**
* {@inheritDoc}
*/
@Override
public void deleteToken(String tokenId) {
deleteToken(tokenId, null);
}
/**
* {@inheritDoc}
*/
@Override
public void deleteToken(String tokenId, CallContext context) {
Map pathContext = new TreeMap();
pathContext.put("tokenId", tokenId);
String uri = instantiateUri("/v2/{merchantId}/tokens/{tokenId}", pathContext);
try {
communicator.delete(
uri,
getClientHeaders(),
null,
void.class,
context);
} catch (ResponseException e) {
final Class errorType = ErrorResponse.class;
final Object errorObject = communicator.getMarshaller().unmarshal(e.getBody(), errorType);
throw createException(e.getStatusCode(), e.getBody(), errorObject, context);
}
}
}