public GcmMessageResponse SendMessage(GcmMessage message)
        {
            GcmMessageResponse response = Send <GcmMessage, GcmMessageResponse>(message, GCM_SEND_URL);

            response.Message = message;
            UpdateResponseStatusForGcmMessage(response);
            return(response);
        }
        public void UpdateResponseStatusForGcmMessage(GcmMessageResponse response)
        {
            HttpStatusCode statusCode = response.HttpWebResponse.StatusCode;

            if (statusCode == HttpStatusCode.BadRequest)
            {
                response.ResponseStatus = ENUM_GCM_MESSAGE_RESPONSE_TYPES.INVALID_JSON;
            }
            else if (statusCode == HttpStatusCode.OK)
            {
                response.ResponseStatus = ENUM_GCM_MESSAGE_RESPONSE_TYPES.SUCCESS;
                foreach (var status in response.Results)
                {
                    switch (status.Error)
                    {
                    case null:
                        break;

                    case "MissingRegistration":
                        status.Status = ENUM_GCM_MESSAGE_RESPONSE_TYPES.MISSING_REGISTRATION_TOKEN;
                        break;

                    case "InvalidRegistration":
                        status.Status = ENUM_GCM_MESSAGE_RESPONSE_TYPES.INVALID_REGISTRATION_TOKEN;
                        break;

                    case "NotRegistered":
                        status.Status = ENUM_GCM_MESSAGE_RESPONSE_TYPES.UNREGISTED_DEVICE;
                        break;

                    case "InvalidPackageName":
                        status.Status = ENUM_GCM_MESSAGE_RESPONSE_TYPES.INVALID_PACKAGE_NAME;
                        break;

                    case "MismatchSenderId":
                        status.Status = ENUM_GCM_MESSAGE_RESPONSE_TYPES.MISMATHED_SENDER;
                        break;

                    case "MessageTooBig":
                        status.Status = ENUM_GCM_MESSAGE_RESPONSE_TYPES.MESSAGE_TOO_BIG;
                        break;

                    case "InvalidDataKey":
                        status.Status = ENUM_GCM_MESSAGE_RESPONSE_TYPES.INVALID_DATA_KEY;
                        break;

                    case "InvalidTtl":
                        status.Status = ENUM_GCM_MESSAGE_RESPONSE_TYPES.INVALID_TIME_TO_LIVE;
                        break;

                    case "Unavailable":
                        status.Status           = ENUM_GCM_MESSAGE_RESPONSE_TYPES.TIMEOUT;
                        response.ResponseStatus = ENUM_GCM_MESSAGE_RESPONSE_TYPES.TIMEOUT;
                        break;

                    case "InternalServerError":
                        status.Status           = ENUM_GCM_MESSAGE_RESPONSE_TYPES.INTERNAL_SERVER_ERROR;
                        response.ResponseStatus = ENUM_GCM_MESSAGE_RESPONSE_TYPES.INTERNAL_SERVER_ERROR;
                        break;

                    case "DeviceMessageRateExceeded":
                        status.Status = ENUM_GCM_MESSAGE_RESPONSE_TYPES.DEVICE_MESSAGE_RATE_EXCEEDED;
                        break;

                    case "TopicsMessageRateExceeded":
                        status.Status = ENUM_GCM_MESSAGE_RESPONSE_TYPES.TOPICS_MESSAGE_RATE_EXCEEDED;
                        break;

                    default:
                        break;
                    }
                }
            }
            else if (statusCode == HttpStatusCode.Unauthorized)
            {
                response.ResponseStatus = ENUM_GCM_MESSAGE_RESPONSE_TYPES.AUTHENTICATION_ERROR;
            }
            else if (statusCode >= HttpStatusCode.InternalServerError)
            {
                response.ResponseStatus = ENUM_GCM_MESSAGE_RESPONSE_TYPES.INTERNAL_SERVER_ERROR;
            }
        }