001package com.plivo.api; 002 003import com.plivo.api.models.base.LogLevel; 004import okhttp3.OkHttpClient; 005 006public class Plivo { 007 008 private static PlivoClient plivoInstance = null; 009 private static PlivoClient phloInstance = null; 010 011 /** 012 * Initializes the global {@link PlivoClient} plivoInstance 013 */ 014 public static synchronized void init(String authId, String authToken) { 015 plivoInstance = new PlivoClient(authId, authToken); 016 phloInstance = new PhloRestClient(authId, authToken).getClient(); 017 } 018 019 public static synchronized void init(String authId, String authToken, OkHttpClient.Builder httpClientBuilder) { 020 plivoInstance = new PlivoClient(authId, authToken, httpClientBuilder); 021 } 022 023 public static synchronized void init(String authId, String authToken, LogLevel logLevel) { 024 plivoInstance = new PlivoClient(authId, authToken, logLevel); 025 phloInstance = new PhloRestClient(authId, authToken).getClient(); 026 } 027 028 public static synchronized void init(String authId, String authToken, OkHttpClient.Builder httpClientBuilder, 029 LogLevel logLevel) { 030 plivoInstance = new PlivoClient(authId, authToken, httpClientBuilder, logLevel); 031 } 032 033 /** 034 * Initializes the global {@link PlivoClient} plivoInstance, taking the authId and authToken from 035 * environment variables called PLIVO_AUTH_ID and PLIVO_AUTH_TOKEN. 036 */ 037 public static synchronized void init() { 038 init(System.getenv("PLIVO_AUTH_ID"), System.getenv("PLIVO_AUTH_TOKEN")); 039 } 040 041 public static PlivoClient getClient() { 042 return plivoInstance; 043 } 044 045 public static PlivoClient getPhloClient() { 046 return phloInstance; 047 } 048}