public List <StreamListItem> getUserStreams(List <String> streamTypes, Boolean includeInactiveStreams) { List <Dictionary <String, String> > inputStreamTypes = new List <Dictionary <String, String> >(); if (streamTypes != null) { foreach (String type in streamTypes) { Dictionary <String, String> streamTypesMap = new Dictionary <string, string>(); streamTypesMap.Add("type", type); inputStreamTypes.Add(streamTypesMap); } } Dictionary <String, Object> input = new Dictionary <String, Object>(); input.Add("streamTypes", inputStreamTypes); input.Add("includeInactiveStreams", includeInactiveStreams); SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.LISTUSERSTREAMS; HttpWebResponse resp = restRequestHandler.executeRequest(input, url, false, WebRequestMethods.Http.Post, symConfig, true); string body = restRequestHandler.ReadResponse(resp); return(JsonConvert.DeserializeObject <StreamInfoList>(body)); }
public UserInfo getUserFromId(long id, Boolean local) { SymConfig symConfig = botClient.getConfig(); UserInfoList info = null; RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.GETUSERSV3 + "?uid=" + id + "&local=" + local; HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Get, symConfig, true); if (resp.StatusCode == HttpStatusCode.NoContent) { resp.Close(); throw new Exception("No user found."); } else if (resp.StatusCode == HttpStatusCode.OK) { string body = restRequestHandler.ReadResponse(resp); info = JsonConvert.DeserializeObject <UserInfoList>(body); } resp.Close(); if (info != null && info.users != null && info.users.Count > 0) { return(info.users[0]); } throw new Exception("No user found or empty user list returned."); }
public void sessionAuthenticate() { if (uid != 0) { RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = "https://" + config.sessionAuthHost + ":" + config.sessionAuthPort + AuthEndpointConstants.OBOUSERAUTH.Replace("{uid}", uid.ToString()); HttpWebResponse resp = restRequestHandler.executeRequest(null, url, true, WebRequestMethods.Http.Post, config, false); string body = restRequestHandler.ReadResponse(resp); resp.Close(); JObject o = JObject.Parse(body); authTokens.sessionToken = (string)o["sessionToken"]; sessionToken = authTokens.sessionToken; } else { RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = "https://" + config.sessionAuthHost + ":" + config.sessionAuthPort + AuthEndpointConstants.OBOUSERAUTHUSERNAME.Replace("{username}", username); HttpWebResponse resp = restRequestHandler.executeRequest(null, url, true, WebRequestMethods.Http.Post, config, false); string body = restRequestHandler.ReadResponse(resp); resp.Close(); JObject o = JObject.Parse(body); authTokens.sessionToken = (string)o["sessionToken"]; sessionToken = authTokens.sessionToken; } }
public SignalSubscriberList getSignalSubscribers(String id, int skip, int limit) { SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.agentHost + ":" + symConfig.agentPort + AgentConstants.GETSUBSCRIBERS.Replace("{id}", id); if (skip > 0) { if (url.Contains("?")) { url = url + "&skip=" + skip; } else { url = url + "?skip=" + skip; } } if (limit > 0) { if (url.Contains("?")) { url = url + "&limit=" + limit; } else { url = url + "?limit=" + limit; } } HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Get, symConfig, true); string body = restRequestHandler.ReadResponse(resp); return JsonConvert.DeserializeObject<SignalSubscriberList>(body); }
public List <InboundMessage> getMessagesFromStream(String streamId, int since, int skip, int limit) { List <InboundMessage> result = null; SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string getMessageUrl = AgentConstants.GETMESSAGES.Replace("{sid}", streamId); string url = CommonConstants.HTTPSPREFIX + symConfig.agentHost + ":" + symConfig.agentPort + getMessageUrl + "?since=" + since.ToString(); if (skip > 0) { url = url + "&skip=" + skip; } if (limit > 0) { url = url + "&limit=" + limit; } HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Get, symConfig, true); string body = restRequestHandler.ReadResponse(resp); resp.Close(); List <InboundMessage> inboundMessages = JsonConvert.DeserializeObject <List <InboundMessage> >(body); return(inboundMessages); }
static async Task <List <DatafeedEvent> > GetEventAsync(SymConfig symConfig, Datafeed datafeed, DatafeedClient datafeedClient) { RestRequestHandler restRequestHandler = new RestRequestHandler(); HttpWebResponse response = datafeedClient.getEventsFromDatafeed(symConfig, datafeed); if (response.StatusCode.Equals(HttpStatusCode.OK) || response.StatusCode.Equals(HttpStatusCode.Accepted)) { try { string body = restRequestHandler.ReadResponse(response); List <DatafeedEvent> events = JsonConvert.DeserializeObject <List <DatafeedEvent> >(body); return(events); } catch (JsonSerializationException e) { Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } } else if (response.StatusCode.Equals(HttpStatusCode.NoContent)) { return(null); } else if (response.StatusCode.Equals(HttpStatusCode.Forbidden) || response.StatusCode.Equals(HttpStatusCode.Unauthorized)) { //Add reauth stopLoop = true; return(null); } else if (response.StatusCode.Equals(HttpStatusCode.BadRequest)) { stopLoop = true; } return(null); }
public void registerInterestExtUser(List <long> userIds) { SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.REGISTERPRESENCEINTEREST; HttpWebResponse resp = restRequestHandler.executeRequest(userIds, url, false, WebRequestMethods.Http.Post, symConfig, true); string body = restRequestHandler.ReadResponse(resp); }
public void removeConnection(long userId) { SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.REMOVECONNECTION.Replace("{userId}", userId.ToString()); HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Post, symConfig, true); string body = restRequestHandler.ReadResponse(resp); }
public void deleteSignal(String id) { SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.agentHost + ":" + symConfig.agentPort + AgentConstants.DELETESIGNAL.Replace("{id}", id); HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Post, symConfig, true); string body = restRequestHandler.ReadResponse(resp); }
public void logout() { RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = "https://" + config.sessionAuthHost + ":" + config.sessionAuthPort + AuthEndpointConstants.LOGOUTPATH; HttpWebResponse resp = restRequestHandler.executeRequest(null, url, true, WebRequestMethods.Http.Post, config, false); string body = restRequestHandler.ReadResponse(resp); JObject o = JObject.Parse(body); string message = (string)o["message"]; }
public UserPresence getUserPresence(long userId, Boolean local) { SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.GETUSERPRESENCE.Replace("{uid}", userId.ToString()) + "?local=" + local; HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Get, symConfig, true); string body = restRequestHandler.ReadResponse(resp); return(JsonConvert.DeserializeObject <UserPresence>(body)); }
public InboundConnectionRequest getConnectionRequestStatus(long userId) { SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.GETCONNECTIONSTATUS.Replace("{userId}", userId.ToString()); HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Get, symConfig, true); string body = restRequestHandler.ReadResponse(resp); return(JsonConvert.DeserializeObject <InboundConnectionRequest>(body)); }
public void kmAuthenticate() { RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = "https://" + symConfig.keyAuthHost + ":" + symConfig.keyAuthPort + "/keyauth/v1/authenticate"; HttpWebResponse resp = restRequestHandler.executeRequest(null, url, true, WebRequestMethods.Http.Post, symConfig, false); string body = restRequestHandler.ReadResponse(resp); JObject o = JObject.Parse(body); authTokens.keyManagerToken = (string)o["token"]; kmToken = authTokens.keyManagerToken; }
//TODO: CHECK WHY 403 private void setActiveRoom(String streamId, Boolean active) { SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.SETACTIVE.Replace("{id}", streamId); HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Post, symConfig, true); if (resp.StatusCode == HttpStatusCode.OK) { string body = restRequestHandler.ReadResponse(resp); } }
public Signal createSignal(Signal signal) { Signal result = new Signal(); SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.agentHost + ":" + symConfig.agentPort + AgentConstants.CREATESIGNAL; HttpWebResponse resp = restRequestHandler.executeRequest(signal, url, false, WebRequestMethods.Http.Post, symConfig, true); string body = restRequestHandler.ReadResponse(resp); result = JsonConvert.DeserializeObject<Signal>(body); return result; }
public Signal getSignal(String id) { Signal result = new Signal(); SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.agentHost + ":" + symConfig.agentPort + AgentConstants.GETSIGNAL.Replace("{id}", id); HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Get, symConfig, true); string body = restRequestHandler.ReadResponse(resp); result = JsonConvert.DeserializeObject<Signal>(body); return result; }
public void sessionAppAuthenticate() { RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = "https://" + symConfig.sessionAuthHost + ":" + symConfig.sessionAuthPort + AuthEndpointConstants.SESSIONAPPAUTH; HttpWebResponse resp = restRequestHandler.executeRequest(null, url, true, WebRequestMethods.Http.Post, symConfig, false); string body = restRequestHandler.ReadResponse(resp); JObject o = JObject.Parse(body); authTokens.sessionToken = (string)o["token"]; sessionToken = authTokens.sessionToken; symConfig.authTokens = authTokens; }
public Datafeed createDatafeed(SymConfig symConfig) { Datafeed datafeed = new Datafeed(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = "https://" + symConfig.agentHost + ":" + symConfig.agentPort + "/agent/v4/datafeed/create"; HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Post, symConfig, true); string body = restRequestHandler.ReadResponse(resp); JObject o = JObject.Parse(body); datafeed.datafeedID = (string)o["id"]; return(datafeed); }
public InboundConnectionRequest acceptConnectionRequest(long userId) { UserId userIdObject = new UserId(); userIdObject.setUserId(userId); SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.ACCEPTCONNECTION; HttpWebResponse resp = restRequestHandler.executeRequest(userId, url, false, WebRequestMethods.Http.Post, symConfig, true); string body = restRequestHandler.ReadResponse(resp); return(JsonConvert.DeserializeObject <InboundConnectionRequest>(body)); }
public UserPresence setPresence(String status) { Category category = new Category(); category.setCategory(status); SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.SETPRESENCE; HttpWebResponse resp = restRequestHandler.executeRequest(category, url, false, WebRequestMethods.Http.Post, symConfig, true); string body = restRequestHandler.ReadResponse(resp); return(JsonConvert.DeserializeObject <UserPresence>(body)); }
public byte[] getAttachment(String streamId, String attachmentId, String messageId) { SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.agentHost + ":" + symConfig.agentPort + AgentConstants.GETATTACHMENT.Replace("{sid}", streamId) + "?fieldId=" + attachmentId + "&messageId=" + messageId; HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Get, symConfig, true); string body = restRequestHandler.ReadResponse(resp); var base64EncodedBytes = System.Convert.FromBase64String(body); return(base64EncodedBytes); }
public MessageStatus getMessageStatus(String messageId) { SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.agentHost + ":" + symConfig.agentPort + PodConstants.GETMESSAGESTATUS.Replace("{mid}", messageId); HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Get, symConfig, true); string body = restRequestHandler.ReadResponse(resp); MessageStatus messageStatus = JsonConvert.DeserializeObject <MessageStatus>(body); return(messageStatus); }
public List <InboundConnectionRequest> getConnections(String status, List <long> userIds) { Boolean userList = false; StringBuilder userIdList = new StringBuilder(); if (userIds != null) { if (userIds.Count != 0) { userList = true; userIdList.Append(userIds[0]); for (int i = 1; i < userIds.Count; i++) { userIdList.Append("," + userIds[i]); } } } SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = CreateRestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.GETCONNECTIONS; if (status != null) { if (url.Contains("?")) { url = url + "&status=" + status; } else { url = url + "?status=" + status; } } if (userList) { if (url.Contains("?")) { url = url + "&userIds=" + userIdList.ToString(); } else { url = url + "?userIds=" + userIdList.ToString(); } } HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Get, symConfig, true); string body = restRequestHandler.ReadResponse(resp); resp.Close(); return(JsonConvert.DeserializeObject <InboundConnectionRequestList>(body)); }
public void kmAuthenticate() { Dictionary <String, String> token = new Dictionary <string, string>(); token.Add("token", jwt); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = "https://" + symConfig.sessionAuthHost + ":" + symConfig.sessionAuthPort + AuthEndpointConstants.RSAKMAUTH; HttpWebResponse resp = restRequestHandler.executeRequest(token, url, true, WebRequestMethods.Http.Post, symConfig, false); string body = restRequestHandler.ReadResponse(resp); JObject o = JObject.Parse(body); authTokens.keyManagerToken = (string)o["token"]; kmToken = authTokens.keyManagerToken; }
public UserInfo getSessionUser() { SymConfig symConfig = botClient.getConfig(); UserInfo info = null; RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.GETSESSIONUSER; HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Get, symConfig, false); if (resp.StatusCode == HttpStatusCode.OK) { string body = restRequestHandler.ReadResponse(resp); info = JsonConvert.DeserializeObject <UserInfo>(body); } resp.Close(); return(info); }
public void removeMemberFromRoom(String streamId, long userId) { SymConfig symConfig = botClient.getConfig(); NumericId id = new NumericId(); id.id = userId; RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.REMOVEMEMBER.Replace("{id}", streamId); HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Post, symConfig, true); if (resp.StatusCode == HttpStatusCode.NoContent) { throw new Exception("No user found."); } else if (resp.StatusCode == HttpStatusCode.OK) { string body = restRequestHandler.ReadResponse(resp); } }
//TODO: CHECK WHY 500 public RoomSearchResult searchRooms(RoomSearchQuery query, int skip, int limit) { RoomSearchResult result = null; SymConfig symConfig = botClient.getConfig(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.SEARCHROOMS; if (skip > 0) { if (url.Contains("?")) { url = url + "&skip=" + skip; } else { url = url + "?skip=" + skip; } } if (limit > 0) { if (url.Contains("?")) { url = url + "&limit=" + limit; } else { url = url + "?limit=" + limit; } } if (query.labels == null) { query.labels = new List <String>(); } HttpWebResponse resp = restRequestHandler.executeRequest(query, url, false, WebRequestMethods.Http.Post, symConfig, true); string body = restRequestHandler.ReadResponse(resp); result = JsonConvert.DeserializeObject <RoomSearchResult>(body); return(result); }
//TODO: CHECK WHY 404 public StreamInfo getStreamInfo(String streamId) { SymConfig symConfig = botClient.getConfig(); StreamInfo streamInfo = new StreamInfo(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.GETSTREAMINFO.Replace("{id}", streamId); HttpWebResponse resp = restRequestHandler.executeRequest(null, url, false, WebRequestMethods.Http.Get, symConfig, true); if (resp.StatusCode == HttpStatusCode.NoContent) { throw new Exception("No stream found."); } else if (resp.StatusCode == HttpStatusCode.OK) { string body = restRequestHandler.ReadResponse(resp); streamInfo = JsonConvert.DeserializeObject <StreamInfo>(body); } return(streamInfo); }
public String getUserListIM(List <long> userIdList) { SymConfig symConfig = botClient.getConfig(); StringId id = new StringId(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.GETIM; HttpWebResponse resp = restRequestHandler.executeRequest(userIdList, url, false, WebRequestMethods.Http.Post, symConfig, true); if (resp.StatusCode == HttpStatusCode.NoContent) { throw new Exception("No user found."); } else if (resp.StatusCode == HttpStatusCode.OK) { string body = restRequestHandler.ReadResponse(resp); id = JsonConvert.DeserializeObject <StringId>(body); } return(id.id); }
public RoomInfo createRoom(Room room) { SymConfig symConfig = botClient.getConfig(); RoomInfo roomInfo = new RoomInfo(); RestRequestHandler restRequestHandler = new RestRequestHandler(); string url = CommonConstants.HTTPSPREFIX + symConfig.podHost + ":" + symConfig.podPort + PodConstants.CREATEROOM; HttpWebResponse resp = restRequestHandler.executeRequest(room, url, false, WebRequestMethods.Http.Post, symConfig, true); if (resp.StatusCode == HttpStatusCode.NoContent) { throw new Exception("No user found."); } else if (resp.StatusCode == HttpStatusCode.OK) { string body = restRequestHandler.ReadResponse(resp); roomInfo = JsonConvert.DeserializeObject <RoomInfo>(body); } return(roomInfo); }