private static bool IsSuccess(string responseContent, SendyActions action)
        {
            switch (action)
            {
            case SendyActions.Subscribe:
            case SendyActions.Unsubscribe:
            case SendyActions.DeleteSubscriber:
                return(responseContent == "1");

            case SendyActions.SubscriptionStatus:
                var successContent = new List <string> {
                    "Subscribed", "Unsubscribed", "Unconfirmed", "Bounced", "Soft bounced", "Complained"
                };
                return(successContent.Contains(responseContent));

            case SendyActions.ActiveSubscriberCount:
            case SendyActions.CreateList:
                return(int.TryParse(responseContent, out int dummy));

            case SendyActions.CreateCampaign:
                successContent = new List <string> {
                    "Campaign created", "Campaign created and now sending"
                };
                return(successContent.Contains(responseContent));

            default:
                throw new ArgumentOutOfRangeException(nameof(action), action, null);
            }
        }
        internal static async Task <SendyResponse> HandleResponse(HttpResponseMessage responseMessage, SendyActions action)
        {
            if (responseMessage.IsSuccessStatusCode)
            {
                var responseContent = await responseMessage.Content.ReadAsStringAsync();

                responseContent = responseContent.Trim();
                var isSuccess = IsSuccess(responseContent, action);

                return(new SendyResponse
                {
                    IsSuccess = isSuccess,
                    ErrorMessage = !isSuccess ? responseContent : "",
                    Response = isSuccess && ActionsWithUsefulResponseContent.Contains(action) ? responseContent : ""
                });
            }
            return(new SendyResponse
            {
                IsSuccess = false,
                ErrorMessage =
                    $"Problem while connecting to your Sendy installation. Statuscode {responseMessage.StatusCode}, error: {responseMessage.Content}"
            });
        }