private async Task <BatchRequestResponse> SendBatchRequestAsync(Func <Task> executeRequests)
        {
            BatchApiRequest.StartNewBatchRequest();

            try
            {
                bool isBatchSuccess = true;
                var  data           = new List <object>();

                await executeRequests();

                List <BatchApiResponse> batchResponses = await BatchApiRequest.SendBatchApiRequest();

                for (int i = 0; i < batchResponses.Count; i++)
                {
                    BatchApiResponse batchResponse = batchResponses[i];
                    if (batchResponse.status_code != 200)
                    {
                        isBatchSuccess = false;
                        BatchApiRequest.AbortBatchRequest();
                        break;
                    }
                    var body = batchResponses[i].GetBody <object>();
                    data.Add(body);
                }

                var response = new BatchRequestResponse(isBatchSuccess, "200", data.ToJson());
                return(response);
            }
            catch (AggregateException ex)
            {
                BatchApiRequest.AbortBatchRequest();
                return(new BatchRequestResponse(false, "500", null, ex.ToString()));
            }
            catch (InvalidOperationException ex)
            {
                BatchApiRequest.AbortBatchRequest();
                return(new BatchRequestResponse(false, "500", null, ex.ToString()));
            }
        }
        public async Task <BatchRequestResponse> CreateTemplatesAsync()
        {
            BatchRequestResponse response = await SendBatchRequestAsync(async() =>
            {
                var templateVersion1 = new TemplateVersion
                {
                    name    = $"Store 1",
                    subject = $"Store 1",
                    html    = "Template1.html".ToHtmlTemplate(),
                };
                await Template.CreateTemplateAsync(templateVersion1);

                var templateVersion2 = new TemplateVersion
                {
                    name    = $"Store 2",
                    subject = $"Store 2",
                    html    = "Template2.html".ToHtmlTemplate(),
                };
                await Template.CreateTemplateAsync(templateVersion2);
            });

            return(response);
        }