001package com.plivo.api.models.number; 002 003import com.plivo.api.exceptions.PlivoRestException; 004import com.plivo.api.models.base.Creator; 005import com.plivo.api.util.Utils; 006import java.io.IOException; 007import java.util.ArrayList; 008import java.util.List; 009import retrofit2.Call; 010 011public class NumberCreator extends Creator<NumberCreateResponse> { 012 013 private List<String> numbers = new ArrayList<>(); 014 private String carrier; 015 private String region; 016 private NumberType numberType; 017 private String appId; 018 private String subaccount; 019 020 NumberCreator(List<String> numbers, String carrier, String region) { 021 if (!Utils.allNotNull(carrier, numbers, region)) { 022 throw new IllegalStateException("carrier, numbers and region are required"); 023 } 024 025 this.numbers = numbers; 026 this.carrier = carrier; 027 this.region = region; 028 } 029 030 public List<String> numbers() { 031 return this.numbers; 032 } 033 034 public String carrier() { 035 return this.carrier; 036 } 037 038 public String region() { 039 return this.region; 040 } 041 042 public NumberType numberType() { 043 return this.numberType; 044 } 045 046 public String appId() { 047 return this.appId; 048 } 049 050 public String subaccount() { 051 return this.subaccount; 052 } 053 054 public NumberCreator numberType(final NumberType numberType) { 055 this.numberType = numberType; 056 return this; 057 } 058 059 public NumberCreator appId(final String appId) { 060 this.appId = appId; 061 return this; 062 } 063 064 public NumberCreator subaccount(final String subaccount) { 065 this.subaccount = subaccount; 066 return this; 067 } 068 069 @Override 070 protected Call<NumberCreateResponse> obtainCall() { 071 return client().getApiService().numberCreate(client().getAuthId(), this); 072 } 073 074 public NumberCreateResponse add() throws IOException, PlivoRestException { 075 return create(); 076 } 077}