public NotificationsApi(IBitmovinApiClientFactory apiClientFactory)
 {
     _apiClient = apiClientFactory.CreateClient <INotificationsApiClient>();
     Webhooks   = new WebhooksApi(apiClientFactory);
     States     = new StatesApi(apiClientFactory);
     Emails     = new EmailsApi(apiClientFactory);
 }
        public static void SendServerEmail(UserInfo userInfo, EmailMessage emailMessage, List <string> attachments, string accountName, int count = 0)
        {
            var apiInstance = new EmailsApi(userInfo.ServerUrl);

            apiInstance.Configuration.AccessToken = userInfo.Token;

            try
            {
                var emailMessageJson = JsonConvert.SerializeObject(emailMessage);

                if (attachments != null)
                {
                    List <SystemFile.FileStream> attachmentsList = new List <SystemFile.FileStream>();

                    foreach (var attachment in attachments)
                    {
                        SystemFile.FileStream _file = new SystemFile.FileStream(attachment, SystemFile.FileMode.Open, SystemFile.FileAccess.Read);
                        attachmentsList.Add(_file);
                    }

                    apiInstance.ApiVapiVersionEmailsSendPostAsyncWithHttpInfo(userInfo.ApiVersion, userInfo.OrganizationId, emailMessageJson, attachmentsList, accountName).Wait();

                    foreach (var file in attachmentsList)
                    {
                        file.Flush();
                        file.Dispose();
                        file.Close();
                    }
                }
                else
                {
                    apiInstance.ApiVapiVersionEmailsSendPostAsyncWithHttpInfo(userInfo.ApiVersion, userInfo.OrganizationId, emailMessageJson, null, accountName).Wait();
                }
            }
            catch (Exception ex)
            {
                if (ex.GetType().GetProperty("ErrorCode").GetValue(ex, null).ToString() == "401" && count < 2)
                {
                    UtilityMethods.RefreshToken(userInfo);
                    count++;
                    SendServerEmail(userInfo, emailMessage, attachments, accountName, count);
                }
                else if (ex.Message != "One or more errors occurred.")
                {
                    throw new InvalidOperationException("Exception when calling EmailsApi.SendEmail: " + ex.Message);
                }
                else
                {
                    throw new InvalidOperationException(ex.InnerException.Message);
                }
            }
        }
        public static void SendServerEmail(string token, string serverUrl, string organizationId, EmailMessage emailMessage, List <string> attachments, string accountName, string apiVersion)
        {
            var apiInstance = new EmailsApi(serverUrl);

            apiInstance.Configuration.AccessToken = token;

            try
            {
                var emailMessageJson = JsonConvert.SerializeObject(emailMessage);

                if (attachments != null)
                {
                    List <SystemFile.FileStream> attachmentsList = new List <SystemFile.FileStream>();

                    foreach (var attachment in attachments)
                    {
                        SystemFile.FileStream _file = new SystemFile.FileStream(attachment, SystemFile.FileMode.Open, SystemFile.FileAccess.Read);
                        attachmentsList.Add(_file);
                    }

                    apiInstance.ApiVapiVersionEmailsSendPostAsyncWithHttpInfo(apiVersion, organizationId, emailMessageJson, attachmentsList, accountName).Wait();

                    foreach (var file in attachmentsList)
                    {
                        file.Flush();
                        file.Dispose();
                        file.Close();
                    }
                }
                else
                {
                    apiInstance.ApiVapiVersionEmailsSendPostAsyncWithHttpInfo(apiVersion, organizationId, emailMessageJson, null, accountName).Wait();
                }
            }
            catch (Exception ex)
            {
                if (ex.Message != "One or more errors occurred.")
                {
                    throw new InvalidOperationException("Exception when calling EmailsApi.SendEmail: " + ex.Message);
                }
                else
                {
                    throw new InvalidOperationException(ex.InnerException.Message);
                }
            }
        }
Example #4
0
 public void Init()
 {
     instance = new EmailsApi();
 }
Example #5
0
 public EmailsApiTests()
 {
     instance = new EmailsApi();
 }