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.sns; 017 018 019import com.vonage.client.HttpWrapper; 020import com.vonage.client.VonageClient; 021import com.vonage.client.VonageClientException; 022import com.vonage.client.VonageResponseParseException; 023import com.vonage.client.sns.request.SnsPublishRequest; 024import com.vonage.client.sns.request.SnsSubscribeRequest; 025import com.vonage.client.sns.response.SnsPublishResponse; 026import com.vonage.client.sns.response.SnsSubscribeResponse; 027 028/** 029 * A client for talking to the Vonage Voice API. The standard way to obtain an instance of this class is to use {@link 030 * VonageClient#getSnsClient()}. 031 */ 032public class SnsClient { 033 private SnsEndpoint endpoint; 034 035 /** 036 * Constructor. 037 * 038 * @param httpWrapper (required) shared HTTP wrapper object used for making REST calls. 039 */ 040 public SnsClient(HttpWrapper httpWrapper) { 041 this.endpoint = new SnsEndpoint(httpWrapper); 042 } 043 044 public SnsPublishResponse publish(SnsPublishRequest request) throws VonageClientException, VonageResponseParseException { 045 return (SnsPublishResponse) this.endpoint.execute(request); 046 } 047 048 public SnsSubscribeResponse subscribe(SnsSubscribeRequest request) throws VonageClientException, VonageResponseParseException { 049 return (SnsSubscribeResponse) this.endpoint.execute(request); 050 } 051}