package lookup;

import java.util.Optional;

import com.twilio.Twilio;
import com.twilio.rest.lookups.v1.PhoneNumber;

public class Lookup {
    
    public static final String ACCOUNT_SID = Optional.ofNullable(
        System.getenv("TWILIO_ACCOUNT_SID")).orElseThrow(
        () -> new IllegalArgumentException("TWILIO_ACCOUNT_SID is not set in the environment."));
    
    public static final String AUTH_TOKEN = Optional.ofNullable(
        System.getenv("TWILIO_AUTH_TOKEN")).orElseThrow(
        () -> new IllegalArgumentException("TWILIO_AUTH_TOKEN is not set in the environment."));

    public static void main(String[] args) {
        if(args.length == 0) {
            throw new IllegalArgumentException("Missing command line argument.");
        }

        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        String lookup_number = args[0];

        PhoneNumber number = PhoneNumber
            .fetcher(new com.twilio.type.PhoneNumber(lookup_number))
            .setType("carrier")
            .fetch();

        System.out.println("Carrier name: " + number.getCarrier().get("name"));
        System.out.println("Number type: " + number.getCarrier().get("type"));
    }
}
@@ -187,37 +187,8 @@
 ID =
- Optional.ofNullable(%0A       
  Sys
@@ -223,126 +223,10 @@
 ID%22)
-).orElseThrow(%0A        () -%3E new IllegalArgumentException(%22TWILIO_ACCOUNT_SID is not set in the environment.%22))
 ;%0A
-    %0A
     
@@ -268,37 +268,8 @@
 EN =
- Optional.ofNullable(%0A       
  Sys
@@ -303,118 +303,8 @@
 EN%22)
-).orElseThrow(%0A        () -%3E new IllegalArgumentException(%22TWILIO_AUTH_TOKEN is not set in the environment.%22))
 ;%0A%0A 

simplify getting env variables