001package com.plivo.api.models.call.actions;
002
003import com.plivo.api.PlivoClient;
004import com.plivo.api.exceptions.PlivoRestException;
005import com.plivo.api.models.base.VoiceCreator;
006import com.plivo.api.models.call.LegSpecifier;
007import java.io.IOException;
008import retrofit2.Call;
009
010public class CallDtmfCreator extends VoiceCreator<CallDtmfCreateResponse> {
011
012  private final String digits;
013  private final String id;
014  private LegSpecifier leg;
015
016  public CallDtmfCreator(String id, String digits) {
017    this.id = id;
018    this.digits = digits;
019  }
020
021  public String digits() {
022    return digits;
023  }
024
025  public LegSpecifier leg() {
026    return this.leg;
027  }
028
029  public CallDtmfCreator leg(final LegSpecifier leg) {
030    this.leg = leg;
031    return this;
032  }
033
034
035  @Override
036  protected Call<CallDtmfCreateResponse> obtainCall() {
037    return client().getVoiceApiService().callDtmfCreate(client().getAuthId(), id, this);
038  }
039
040  @Override
041  protected Call<CallDtmfCreateResponse> obtainFallback1Call() {
042    return client().getVoiceFallback1Service().callDtmfCreate(client().getAuthId(), id, this);
043  }
044
045  @Override
046  protected Call<CallDtmfCreateResponse> obtainFallback2Call() {
047    return client().getVoiceFallback2Service().callDtmfCreate(client().getAuthId(), id, this);
048  }
049
050  public CallDtmfCreateResponse sendDigits() throws IOException, PlivoRestException {
051    return create();
052  }
053
054  @Override
055  public CallDtmfCreator client(final PlivoClient plivoClient) {
056    this.plivoClient = plivoClient;
057    return this;
058  }
059
060}