001/* 002 * Copyright (c) 2011-2017 Nexmo Inc 003 * 004 * Permission is hereby granted, free of charge, to any person obtaining a copy 005 * of this software and associated documentation files (the "Software"), to deal 006 * in the Software without restriction, including without limitation the rights 007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 008 * copies of the Software, and to permit persons to whom the Software is 009 * furnished to do so, subject to the following conditions: 010 * 011 * The above copyright notice and this permission notice shall be included in 012 * all copies or substantial portions of the Software. 013 * 014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 020 * THE SOFTWARE. 021 */ 022package com.nexmo.client.applications; 023 024import org.apache.http.client.methods.RequestBuilder; 025 026public class UpdateApplicationRequest { 027 private final String applicationId; 028 private final String name; 029 private final ApplicationType type; 030 private final String answerUrl; 031 private final String eventUrl; 032 033 private String answerMethod; 034 private String eventMethod; 035 036 public UpdateApplicationRequest(String applicationId, String name, String answerUrl, String eventUrl) { 037 this(applicationId, name, ApplicationType.VOICE, answerUrl, null, eventUrl, null); 038 } 039 040 public UpdateApplicationRequest( 041 String applicationId, String name, ApplicationType type, 042 String answerUrl, String answerMethod, 043 String eventUrl, String eventMethod) { 044 this.applicationId = applicationId; 045 this.name = name; 046 this.type = type; 047 this.answerUrl = answerUrl; 048 this.eventUrl = eventUrl; 049 this.answerMethod = answerMethod; 050 this.eventMethod = eventMethod; 051 } 052 053 public String getApplicationId() { 054 return applicationId; 055 } 056 057 public String getName() { 058 return name; 059 } 060 061 public ApplicationType getType() { 062 return type; 063 } 064 065 public String getAnswerUrl() { 066 return answerUrl; 067 } 068 069 public String getEventUrl() { 070 return eventUrl; 071 } 072 073 public String getAnswerMethod() { 074 return answerMethod; 075 } 076 077 public void setAnswerMethod(String answerMethod) { 078 this.answerMethod = answerMethod; 079 } 080 081 public String getEventMethod() { 082 return eventMethod; 083 } 084 085 public void setEventMethod(String eventMethod) { 086 this.eventMethod = eventMethod; 087 } 088 089 public void addParams(RequestBuilder request) { 090 request.addParameter("name", this.name) 091 .addParameter("type", this.type.toString()) 092 .addParameter("answer_url", this.answerUrl) 093 .addParameter("event_url", this.eventUrl); 094 if (this.eventMethod != null) { 095 request.addParameter("event_method", this.eventMethod); 096 } 097 if (this.answerMethod != null) { 098 request.addParameter("answer_method", this.answerMethod); 099 } 100 } 101 102}