com.global.api.services.RecurringService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of globalpayments-sdk Show documentation
Show all versions of globalpayments-sdk Show documentation
API for processing payments through Global Payments
package com.global.api.services;
import com.global.api.builders.RecurringBuilder;
import com.global.api.entities.IRecurringCollection;
import com.global.api.entities.IRecurringEntity;
import com.global.api.entities.enums.TransactionType;
import com.global.api.entities.exceptions.ApiException;
public class RecurringService {
public static T create(T entity, Class clazz) throws ApiException {
return create(entity, clazz, "default");
}
public static T create(T entity, Class clazz, String configName) throws ApiException {
return new RecurringBuilder(TransactionType.Create, entity, clazz).execute(configName);
}
public static T delete(T entity, Class clazz) throws ApiException {
return delete(entity, clazz, false);
}
public static T delete(T entity, Class clazz, boolean force) throws ApiException {
return delete(entity, clazz, false, "default");
}
public static T delete(T entity, Class clazz, boolean force, String configName) throws ApiException {
return
new RecurringBuilder(TransactionType.Delete, entity, clazz)
.withForceDelete(force)
.execute(configName);
}
public static T edit(T entity, Class clazz) throws ApiException {
return edit(entity, clazz, "default");
}
public static T edit(T entity, Class clazz, String configName) throws ApiException {
return new RecurringBuilder(TransactionType.Edit, entity, clazz).execute(configName);
}
public static T get(String key, Class clazz) throws ApiException {
return get(key, clazz, "default");
}
public static T get(String key, Class clazz, String configName) throws ApiException {
IRecurringEntity entity;
try {
entity = clazz.newInstance();
entity.setKey(key);
} catch (Exception e) {
throw new ApiException(e.getMessage(), e);
}
return
new RecurringBuilder(TransactionType.Fetch, entity, clazz)
.withKey(key)
.execute(configName);
}
public static RecurringBuilder search(Class clazz) throws ApiException {
return new RecurringBuilder(TransactionType.Search, clazz);
}
public static RecurringBuilder search(IRecurringEntity entity, Class clazz) throws ApiException {
return new RecurringBuilder(TransactionType.Search, entity, clazz);
}
}