001/* 002 * Copyright 2020 Vonage 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.vonage.client.application; 017 018 019import com.vonage.client.*; 020 021/** 022 * A client for talking to the Vonage Application API. The standard way to obtain an instance of this class is to use 023 * {@link VonageClient#getApplicationClient()} 024 */ 025public class ApplicationClient extends AbstractClient { 026 private ApplicationEndpoint applicationEndpoint; 027 028 public ApplicationClient(HttpWrapper httpWrapper) { 029 super(httpWrapper); 030 this.applicationEndpoint = new ApplicationEndpoint(httpWrapper); 031 } 032 033 /** 034 * Create a new application. 035 * 036 * @param application The application properties for the application to be created with. 037 * 038 * @return The application which has been created. 039 * 040 * @throws VonageResponseParseException if the response from the API could not be parsed. 041 * @throws VonageClientException if there was a problem with the Vonage request. 042 */ 043 public Application createApplication(Application application) throws VonageResponseParseException, VonageClientException { 044 return this.applicationEndpoint.create(application); 045 } 046 047 /** 048 * Update an existing application. 049 * 050 * @param application The application properties for the application to be updated with. 051 * 052 * @return The application which has been updated. 053 * 054 * @throws VonageResponseParseException if the response from the API could not be parsed. 055 * @throws VonageClientException if there was a problem with the Vonage request. 056 */ 057 public Application updateApplication(Application application) throws VonageResponseParseException, VonageClientException { 058 return this.applicationEndpoint.update(application); 059 } 060 061 /** 062 * Retrieve an application. 063 * 064 * @param id The id of the application to retrieve. 065 * 066 * @return The corresponding application. 067 * 068 * @throws VonageResponseParseException if the response from the API could not be parsed. 069 * @throws VonageClientException if there was a problem with the Vonage request. 070 */ 071 public Application getApplication(String id) throws VonageResponseParseException, VonageClientException { 072 return this.applicationEndpoint.get(id); 073 } 074 075 /** 076 * Delete an application. 077 * 078 * @param id The id of the application to delete. 079 * 080 * @throws VonageResponseParseException if the response from the API could not be parsed. 081 * @throws VonageClientException if there was a problem with the Vonage request. 082 */ 083 public void deleteApplication(String id) throws VonageResponseParseException, VonageClientException { 084 this.applicationEndpoint.delete(id); 085 } 086 087 /** 088 * List the first page of available applications. 089 * 090 * @return The list of available applications. 091 * 092 * @throws VonageResponseParseException if the response from the API could not be parsed. 093 * @throws VonageClientException if there was a problem with the Vonage request. 094 */ 095 public ApplicationList listApplications() throws VonageResponseParseException, VonageClientException { 096 return listApplications(null); 097 } 098 099 /** 100 * List the available applications. 101 * 102 * @param listApplicationRequest The page and number of applications per page to list. 103 * 104 * @return The list of available applications. 105 * 106 * @throws VonageResponseParseException if the response from the API could not be parsed. 107 * @throws VonageClientException if there was a problem with the Vonage request. 108 */ 109 public ApplicationList listApplications(ListApplicationRequest listApplicationRequest) throws VonageResponseParseException, VonageClientException { 110 return this.applicationEndpoint.list(listApplicationRequest); 111 } 112}