public override MessageStatusResponse GetMessageStatus(APIMessageRequest request) { try { //Will hold all the MessageStatuses of all the APIMessageIds requested var messageStatuses = new List <MessageStatus>(); //Will hold all the raw webResponses from the Clickatell service var messageResults = new StringBuilder(); //Loops through all APIMessageIds requested to check status foreach (var apiMsgId in request.APIMessageIds) { //Get WebRequest with MessageStatusURL+current apiMsgId with GET method var webRequest = GetWebRequest(string.Format(Properties.RESTSettings.Default.MessageStatusURL, apiMsgId), Properties.RESTSettings.Default.GetMethod); //Get WebResponse from Clickatell service var webResponse = GetWebResponse(webRequest); //Add raw webResponse to messageResults messageResults.AppendLine(webResponse.Result); //Deserlialize the webResponse to Data.JSON.REST.MessageStatusResponse.Rootobject var jsonResponse = JsonDeserialize <Data.JSON.REST.MessageStatusResponse.Rootobject>(webResponse.Result).data; if (jsonResponse != null) { //Maps the jsonResponse to MessageStatus and adds it to the messageStatuses list messageStatuses.Add(new MessageStatus { APIMessageID = jsonResponse.apiMessageId, Description = jsonResponse.description, Status = jsonResponse.messageStatus }); } } return(new MessageStatusResponse { Success = true, Result = messageResults.ToString(), MessageStatuses = messageStatuses.ToArray() }); } catch (Exception exception) { return(new MessageStatusResponse { Result = string.Format("Error occured during Clickatell {0}. Details: {1}", MethodBase.GetCurrentMethod().Name, exception.Message), Success = false }); } }
public override MessageStatusResponse GetMessageStatus(APIMessageRequest request) { try { //MessageStatuses of all the APIMessageIds requested var messageStatuses = new List <MessageStatus>(); //Raw web responses from the Clickatell service var messageResults = new StringBuilder(); //Loops through all APIMessageIds requested to check statuses foreach (var apiMsgId in request.APIMessageIds) { //Send Request to Clickatell service with MessageStatusURL and apiMessageId var response = SendRequest(Properties.HTTPSettings.Default.MessageStatusURL, apiMessageId: apiMsgId); //Add raw response to messageResults messageResults.AppendLine(response); //Extract messageStatus from string response var messageStatus = GetMessageStatusFromResponse(response); //Adds messageStatus to messageStatuses list messageStatuses.Add(messageStatus); } return(new MessageStatusResponse { Success = true, Result = messageResults.ToString(), MessageStatuses = messageStatuses.ToArray() }); } catch (Exception exception) { return(new MessageStatusResponse { Result = string.Format("Error occured during Clickatell {0}. Details: {1}", MethodBase.GetCurrentMethod().Name, exception.Message), Success = false }); } }
/// <summary> /// Sends a request with APIMessageID(s) to see what the costs were for these phonenumber(s) sent. /// </summary> /// <param name="request"></param> /// <returns> /// MessageChargeResponse: /// Success = If call was successfully made to Clickatell /// Result = Service response /// MessageCharges[] = MessageCharge object which will have the current APIMessageID and Charge of that call. /// </returns> public abstract MessageChargeResponse GetMessageCharge(APIMessageRequest request);
/// <summary> /// Sends a request with APIMessageID(s) to see in what status the requested APIMessageID(s) are. /// </summary> /// <param name="request"></param> /// <returns> /// MessageStatusResponse: /// Success = If call was successfully made to Clickatell /// Result = Service response /// MessageStatuses[] = MessageStatus object which will have the current APIMessageID, Status and Description of the message. /// </returns> public abstract MessageStatusResponse GetMessageStatus(APIMessageRequest request);
/// <summary> /// Sends request with APIMessageID(s) to stop/delete a message. /// Note the message will only be stopped if it is still in Clickatells queue. /// </summary> /// <param name="request"></param> /// <returns> /// MessageStatusResponse: /// Success = If call was successfully made to Clickatell /// Result = Service response /// MessageStatuses[] = MessageStatus object which will have the current APIMessageID, Status and Description of the message. /// </returns> public abstract MessageStatusResponse StopMessage(APIMessageRequest request);