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

jp.gopay.sdk.builders.transactiontoken.TransactionTokensBuilders Maven / Gradle / Ivy

There is a newer version: 0.11.17
Show newest version
package jp.gopay.sdk.builders.transactiontoken;

import jp.gopay.sdk.builders.transactiontoken.AbstractTransactionTokensBuilders.*;
import jp.gopay.sdk.models.common.*;
import jp.gopay.sdk.models.common.Void;
import jp.gopay.sdk.models.request.transactiontoken.*;
import jp.gopay.sdk.models.request.transactiontoken.PaymentData;
import jp.gopay.sdk.models.response.GoPayBinaryData;
import jp.gopay.sdk.models.response.PaginatedList;
import jp.gopay.sdk.models.response.transactiontoken.*;
import jp.gopay.sdk.resources.TransactionTokensResource;
import jp.gopay.sdk.types.TemporaryTokenAliasMedia;
import jp.gopay.sdk.types.TransactionTokenType;
import retrofit2.Call;
import retrofit2.Retrofit;

public abstract class TransactionTokensBuilders {

    public static class DeleteTransactionTokenRequestBuilder
            extends AbstractDeleteTransactionTokenRequestBuilder{

        public DeleteTransactionTokenRequestBuilder(Retrofit retrofit, StoreId storeId, TransactionTokenId transactionTokenId) {
            super(retrofit, storeId, transactionTokenId);
        }

        @Override
        protected Call getRequest(TransactionTokensResource resource) {
            return resource.delete(storeId,transactionTokenId);
        }
    }

    public static class GetTransactionTokenRequestBuilder
            extends AbstractGetTransactionTokenRequestBuilder{

        public GetTransactionTokenRequestBuilder(Retrofit retrofit, StoreId storeId, TransactionTokenId transactionTokenId) {
            super(retrofit, storeId, transactionTokenId);
        }

        @Override
        protected Call getRequest(TransactionTokensResource resource) {
            return resource.get(storeId, transactionTokenId);
        }
    }

    public static class CreateTransactionTokenRequestBuilder
            extends AbstractCreateTransactionTokenRequestBuilder{

        public CreateTransactionTokenRequestBuilder(Retrofit retrofit, GoPayEmailAddress email, PaymentData paymentData, TransactionTokenType type) {
            super(retrofit, email, paymentData, type);
        }

        @Override
        protected Call getRequest(TransactionTokensResource resource) {
            CreateReq dataToPost = new CreateReq(email, type, usageLimit, metadata, useConfirmation, paymentData);

            return resource.create(dataToPost, idempotencyKey);
        }
    }

    public static class UpdateTransactionTokenRequestBuilder
            extends AbstractUpdateTransactionTokenRequestBuilder{

        public UpdateTransactionTokenRequestBuilder(Retrofit retrofit, StoreId storeId, TransactionTokenId transactionTokenId) {
            super(retrofit, storeId, transactionTokenId);
        }

        @Override
        protected Call getRequest(TransactionTokensResource resource) {
            UpdateReq dataToPost = new UpdateReq(email, metadata, cvv);
            return resource.update(storeId, transactionTokenId, dataToPost, idempotencyKey);
        }
    }

    public static class ListTransactionTokensRequestBuilder
            extends AbstractListTransactionTokensRequestBuilder{

        public ListTransactionTokensRequestBuilder(Retrofit retrofit, StoreId storeId) {
            super(retrofit, storeId);
        }

        @Override
        protected Call> getRequest(TransactionTokensResource resource){
            return resource.list(storeId, getLimit(), getCursorDirection(), getCursor(), all, search, mode, type, customerId);
        }
    }

    public static class ListTransactionTokensMerchantRequestBuilder
            extends AbstractListTransactionTokensMerchantRequestBuilder{

        public ListTransactionTokensMerchantRequestBuilder(Retrofit retrofit) {
            super(retrofit);
        }

        @Override
        protected Call> getRequest(TransactionTokensResource resource){
            return resource.listMerchant(getLimit(), getCursorDirection(), getCursor(), all, search, mode, type, customerId);
        }
    }

    public static class CreateTemporaryTokenAliasRequestBuilder
            extends AbstractCreateTemporaryTokenAliasRequestBuilder{

        public CreateTemporaryTokenAliasRequestBuilder(Retrofit retrofit, TransactionTokenId transactionTokenId) {
            super(retrofit, transactionTokenId);
        }

        @Override
        protected Call getRequest(TransactionTokensResource resource) {

            TemporaryTokenAliasReq requestData;
            if(money == null){
                requestData = new TemporaryTokenAliasReq(
                        transactionTokenId,
                        validUntil,
                        metadata
                );
            } else {
                requestData = new TemporaryTokenAliasReq(
                        transactionTokenId,
                        validUntil,
                        metadata,
                        money
                );
            }

            return resource.createAlias(
                    requestData,
                    getIdempotencyKey()
            );
        }
    }

    public static class GetTemporaryTokenAliasRequestBuilder
            extends AbstractGetTemporaryTokenAliasRequestBuilder{

        public GetTemporaryTokenAliasRequestBuilder(Retrofit retrofit, StoreId storeId, TokenAliasKey aliasKey) {
            super(retrofit, storeId, aliasKey);
        }

        @Override
        protected Call getRequest(TransactionTokensResource resource) {
            return resource.getAlias(storeId, aliasKey);
        }

    }

    public static class GetTemporaryTokenAliasAsImageRequestBuilder
            extends AbstractGetTemporaryTokenAliasAsImageRequestBuilder{

        public GetTemporaryTokenAliasAsImageRequestBuilder(Retrofit retrofit, StoreId storeId, TokenAliasKey aliasKey) {
            super(retrofit, storeId, aliasKey);
        }

        @Override
        protected Call getRequest(TransactionTokensResource resource) {
            TemporaryTokenAliasDisplayReq requestData = new TemporaryTokenAliasDisplayReq(TemporaryTokenAliasMedia.QR, size, logoType, color);
            return resource.getAliasAsImage(storeId, aliasKey, requestData);
        }
    }

    public static class DeleteTemporaryTokenAliasRequestBuilder
            extends AbstractDeleteTemporaryTokenAliasRequestBuilder{

        public DeleteTemporaryTokenAliasRequestBuilder(Retrofit retrofit, StoreId storeId, TokenAliasKey aliasKey) {
            super(retrofit, storeId, aliasKey);
        }

        @Override
        protected Call getRequest(TransactionTokensResource resource) {
            return resource.deleteAlias(storeId, aliasKey);
        }
    }

    public static class ConfirmTransactionTokenRequestBuilder
            extends AbstractConfirmTransactionTokenRequestBuilder {

        public ConfirmTransactionTokenRequestBuilder(Retrofit retrofit, StoreId storeId, TransactionTokenId tokenId, String confirmationCode) {
            super(retrofit, storeId, tokenId, confirmationCode);
        }

        @Override
        protected Call getRequest(TransactionTokensResource resource) {
            return resource.confirm(storeId, tokenId, new ConfirmTransactionTokenReq(confirmationCode), idempotencyKey);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy