001package com.plivo.api.models.call; 002 003import com.plivo.api.models.base.ListResponse; 004import com.plivo.api.models.base.VoiceLister; 005import com.plivo.api.util.PropertyFilter; 006import okhttp3.ResponseBody; 007 008public class CallLister extends VoiceLister<Call> { 009 010 private String subaccount; 011 private CallDirection callDirection; 012 private String fromNumber; 013 private String toNumber; 014 private String parentCallUuid; 015 private String hangupSource; 016 private Integer hangupCauseCode; 017 // TODO XXX PropertyFilter 018 private PropertyFilter<Long> billDuration; 019 private PropertyFilter<Long> endTime; 020 021 public String subaccount() { 022 return this.subaccount; 023 } 024 025 public CallDirection callDirection() { 026 return this.callDirection; 027 } 028 029 public String fromNumber() { 030 return this.fromNumber; 031 } 032 033 public String toNumber() { 034 return this.toNumber; 035 } 036 037 public String parentCallUuid(){ 038 return this.parentCallUuid; 039 } 040 041 public String hangupSource() { 042 return hangupSource; 043 } 044 045 public Integer hangupCauseCode() { 046 return hangupCauseCode; 047 } 048 049 public PropertyFilter<Long> billDuration() { 050 return this.billDuration; 051 } 052 053 public PropertyFilter<Long> endTime() { 054 return this.endTime; 055 } 056 057 /** 058 * @param subaccount The id of the subaccount, if call details of the subaccount are needed. 059 */ 060 public CallLister subaccount(final String subaccount) { 061 this.subaccount = subaccount; 062 return this; 063 } 064 065 /** 066 * @param callDirection Filter the results by call direction. The valid inputs are inbound and 067 * outbound. 068 */ 069 public CallLister callDirection(final CallDirection callDirection) { 070 this.callDirection = callDirection; 071 return this; 072 } 073 074 /** 075 * @param fromNumber Filter the results by the number from where the call originated. 076 */ 077 public CallLister fromNumber(final String fromNumber) { 078 this.fromNumber = fromNumber; 079 return this; 080 } 081 082 /** 083 * @param toNumber Filter the results by the number to which the call was made. 084 */ 085 public CallLister toNumber(final String toNumber) { 086 this.toNumber = toNumber; 087 return this; 088 } 089 090 /** 091 * @param parentCallUuid Filter the results by the number to which the call was made. 092 */ 093 public CallLister parentCallUuid(final String parentCallUuid) { 094 this.parentCallUuid = parentCallUuid; 095 return this; 096 } 097 098 /** 099 * @param hangupSource Filter the results by hangup source. 100 */ 101 public CallLister hangupSource(String hangupSource) { 102 this.hangupSource = hangupSource; 103 return this; 104 } 105 106 /** 107 * @param hangupCauseCode Filter the results by hangup cause code. 108 */ 109 public CallLister hangupCauseCode(Integer hangupCauseCode) { 110 this.hangupCauseCode = hangupCauseCode; 111 return this; 112 } 113 114 /** 115 * @param billDuration Filter the results according to billed duration. 116 */ 117 public CallLister billDuration( 118 final PropertyFilter<Long> billDuration) { 119 this.billDuration = billDuration; 120 return this; 121 } 122 123 /** 124 * @param endTime Filter out calls according to the time of completion. 125 */ 126 public CallLister endTime(final PropertyFilter<Long> endTime) { 127 this.endTime = endTime; 128 return this; 129 } 130 131 @Override 132 protected retrofit2.Call<ListResponse<Call>> obtainCall() { 133 return client().getVoiceApiService().callList(client().getAuthId(), toMap()); 134 } 135 136 @Override 137 protected retrofit2.Call<ListResponse<Call>> obtainFallback1Call() { 138 return client().getVoiceFallback1Service().callList(client().getAuthId(), toMap()); 139 } 140 141 @Override 142 protected retrofit2.Call<ListResponse<Call>> obtainFallback2Call() { 143 return client().getVoiceFallback2Service().callList(client().getAuthId(), toMap()); 144 } 145}