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

one.credify.sdk.impl.OfferServiceImpl Maven / Gradle / Ivy

package one.credify.sdk.impl;

import one.credify.sdk.exception.CredifyException;
import one.credify.sdk.OfferService;
import one.credify.sdk.dto.*;
import one.credify.sdk.enumeration.OnboardingReasonCode;
import one.credify.sdk.enumeration.OnboardingStatus;
import one.credify.sdk.restapi.CredifyRestV1;

import java.io.IOException;
import java.util.UUID;

public class OfferServiceImpl implements OfferService {
    private final CredifyRestV1 credifyClient;

    public OfferServiceImpl(CredifyRestV1 credifyClient) {
        this.credifyClient = credifyClient;
    }

    @Override
    public boolean updateStatus(UUID transactionId, OnboardingStatus status, FiatCurrency transactionAmount, FiatCurrency vat,
                                String referenceId, String description, OnboardingReasonCode code) throws IOException {
        UpdateOfferTransactionStatusRequest req = new UpdateOfferTransactionStatusRequest(
                status, transactionAmount, vat, referenceId, code, description
        );
        CredifyApiResponse response = this.credifyClient.updateOfferTransactionStatusForOidcClient(transactionId, req).execute().body();
        if (response == null || !response.isSuccess()) {
            throw new CredifyException("update offer transaction status failed");
        }
        return false;
    }

    @Override
    public Offer getOfferDetail(String offerCode) throws IOException {
        CredifyApiResponse response = this.credifyClient.getOffer(offerCode).execute().body();
        if (response == null || !response.isSuccess()) {
            throw new CredifyException("get offer detail failed");
        }
        return response.getData().getOffer();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy