001package com.plivo.api.models.multipartycall; 002 003import com.plivo.api.exceptions.PlivoValidationException; 004import com.plivo.api.models.base.VoiceUpdater; 005import com.plivo.api.util.Utils; 006import retrofit2.Call; 007 008public class MultiPartyCallParticipantUpdate extends VoiceUpdater<MultiPartyCallParticipantUpdateResponse> { 009 010 private Boolean mute; 011 private Boolean hold; 012 private Boolean coachMode; 013 014 public MultiPartyCallParticipantUpdate(String mpcId, String secondaryId) { 015 super(mpcId, secondaryId); 016 } 017 018 public Boolean mute() { 019 return mute; 020 } 021 022 public Boolean hold() { 023 return hold; 024 } 025 026 public Boolean coachMode() { 027 return coachMode; 028 } 029 030 public MultiPartyCallParticipantUpdate mute(Boolean mute) { 031 this.mute = mute; 032 return this; 033 } 034 035 public MultiPartyCallParticipantUpdate hold(Boolean hold) { 036 this.hold = hold; 037 return this; 038 } 039 040 public MultiPartyCallParticipantUpdate coachMode(Boolean coachMode) { 041 this.coachMode = coachMode; 042 return this; 043 } 044 045 @Override 046 protected Call<MultiPartyCallParticipantUpdateResponse> obtainCall() throws PlivoValidationException { 047 MultiPartyCallUtils.validMultiPartyCallId(id); 048 if (secondaryId.equalsIgnoreCase(MultiPartyCallUtils.allParticipants) && coachMode != null) { 049 throw new PlivoValidationException("cannot update coachMode for all participants"); 050 } 051 if (!Utils.anyNotNull(coachMode, mute, hold)) { 052 throw new PlivoValidationException("please update either mute, hold or coach_mode"); 053 } 054 return client().getVoiceApiService().mpcMemberUpdate(client().getAuthId(), id, secondaryId, this); 055 } 056 057 @Override 058 protected Call<MultiPartyCallParticipantUpdateResponse> obtainFallback1Call() throws PlivoValidationException { 059 MultiPartyCallUtils.validMultiPartyCallId(id); 060 if (secondaryId.equalsIgnoreCase(MultiPartyCallUtils.allParticipants) && coachMode != null) { 061 throw new PlivoValidationException("cannot update coachMode for all participants"); 062 } 063 if (!Utils.anyNotNull(coachMode, mute, hold)) { 064 throw new PlivoValidationException("please update either mute, hold or coach_mode"); 065 } 066 return client().getVoiceFallback1Service().mpcMemberUpdate(client().getAuthId(), id, secondaryId, this); 067 } 068 069 @Override 070 protected Call<MultiPartyCallParticipantUpdateResponse> obtainFallback2Call() throws PlivoValidationException { 071 MultiPartyCallUtils.validMultiPartyCallId(id); 072 if (secondaryId.equalsIgnoreCase(MultiPartyCallUtils.allParticipants) && coachMode != null) { 073 throw new PlivoValidationException("cannot update coachMode for all participants"); 074 } 075 if (!Utils.anyNotNull(coachMode, mute, hold)) { 076 throw new PlivoValidationException("please update either mute, hold or coach_mode"); 077 } 078 return client().getVoiceFallback2Service().mpcMemberUpdate(client().getAuthId(), id, secondaryId, this); 079 } 080}