/// <summary> /// This funtion makes API call to get SMS /// </summary> public RecognitionObj.RootObject speechToText(string parXspeechContext, string parXArgs, string parSpeechFilePath, bool parChunked) { var audioFileStream = new FileStream(parSpeechFilePath, FileMode.Open, FileAccess.Read); BinaryReader reader = new BinaryReader(audioFileStream); byte[] binaryData = reader.ReadBytes((int)audioFileStream.Length); reader.Close(); audioFileStream.Close(); if (binaryData.Length > 0) { APIRequest apiRequest = new APIRequest("speechToText"); apiRequest.accept = "application/json"; apiRequest.addHeaders("X-SpeechContext", parXspeechContext); apiRequest.addHeaders("X-Arg", parXArgs); apiRequest.contentType = "audio/wav"; apiRequest.accept = "application/json"; apiRequest.SendChunked = parChunked; apiRequest.binaryData = binaryData; if (apiService.post(apiRequest)) { RecognitionObj robj = new RecognitionObj(); return robj.deserializeRecognition(apiService.apiResponse.getResponseData()); } throw new Exception(apiService.errorResponse); } throw new Exception("No audio data."); }
/// <summary> /// This using makes API call to create message index /// </summary> public bool createMessageIndex() { APIRequest apiRequest = new APIRequest("messages/index"); apiRequest.accept = "application/json"; return apiService.post(apiRequest); }
/// <summary> /// This function makes API call to add contact to group operation /// </summary> public bool addContactToGroup(string groupID, string contactids) { APIRequest apiRequest = new APIRequest("groups/" + groupID + "/contacts?contactIds=" + contactids); if (apiService.post(apiRequest)) { return true; } throw new Exception(apiService.errorResponse); }
public DeviceIdObj.RootObject GetDeviceCapabilities() { APIRequest apiRequest = new APIRequest("Info"); apiRequest.accept = "application/json"; if (apiService.get(apiRequest)) { DeviceIdObj responseObj = new DeviceIdObj(); return responseObj.deserializeDeviceIdObj(apiService.apiResponse.getResponseData()); } return null; }
/// <summary> /// This funtion makes API call to get SMS DeliveryStatus /// </summary> /// <param name="messageID">messageID</param> public DeliveryInfoObj.RootObject getSMSDeliveryStatus(string messageID) { APIRequest apiRequest = new APIRequest("outbox/" + messageID); apiRequest.accept = "application/json"; if (apiService.get(apiRequest)) { DeliveryInfoObj statusResponseObj = new DeliveryInfoObj(); return statusResponseObj.deserializeDeliveryInfo(apiService.apiResponse.getResponseData()); } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to delete messages /// </summary> public bool deleteMessages(string quertString) { APIRequest apiRequest = new APIRequest("messages?" + quertString); apiRequest.accept = "application/json"; if (apiService.delete(apiRequest)) { return true; } throw new Exception(apiService.errorResponse); }
/// <summary> /// This funtion makes API call to get SMS /// </summary> /// <param name="RegistrationID">RegistrationID</param> public InboundSmsMessageObj.RootObject getSMS(string RegistrationID) { APIRequest apiRequest = new APIRequest("inbox/" + RegistrationID); apiRequest.accept = "application/json"; if (apiService.get(apiRequest)) { InboundSmsMessageObj MsgListresponseObj = new InboundSmsMessageObj(); return MsgListresponseObj.deserializeMsgListRequest(apiService.apiResponse.getResponseData()); } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to create contact operation /// </summary> public string createContact(string data) { APIRequest apiRequest = new APIRequest("contacts"); apiRequest.contentType = "application/json"; apiRequest.setBinaryData(data); if (apiService.post(apiRequest)) { return apiService.apiResponse.location; } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to get MMS delivery status /// </summary> public DeliveryInfoObj.RootObject getMMSDeliveryStatus(string messageID) { APIRequest apiRequest = new APIRequest("outbox/" + messageID); apiRequest.accept = "application/json"; if (apiService.get(apiRequest)) { DeliveryInfoObj ro = new DeliveryInfoObj(); return ro.deserializeDeliveryInfo(apiService.apiResponse.getResponseData()); } return null; }
/// <summary> /// This function makes API call to send MMS /// </summary> public OutboundMessageResponseObj.RootObject sendMMS(string mmsAddress, string mmsMessage, string mmsFile, string mmsContentType) { APIRequest apiRequest = new APIRequest("outbox"); string boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x"); apiRequest.accept = "application/json"; apiRequest.contentType = "multipart/related; type=\"application/x-www-form-urlencoded\"; start=\"<startpart>\"; boundary=\"" + boundary + "\"\r\n"; apiRequest.binaryData = setFinalByte(mmsAddress, mmsMessage, mmsFile, mmsContentType, false, boundary); if (apiService.post(apiRequest)) { OutboundMessageResponseObj ro = new OutboundMessageResponseObj(); return ro.deserializeOutboundSMSResponse(apiService.apiResponse.getResponseData()); } throw new Exception(apiService.errorResponse); }
public AdsObj.RootObject GetAds(string category, string udid, string userAgent) { try { APIRequest apiRequest = new APIRequest("ads?Category=" + category); apiRequest.accept = "application/json"; apiRequest.addHeaders("Udid", udid); apiRequest.userAgent = userAgent; if (apiService.get(apiRequest)) { return new AdsObj().deserializeAdsObj(apiService.apiResponse.getResponseData()); } } catch (Exception ex) { string error = ex.Message; } return null; }
/// <summary> /// This funtion makes API call to send SMS /// </summary> public byte[] textToSpeech(string data) { APIRequest apiRequest = new APIRequest("textToSpeech"); apiRequest.accept = "audio/amr-wb"; apiRequest.contentType = "text/plain"; apiRequest.setBinaryData(data); if (apiService.post(apiRequest)) { return apiService.apiResponse.getResponseBinary(); } return null; }
/// <summary> /// This function makes API call to delete group operation /// </summary> public bool deleteGroup(string groupID) { APIRequest apiRequest = new APIRequest("groups/" + groupID); if (apiService.delete(apiRequest)) { return true; } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to get contacts operation /// </summary> public QuickContactObj.RootObject getContacts(string search) { APIRequest apiRequest = new APIRequest("contacts?" + "search=" + search); apiRequest.accept = "application/json"; apiRequest.addHeaders("x-fields", "shallow"); if (apiService.get(apiRequest)) { var contact = new QuickContactObj(); return contact.deserializeQuickContactsObj(apiService.apiResponse.getResponseData()); } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to get message /// </summary> public MessageObj.Message getMessage(string messageId) { APIRequest apiRequest = new APIRequest("messages/" + messageId); apiRequest.accept = "application/json"; if (apiService.get(apiRequest)) { var message = new MessageObj(); return message.deserializeMessageObj(apiService.apiResponse.getResponseData()); } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to get contacts operation /// </summary> public String getMyInfo() { APIRequest apiRequest = new APIRequest("myInfo"); apiRequest.accept = "application/json"; if (apiService.get(apiRequest)) { //return true; return apiService.apiResponse.getResponseData(); } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to get group contacts operation /// </summary> public string getGroupContacts(string groupID) { APIRequest apiRequest = new APIRequest("groups/" + groupID + "/contacts?"); apiRequest.accept = "application/json"; if (apiService.get(apiRequest)) { return apiService.apiResponse.getResponseData(); } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to get message list /// </summary> public MessageObj.MessageList getMessageList(string limit, string offset) { if (String.IsNullOrEmpty(limit)) { limit = "500"; } if (String.IsNullOrEmpty(offset)) { offset = "50"; } APIRequest apiRequest = new APIRequest("messages?limit=" + limit + "&offset=" + offset); apiRequest.accept = "application/json"; if (apiService.get(apiRequest)) { var message = new MessageObj(); return message.deserializeMessageListObj(apiService.apiResponse.getResponseData()); } throw new Exception(apiService.errorResponse); }
/// <summary> /// This funtion makes API call to send SMS /// </summary> /// <param name="data">JSON string</param> public OutboundSMSResponseObj.RootObject sendSMS(string add, string msg) { var obSMSreqObj = new OutboundSMSRequestObj.RootObject() { outboundSMSRequest = new OutboundSMSRequestObj.OutboundSMSRequest() { address = add, message = msg } }; var serializer = new JavaScriptSerializer(); var data = serializer.Serialize(obSMSreqObj); APIRequest apiRequest = new APIRequest("outbox"); apiRequest.accept = "application/json"; apiRequest.contentType = "application/json"; apiRequest.setBinaryData(data); if (apiService.post(apiRequest)) { OutboundSMSResponseObj responseObj = new OutboundSMSResponseObj(); return responseObj.deserializeOutboundSMSResponse(apiService.apiResponse.getResponseData()); } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to get message delta /// </summary> public string getMessageDelta(string state) { APIRequest apiRequest = new APIRequest("delta?state=" + state); apiRequest.accept = "application/json"; if (apiService.get(apiRequest)) { return apiService.apiResponse.getResponseData(); } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to get message index info /// </summary> public string getMessageIndexInfo() { APIRequest apiRequest = new APIRequest("messages/index/info"); apiRequest.accept = "application/json"; if (apiService.get(apiRequest)) { return apiService.apiResponse.getResponseData(); } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to get groups operation /// </summary> public GroupObj.RootObject getGroups(string groupsName) { APIRequest apiRequest = new APIRequest("groups??groupName=" + groupsName); apiRequest.accept = "application/json"; if (apiService.get(apiRequest)) { var group = new GroupObj(); return group.deserializeGroupObj(apiService.apiResponse.getResponseData()); } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function gets access token with post request /// </summary> public bool RevokeToken(TokenTypeHint tokenType, String token) { TokenTypeHint t = tokenType; var query = HttpUtility.ParseQueryString(String.Empty); string oauthParameters = String.Empty; switch (t) { case TokenTypeHint.AccessToken: query["client_id"] = apiKey; query["client_secret"] = secretKey; query["token"] = token; query["token_type_hint"] = "access_token"; break; case TokenTypeHint.RefreshToken: query["client_id"] = apiKey; query["client_secret"] = secretKey; query["token"] = token; query["token_type_hint"] = "refresh_token"; break; } oauthParameters = query.ToString(); if (!String.IsNullOrEmpty(oauthParameters)) { var revokeService = new APIService(endPoint, "/oauth/v4/"); var apiRequest = new APIRequest("revoke"); apiRequest.requireAccessToken = false; apiRequest.contentType = "application/x-www-form-urlencoded"; apiRequest.setBinaryData(oauthParameters); if (revokeService.post(apiRequest)) { return true; } } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function gets access token with post request /// </summary> public bool GetAccessToken(AccessTokenType type) { AccessTokenType t = type; var query = HttpUtility.ParseQueryString(String.Empty); string oauthParameters = String.Empty; switch (t) { case AccessTokenType.AuthorizationCode: query["grant_type"] = "authorization_code"; query["client_id"] = apiKey; query["client_secret"] = secretKey; query["code"] = authCode; break; case AccessTokenType.RefreshToken: query["grant_type"] = "refresh_token"; query["client_id"] = apiKey; query["client_secret"] = secretKey; query["refresh_token"] = refreshToken; break; case AccessTokenType.ClientCredentials: query["grant_type"] = "client_credentials"; query["client_id"] = apiKey; query["client_secret"] = secretKey; query["scope"] = scope; break; } oauthParameters = query.ToString(); if (!String.IsNullOrEmpty(oauthParameters)) { var apiRequest = new APIRequest("token"); apiRequest.requireAccessToken = false; apiRequest.contentType = "application/x-www-form-urlencoded"; apiRequest.accept = "application/json"; apiRequest.setBinaryData(oauthParameters); if (apiService.post(apiRequest)) { accessTokenJson = apiService.apiResponse.getResponseData(); this.ResetTokenVariables(); return true; } } throw new Exception(apiService.errorResponse); }
/// <summary> /// This funtion makes API call to get SMS /// </summary> public RecognitionObj.RootObject speechToTextCustom(string mimeData, string XspeechContext, string XArgs, string SpeechFilePath, string xdictionaryContent, string xgrammerContent) { APIRequest apiRequest = new APIRequest("speechToTextCustom"); string boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x"); apiRequest.accept = "application/json"; apiRequest.addHeaders("Content-Language", "en-us"); apiRequest.addHeaders("X-Arg", XArgs); apiRequest.contentType = "multipart/x-srgs-audio; " + "boundary=" + boundary; apiRequest.accept = "application/json"; apiRequest.binaryData = getTotalByte(boundary, xdictionaryContent, SpeechFilePath, xgrammerContent); if (apiService.post(apiRequest)) { RecognitionObj robj = new RecognitionObj(); return robj.deserializeRecognition(apiService.apiResponse.getResponseData()); } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to get message delta /// </summary> public string getMessageNotificationConnectionDetails(string queues) { APIRequest apiRequest = new APIRequest("notificationConnectionDetails?queues=" + queues); apiRequest.accept = "application/json"; if (apiService.get(apiRequest)) { return apiService.apiResponse.getResponseData(); } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to delete contact operation /// </summary> public bool deleteContact(string contactID) { APIRequest apiRequest = new APIRequest("contacts/" + contactID); if (apiService.delete(apiRequest)) { return true; } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to update messages /// </summary> public bool updateMessages(string data) { APIRequest apiRequest = new APIRequest("messages"); apiRequest.accept = "application/json"; apiRequest.contentType = "application/json"; apiRequest.setBinaryData(data); if (apiService.put(apiRequest)) { return true; } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to get message content /// </summary> public string getMessageContent(string messageId, string partId) { APIRequest apiRequest = new APIRequest("messages/" + messageId + "/parts/" + partId); apiRequest.accept = "application/json"; if (apiService.get(apiRequest)) { return apiService.apiResponse.getResponseData(); } throw new Exception(apiService.errorResponse); }
/// <summary> /// This function makes API call to update group operation /// </summary> public bool updateGroup(string groupID, string data) { APIRequest apiRequest = new APIRequest("groups/" + groupID); apiRequest.contentType = "application/json"; apiRequest.setBinaryData(data); if (apiService.patch(apiRequest)) { return true; } throw new Exception(apiService.errorResponse); }