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

com.twilio.TwilioNoAuth Maven / Gradle / Ivy

There is a newer version: 7.9.1
Show newest version
package com.twilio;

import com.twilio.annotations.Beta;
import com.twilio.http.noauth.NoAuthTwilioRestClient;
import lombok.Getter;

import java.util.List;
import com.twilio.exception.AuthenticationException;

@Beta
public class TwilioNoAuth {
    @Getter
    private static List userAgentExtensions;
    private static String region = System.getenv("TWILIO_REGION");
    private static String edge = System.getenv("TWILIO_EDGE");

    private static volatile NoAuthTwilioRestClient noAuthTwilioRestClient;

    private TwilioNoAuth() {
    }

    public static NoAuthTwilioRestClient getRestClient() {
        if (TwilioNoAuth.noAuthTwilioRestClient == null) {
            synchronized (TwilioNoAuth.class) {
                if (TwilioNoAuth.noAuthTwilioRestClient == null) {
                    TwilioNoAuth.noAuthTwilioRestClient = buildOAuthRestClient();
                }
            }
        }
        return TwilioNoAuth.noAuthTwilioRestClient;
    }

    private static NoAuthTwilioRestClient buildOAuthRestClient() {

        NoAuthTwilioRestClient.Builder builder = new NoAuthTwilioRestClient.Builder();

        if (userAgentExtensions != null) {
            builder.userAgentExtensions(TwilioNoAuth.userAgentExtensions);
        }

        builder.region(TwilioNoAuth.region);
        builder.edge(TwilioNoAuth.edge);

        return builder.build();
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy