private static async Task <PlanningCenterRestResponse <PlanningCenterToken> > GetTokenAsync(string url, FormUrlEncodedContent content)
        {
            using (var httpClient = new HttpClient()) {
                var response = await httpClient.PostAsync($"{url}/oauth/token", content);

                var responseContent = await response.Content.ReadAsStringAsync();

                var pcResponse = new PlanningCenterRestResponse <PlanningCenterToken> {
                    StatusCode   = response.StatusCode,
                    RequestValue = Newtonsoft.Json.JsonConvert.SerializeObject(content),
                    JsonResponse = responseContent
                };

                if (!string.IsNullOrEmpty(responseContent) && responseContent.Contains("error"))
                {
                    var responseError = responseContent.FromJson <dynamic>();
                    pcResponse.ErrorMessage = responseError.error_description;
                }
                else
                {
                    pcResponse.Data = responseContent.FromJson <PlanningCenterToken>();
                }
                return(pcResponse);
            }
        }
        private async Task <IPlanningCenterRestResponse <S> > ConvertResponseAsync <S>(HttpResponseMessage response, string request = "") where S : new()
        {
            var planningCenterResponse = new PlanningCenterRestResponse <S> {
                StatusCode   = response.StatusCode,
                JsonResponse = await response.Content.ReadAsStringAsync(),
                RequestValue = request
            };

            if (!string.IsNullOrEmpty(planningCenterResponse.JsonResponse) && (int)response.StatusCode > 300)
            {
                planningCenterResponse.ErrorMessage = planningCenterResponse.JsonResponse;
            }
            else
            {
                try {
                    planningCenterResponse.Data = JsonConvert.DeserializeObject <S>(planningCenterResponse.JsonResponse, new JsonApiSerializerSettings {
                        ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
                    });
                }
                catch (Exception e) {
                    var t = e.Message;
                    throw;
                }
            }

            return(planningCenterResponse);
        }
        private async Task <IPlanningCenterRestResponse> ConvertResponseAsync(HttpResponseMessage response, string request = "")
        {
            var planningCenterResponse = new PlanningCenterRestResponse {
                StatusCode   = response.StatusCode,
                JsonResponse = await response.Content.ReadAsStringAsync(),
                RequestValue = request
            };

            if (!string.IsNullOrEmpty(planningCenterResponse.JsonResponse) && (int)response.StatusCode > 300)
            {
                planningCenterResponse.ErrorMessage = planningCenterResponse.JsonResponse;
            }

            return(planningCenterResponse);
        }