001package com.plivo.api.models.base; 002 003import com.plivo.api.PlivoClient; 004import com.plivo.api.exceptions.PlivoRestException; 005import java.io.IOException; 006import okhttp3.ResponseBody; 007import retrofit2.Call; 008import retrofit2.Response; 009 010/** 011 * Deletes an instance of a resource. 012 * 013 * @param <T> The type of the resource. 014 */ 015public abstract class Deleter<T extends BaseResource> extends BaseRequest<T> { 016 017 protected String id; 018 019 public Deleter(String id) { 020 this.id = id; 021 022 if (id == null) { 023 throw new IllegalArgumentException("id cannot be null"); 024 } 025 } 026 027 /** 028 * Actually delete the resource. 029 */ 030 public void delete() throws IOException, PlivoRestException { 031 validate(); 032 Response<ResponseBody> response = obtainCall().execute(); 033 034 handleResponse(response); 035 } 036 037 @Override 038 public Deleter<T> client(final PlivoClient plivoClient) { 039 this.plivoClient = plivoClient; 040 return this; 041 } 042 043 044 protected abstract Call<ResponseBody> obtainCall(); 045}