Skip to content

Commit d923255

Browse files
Calls Module Added
1 parent eedb96a commit d923255

36 files changed

+805
-39
lines changed

restcomm-connect.java.sdk/src/main/asciidoc/index.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ Fetching a SubAccount with a given 'Sid', available under our MainAccount
8484
SubAccount spareAccount = SubAccount.getSubAccount(Sid); //Sid is the actual Sid of the SubAccount we wish to fetch
8585

8686
The fields of the SubAccount object can be obtained by invoking the respective '_get()_' method of that field similar to that Of Accounts
87-
87+
----
8888
String FriendlyName;
8989
FriendlyName = spareAccount.getFriendly_name();
90-
90+
----
9191

9292
Modifying the SubAccount in a similar way as mentioned above
9393

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
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.Calls;
22+
23+
import org.restcomm.connect.java.sdk.http.*;
24+
import org.restcomm.connect.java.sdk.Restcomm;
25+
import org.restcomm.connect.java.sdk.Utilities;
26+
27+
public class Call {
28+
29+
static String BASE_URL = Restcomm.COMMON_URL+"Accounts/"+Restcomm.getAuthID()+"/Calls.json/";
30+
31+
static public void SubAccountAccess(String sid)
32+
{
33+
BASE_URL = Restcomm.COMMON_URL+"Accounts/"+sid+"/Calls.json/";
34+
}
35+
36+
public static Call getCall(String sid)
37+
{
38+
Restcomm.sendRequest((new Request(HttpMethod.GET,BASE_URL+sid)));
39+
return Utilities.CallObject(Restcomm.getJSONResponse());
40+
}
41+
42+
public static CallCreator newCall()
43+
{
44+
return new CallCreator(BASE_URL);
45+
}
46+
47+
public static CallModifier modifyLiveCall(String sid)
48+
{
49+
return new CallModifier(BASE_URL+sid);
50+
}
51+
52+
public CallModifier modifyLiveCall()
53+
{
54+
return new CallModifier(BASE_URL+this.getSid());
55+
}
56+
57+
public static CallsList getCallsList()
58+
{
59+
return new CallsList(BASE_URL);
60+
}
61+
62+
63+
private String to;
64+
65+
private String sid;
66+
67+
private String status;
68+
69+
private String direction;
70+
71+
private String InstanceId;
72+
73+
private String date_created;
74+
75+
private String from;
76+
77+
private String uri;
78+
79+
private String api_version;
80+
81+
private String account_sid;
82+
83+
private String date_updated;
84+
85+
private String start_time;
86+
87+
private String price_unit;
88+
89+
private String caller_name;
90+
91+
public String getTo ()
92+
{
93+
return to;
94+
}
95+
96+
private void setTo (String to)
97+
{
98+
this.to = to;
99+
}
100+
101+
public String getSid ()
102+
{
103+
return sid;
104+
}
105+
106+
private void setSid (String sid)
107+
{
108+
this.sid = sid;
109+
}
110+
111+
public String getStatus ()
112+
{
113+
return status;
114+
}
115+
116+
private void setStatus (String status)
117+
{
118+
this.status = status;
119+
}
120+
121+
public String getDirection ()
122+
{
123+
return direction;
124+
}
125+
126+
private void setDirection (String direction)
127+
{
128+
this.direction = direction;
129+
}
130+
131+
public String getInstanceId ()
132+
{
133+
return InstanceId;
134+
}
135+
136+
private void setInstanceId (String InstanceId)
137+
{
138+
this.InstanceId = InstanceId;
139+
}
140+
141+
public String getDate_created ()
142+
{
143+
return date_created;
144+
}
145+
146+
private void setDate_created (String date_created)
147+
{
148+
this.date_created = date_created;
149+
}
150+
151+
public String getFrom ()
152+
{
153+
return from;
154+
}
155+
156+
private void setFrom (String from)
157+
{
158+
this.from = from;
159+
}
160+
161+
public String getUri ()
162+
{
163+
return uri;
164+
}
165+
166+
private void setUri (String uri)
167+
{
168+
this.uri = uri;
169+
}
170+
171+
public String getApi_version ()
172+
{
173+
return api_version;
174+
}
175+
176+
private void setApi_version (String api_version)
177+
{
178+
this.api_version = api_version;
179+
}
180+
181+
public String getAccount_sid ()
182+
{
183+
return account_sid;
184+
}
185+
186+
private void setAccount_sid (String account_sid)
187+
{
188+
this.account_sid = account_sid;
189+
}
190+
191+
public String getDate_updated ()
192+
{
193+
return date_updated;
194+
}
195+
196+
private void setDate_updated (String date_updated)
197+
{
198+
this.date_updated = date_updated;
199+
}
200+
201+
public String getStart_time ()
202+
{
203+
return start_time;
204+
}
205+
206+
private void setStart_time (String start_time)
207+
{
208+
this.start_time = start_time;
209+
}
210+
211+
public String getPrice_unit ()
212+
{
213+
return price_unit;
214+
}
215+
216+
private void setPrice_unit (String price_unit)
217+
{
218+
this.price_unit = price_unit;
219+
}
220+
221+
public String getCaller_name ()
222+
{
223+
return caller_name;
224+
}
225+
226+
private void setCaller_name (String caller_name)
227+
{
228+
this.caller_name = caller_name;
229+
}
230+
}
231+
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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.Calls;
22+
import org.restcomm.connect.java.sdk.http.*;
23+
import org.restcomm.connect.java.sdk.Restcomm;
24+
import org.restcomm.connect.java.sdk.Utilities;
25+
26+
27+
public class CallCreator {
28+
29+
static String BASE_URL;
30+
public Request request;
31+
public CallCreator(final String BASE_URL) {
32+
33+
CallCreator.BASE_URL = BASE_URL;
34+
request = new Request(HttpMethod.POST,BASE_URL);
35+
}
36+
public CallCreator From(String value)
37+
{
38+
request.addPostParameters("From", value);
39+
return this;
40+
}
41+
public CallCreator To(String value)
42+
{
43+
request.addPostParameters("To", value);
44+
return this;
45+
}
46+
public CallCreator Url(String value)
47+
{
48+
request.addPostParameters("Url", value);
49+
return this;
50+
}
51+
public CallCreator Method(String value)
52+
{
53+
request.addPostParameters("Method", value);
54+
return this;
55+
}
56+
public CallCreator FallbackUrl(String value)
57+
{
58+
request.addPostParameters("FallbackUrl", value);
59+
return this;
60+
}
61+
public CallCreator FallbackMethod(String value)
62+
{
63+
request.addPostParameters("FallbackMethod", value);
64+
return this;
65+
}
66+
public CallCreator statusCallbackEvent(String value)
67+
{
68+
request.addPostParameters("statusCallbackEvent", value);
69+
return this;
70+
}
71+
public CallCreator statusCallback(String value)
72+
{
73+
request.addPostParameters("statusCallback", value);
74+
return this;
75+
}
76+
public CallCreator statusCallbackMethod(String value)
77+
{
78+
request.addPostParameters("statusCallbackMethod", value);
79+
return this;
80+
}
81+
public CallCreator Timeout(String value)
82+
{
83+
request.addPostParameters("Timeout", value);
84+
return this;
85+
}
86+
public Call makeCall()
87+
{
88+
Restcomm.sendRequest(request);
89+
return Utilities.CallObject(Restcomm.getJSONResponse());
90+
}
91+
92+
}

0 commit comments

Comments
 (0)