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

com.global.api.services.RecurringService Maven / Gradle / Ivy

There is a newer version: 14.2.3
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy