コード例 #1
0
ファイル: SMS.cs プロジェクト: mattcobb/codekit-csharp
        /// <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);
        }
コード例 #2
0
ファイル: SMS.cs プロジェクト: venugec/codekit-csharp
        /// <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);
        }