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

io.convergence_platform.services.infrastructure.EmailService Maven / Gradle / Ivy

Go to download

Holds the common functionality needed by all Convergence Platform-based services written in Java.

The newest version!
package io.convergence_platform.services.infrastructure;

import io.convergence_platform.common.dto.AtomicValueDTO;
import io.convergence_platform.common.responses.ApiResponse;
import io.convergence_platform.services.infrastructure.dto.SendEmailRequest;
import io.convergence_platform.services.services.BaseRetrofitExternalService;
import retrofit2.Response;
import retrofit2.http.Body;

public class EmailService extends BaseRetrofitExternalService {
    public EmailService(String discoveryServerUrl, String jwt) {
        super(discoveryServerUrl, "email-service", jwt);
    }

    @Override
    protected Class getApiInterface() {
        return IEmailServiceAPI.class;
    }

    public ApiResponse> send(@Body SendEmailRequest request) {
        ApiResponse> result = null;
        Response>> callResponse = null;

        try {
            callResponse = externalService.send(request).execute();
            if (callResponse.isSuccessful()) {
                result = callResponse.body();
            } else {
                result = loadFailureInfo(callResponse.errorBody(), null, new ApiResponse>());
            }
        } catch (Exception ex) {
            result = loadFailureInfo(null, ex, new ApiResponse>());
        }

        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy