Skip to content

Commit 9adfb7b

Browse files
Clients Module added
1 parent 4851e29 commit 9adfb7b

32 files changed

+741
-44
lines changed
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
/*
2+
* TeleStax, Open Source Cloud Communications
3+
* Copyright 2011-2016, Telestax Inc and individual contributors
4+
* by the @authors tag.
5+
*
6+
* This is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation; either version 2.1 of
9+
* the License, or (at your option) any later version.
10+
*
11+
* This software is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this software; if not, write to the Free
18+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20+
*/
21+
package org.restcomm.connect.java.sdk.Clients;
22+
23+
import org.apache.http.ParseException;
24+
import org.apache.http.ProtocolException;
25+
import org.restcomm.connect.java.sdk.Restcomm;
26+
import org.restcomm.connect.java.sdk.Utilities;
27+
import org.restcomm.connect.java.sdk.http.*;
28+
29+
import org.restcomm.connect.java.sdk.Exceptions.*;
30+
31+
public class Client{
32+
33+
static String BASE_URL = Restcomm.COMMON_URL+"Accounts/"+Restcomm.getAuthID()+"/Clients.json/";
34+
35+
static public void SubAccountAccess(String sid)
36+
{
37+
BASE_URL = Restcomm.COMMON_URL+"Accounts/"+sid+"/Clients.json/";
38+
}
39+
public static Client getClient(String sid)
40+
{
41+
Restcomm.sendRequest((new Request(HttpMethod.GET,BASE_URL+sid)));
42+
return Utilities.ClientObject(Restcomm.getJSONResponse());
43+
}
44+
public static ClientCreator createClient()
45+
{
46+
return new ClientCreator(BASE_URL);
47+
}
48+
49+
public static ClientUpdater updateClient(String sid)
50+
{
51+
return new ClientUpdater(BASE_URL+sid);
52+
}
53+
public ClientUpdater updateClient()
54+
{
55+
return updateClient(this.getSid());
56+
}
57+
public void deleteApplication()
58+
{
59+
deleteApplication(this.getSid());
60+
}
61+
public static void deleteApplication(String sid)
62+
{
63+
Restcomm.sendRequest((new Request(HttpMethod.DELETE,BASE_URL+sid)));
64+
}
65+
public static ClientList getClientList()
66+
{
67+
return new ClientList(BASE_URL);
68+
}
69+
70+
private String sid;
71+
72+
private String status;
73+
74+
private String voice_fallback_method;
75+
76+
private String date_updated;
77+
78+
private String login;
79+
80+
private String date_created;
81+
82+
private String friendly_name;
83+
84+
private String uri;
85+
86+
private String password;
87+
88+
private String api_version;
89+
90+
private String voice_method;
91+
92+
private String account_sid;
93+
94+
public String getSid ()
95+
{
96+
return sid;
97+
}
98+
99+
private void setSid (String sid)
100+
{
101+
this.sid = sid;
102+
}
103+
104+
public String getStatus ()
105+
{
106+
return status;
107+
}
108+
109+
private void setStatus (String status)
110+
{
111+
this.status = status;
112+
}
113+
114+
public String getVoice_fallback_method ()
115+
{
116+
return voice_fallback_method;
117+
}
118+
119+
private void setVoice_fallback_method (String voice_fallback_method)
120+
{
121+
this.voice_fallback_method = voice_fallback_method;
122+
}
123+
124+
public String getDate_updated ()
125+
{
126+
return date_updated;
127+
}
128+
129+
private void setDate_updated (String date_updated)
130+
{
131+
this.date_updated = date_updated;
132+
}
133+
134+
public String getLogin ()
135+
{
136+
return login;
137+
}
138+
139+
private void setLogin (String login)
140+
{
141+
this.login = login;
142+
}
143+
144+
public String getDate_created ()
145+
{
146+
return date_created;
147+
}
148+
149+
private void setDate_created (String date_created)
150+
{
151+
this.date_created = date_created;
152+
}
153+
154+
public String getFriendly_name ()
155+
{
156+
return friendly_name;
157+
}
158+
159+
private void setFriendly_name (String friendly_name)
160+
{
161+
this.friendly_name = friendly_name;
162+
}
163+
164+
public String getUri ()
165+
{
166+
return uri;
167+
}
168+
169+
private void setUri (String uri)
170+
{
171+
this.uri = uri;
172+
}
173+
174+
public String getPassword ()
175+
{
176+
return password;
177+
}
178+
179+
private void setPassword (String password)
180+
{
181+
this.password = password;
182+
}
183+
184+
public String getApi_version ()
185+
{
186+
return api_version;
187+
}
188+
189+
private void setApi_version (String api_version)
190+
{
191+
this.api_version = api_version;
192+
}
193+
194+
public String getVoice_method ()
195+
{
196+
return voice_method;
197+
}
198+
199+
private void setVoice_method (String voice_method)
200+
{
201+
this.voice_method = voice_method;
202+
}
203+
204+
public String getAccount_sid ()
205+
{
206+
return account_sid;
207+
}
208+
209+
private void setAccount_sid (String account_sid)
210+
{
211+
this.account_sid = account_sid;
212+
}
213+
214+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* TeleStax, Open Source Cloud Communications
3+
* Copyright 2011-2016, Telestax Inc and individual contributors
4+
* by the @authors tag.
5+
*
6+
* This is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation; either version 2.1 of
9+
* the License, or (at your option) any later version.
10+
*
11+
* This software is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this software; if not, write to the Free
18+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20+
*/
21+
package org.restcomm.connect.java.sdk.Clients;
22+
import org.apache.http.ProtocolException;
23+
import org.restcomm.connect.java.sdk.Restcomm;
24+
import org.restcomm.connect.java.sdk.Utilities;
25+
import org.restcomm.connect.java.sdk.http.*;
26+
public class ClientCreator {
27+
28+
static String BASE_URL;
29+
public Request request;
30+
public ClientCreator(final String BASE_URL) {
31+
32+
ClientCreator.BASE_URL = BASE_URL;
33+
request = new Request(HttpMethod.POST,BASE_URL);
34+
}
35+
public ClientCreator FriendlyName(String value)
36+
{
37+
request.addPostParameters("FriendlyName", value);
38+
return this;
39+
}
40+
public ClientCreator Login(String apiversion)
41+
{
42+
request.addPostParameters("Login", apiversion);
43+
return this;
44+
}
45+
public ClientCreator Password(String rcmlurl)
46+
{
47+
request.addPostParameters("Password", rcmlurl);
48+
return this;
49+
}
50+
public ClientCreator Status(String kind)
51+
{
52+
request.addPostParameters("Status",kind);
53+
return this;
54+
}
55+
public ClientCreator VoiceUrl(String a)
56+
{
57+
request.addPostParameters("VoiceUrl", a);
58+
return this;
59+
}
60+
public ClientCreator VoiceMethod(String a)
61+
{
62+
request.addPostParameters("VoiceMethod", a);
63+
return this;
64+
}public ClientCreator VoiceFallbackUrl(String a)
65+
{
66+
request.addPostParameters("VoiceFallbackUrl", a);
67+
return this;
68+
}public ClientCreator VoiceFallbackMethod(String a)
69+
{
70+
request.addPostParameters("VoiceFallbackMethod", a);
71+
return this;
72+
}public ClientCreator VoiceApplicationSid(String a)
73+
{
74+
request.addPostParameters("VoiceApplicationSid", a);
75+
return this;
76+
}
77+
public Client create()
78+
{
79+
Restcomm.sendRequest(request);
80+
return Utilities.ClientObject(Restcomm.getJSONResponse());
81+
}
82+
83+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* TeleStax, Open Source Cloud Communications
3+
* Copyright 2011-2016, Telestax Inc and individual contributors
4+
* by the @authors tag.
5+
*
6+
* This is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation; either version 2.1 of
9+
* the License, or (at your option) any later version.
10+
*
11+
* This software is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this software; if not, write to the Free
18+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20+
*/
21+
package org.restcomm.connect.java.sdk.Clients;
22+
import org.restcomm.connect.java.sdk.http.*;
23+
import java.io.IOException;
24+
import java.util.ArrayList;
25+
import java.util.List;
26+
27+
import org.restcomm.connect.java.sdk.Restcomm;
28+
import org.apache.http.ProtocolException;
29+
import org.restcomm.connect.java.sdk.Exceptions.*;
30+
import org.apache.http.ParseException;
31+
import java.lang.reflect.Type;
32+
import com.google.gson.reflect.TypeToken;
33+
import com.google.gson.Gson;
34+
35+
public class ClientList {
36+
37+
private String BASE_URL;
38+
39+
private List<Client> List;
40+
41+
public Client get(int index)
42+
{
43+
return List.get(index);
44+
}
45+
public int size()
46+
{
47+
return List.size();
48+
}
49+
public void setList(List<Client> list) {
50+
List = list;
51+
}
52+
public ClientList(final String BASE_URL)
53+
{
54+
this.BASE_URL = BASE_URL;
55+
Restcomm.sendRequest(new Request(HttpMethod.GET,BASE_URL));
56+
Type ListType = new TypeToken< ArrayList<Client> >(){}.getType();
57+
Gson gson = new Gson();
58+
59+
List = gson.fromJson(Restcomm.getJSONResponse(),ListType);
60+
61+
}
62+
}

0 commit comments

Comments
 (0)