001package com.plivo.api.models.application;
002
003import com.plivo.api.models.base.VoiceCreator;
004import com.plivo.api.util.Utils;
005import retrofit2.Call;
006
007public class ApplicationCreator extends VoiceCreator<ApplicationCreateResponse> {
008
009  private String appName;
010  private String answerUrl;
011  private String answerMethod;
012  private String hangupUrl;
013  private String hangupMethod;
014  private String fallbackAnswerUrl;
015  private String fallbackMethod;
016  private String messageUrl;
017  private String messageMethod;
018  private Boolean defaultNumberApp;
019  private Boolean defaultEndpointApp;
020  private String subaccount;
021  private Boolean logIncomingMessages;
022  private Boolean publicUri;
023
024  /**
025   * @param appName The name of your application
026   */
027  ApplicationCreator(String appName) {
028    if (!Utils.allNotNull(appName)) {
029      throw new IllegalArgumentException("appName and answerUrl must not be null");
030    }
031
032    this.appName = appName;
033  }
034
035  public String appName() {
036    return this.appName;
037  }
038
039  public String answerUrl() {
040    return this.answerUrl;
041  }
042
043  public String answerMethod() {
044    return this.answerMethod;
045  }
046
047  public String hangupUrl() {
048    return this.hangupUrl;
049  }
050
051  public String hangupMethod() {
052    return this.hangupMethod;
053  }
054
055  public String fallbackAnswerUrl() {
056    return this.fallbackAnswerUrl;
057  }
058
059  public String fallbackMethod() {
060    return this.fallbackMethod;
061  }
062
063  public String messageUrl() {
064    return this.messageUrl;
065  }
066
067  public String messageMethod() {
068    return this.messageMethod;
069  }
070
071  public Boolean defaultNumberApp() {
072    return this.defaultNumberApp;
073  }
074
075  public Boolean defaultEndpointApp() {
076    return this.defaultEndpointApp;
077  }
078
079  public String subaccount() {
080    return this.subaccount;
081  }
082
083  public Boolean logIncomingMessages() {
084    return this.logIncomingMessages;
085  }
086
087  public Boolean publicUri() {
088    return this.publicUri;
089  }
090
091  public ApplicationCreator appName(final String appName) {
092    this.appName = appName;
093    return this;
094  }
095
096  public ApplicationCreator answerUrl(final String answerUrl) {
097    this.answerUrl = answerUrl;
098    return this;
099  }
100
101  public ApplicationCreator answerMethod(final String answerMethod) {
102    this.answerMethod = answerMethod;
103    return this;
104  }
105
106  public ApplicationCreator hangupUrl(final String hangupUrl) {
107    this.hangupUrl = hangupUrl;
108    return this;
109  }
110
111  public ApplicationCreator hangupMethod(final String hangupMethod) {
112    this.hangupMethod = hangupMethod;
113    return this;
114  }
115
116  public ApplicationCreator fallbackAnswerUrl(final String fallbackAnswerUrl) {
117    this.fallbackAnswerUrl = fallbackAnswerUrl;
118    return this;
119  }
120
121  public ApplicationCreator fallbackMethod(final String fallbackMethod) {
122    this.fallbackMethod = fallbackMethod;
123    return this;
124  }
125
126  public ApplicationCreator messageUrl(final String messageUrl) {
127    this.messageUrl = messageUrl;
128    return this;
129  }
130
131  public ApplicationCreator messageMethod(final String messageMethod) {
132    this.messageMethod = messageMethod;
133    return this;
134  }
135
136  public ApplicationCreator defaultNumberApp(final Boolean defaultNumberApp) {
137    this.defaultNumberApp = defaultNumberApp;
138    return this;
139  }
140
141  public ApplicationCreator defaultEndpointApp(final Boolean defaultEndpointApp) {
142    this.defaultEndpointApp = defaultEndpointApp;
143    return this;
144  }
145
146  public ApplicationCreator subaccount(final String subaccount) {
147    this.subaccount = subaccount;
148    return this;
149  }
150
151  public ApplicationCreator logIncomingMessages(final Boolean logIncomingMessages) {
152    this.logIncomingMessages = logIncomingMessages;
153    return this;
154  }
155
156  public ApplicationCreator publicUri(final Boolean publicUri) {
157    this.publicUri = publicUri;
158    return this;
159  }
160
161  @Override
162  protected Call<ApplicationCreateResponse> obtainCall() {
163    return client().getVoiceApiService().applicationCreate(client().getAuthId(), this);
164  }
165
166  @Override
167  protected Call<ApplicationCreateResponse> obtainFallback1Call() {
168    return client().getVoiceFallback1Service().applicationCreate(client().getAuthId(), this);
169  }
170
171  @Override
172  protected Call<ApplicationCreateResponse> obtainFallback2Call() {
173    return client().getVoiceFallback2Service().applicationCreate(client().getAuthId(), this);
174  }
175}