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 CreateApplicationRequest { 027 private final String name; 028 private final ApplicationType type; 029 private final String answerUrl; 030 private final String eventUrl; 031 032 private String answerMethod; 033 private String eventMethod; 034 035 public CreateApplicationRequest(String name, String answerUrl, String eventUrl) { 036 this(name, ApplicationType.VOICE, answerUrl, null, eventUrl, null); 037 } 038 039 public CreateApplicationRequest( 040 String name, ApplicationType type, 041 String answerUrl, String answerMethod, 042 String eventUrl, String eventMethod) { 043 this.name = name; 044 this.type = type; 045 this.answerUrl = answerUrl; 046 this.eventUrl = eventUrl; 047 this.answerMethod = answerMethod; 048 this.eventMethod = eventMethod; 049 } 050 051 public String getName() { 052 return name; 053 } 054 055 public ApplicationType getType() { 056 return type; 057 } 058 059 public String getAnswerUrl() { 060 return answerUrl; 061 } 062 063 public String getEventUrl() { 064 return eventUrl; 065 } 066 067 public String getAnswerMethod() { 068 return answerMethod; 069 } 070 071 public void setAnswerMethod(String answerMethod) { 072 this.answerMethod = answerMethod; 073 } 074 075 public String getEventMethod() { 076 return eventMethod; 077 } 078 079 public void setEventMethod(String eventMethod) { 080 this.eventMethod = eventMethod; 081 } 082 083 public void addParams(RequestBuilder request) { 084 request.addParameter("name", this.name) 085 .addParameter("type", this.type.toString()) 086 .addParameter("answer_url", this.answerUrl) 087 .addParameter("event_url", this.eventUrl); 088 if (this.eventMethod != null) { 089 request.addParameter("event_method", this.eventMethod); 090 } 091 if (this.answerMethod != null) { 092 request.addParameter("answer_method", this.answerMethod); 093 } 094 } 095 096}