Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public void Test_CSConstants_InternalConstants()
public void Test_CSConstants_InternalMessages()
{
Assert.AreEqual("You are already logged in.", CSConstants.YouAreLoggedIn);
Assert.AreEqual("You are need to login.", CSConstants.YouAreNotLoggedIn);
Assert.AreEqual("Uid should not be empty.", CSConstants.MissingUID);
Assert.AreEqual("API Key should not be empty.", CSConstants.MissingAPIKey);
Assert.AreEqual("You are not logged in. Log in and try again.", CSConstants.YouAreNotLoggedIn);
Assert.AreEqual("UID is required. Provide a valid UID and try again.", CSConstants.MissingUID);
Assert.AreEqual("API Key is required. Provide a valid API Key and try again.", CSConstants.MissingAPIKey);
Assert.AreEqual("API Key should be empty.", CSConstants.APIKey);
Assert.AreEqual("Please enter email id to remove from org.", CSConstants.RemoveUserEmailError);
Assert.AreEqual("Please enter share uid to resend invitation.", CSConstants.OrgShareUIDMissing);
Expand Down
10 changes: 5 additions & 5 deletions Contentstack.Management.Core/ContentstackClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public Task<ContentstackResponse> LogoutAsync(string authtoken = null)
public OAuthHandler OAuth(OAuthOptions options)
{
if (options == null)
throw new ArgumentNullException(nameof(options), "OAuth options cannot be null.");
throw new ArgumentNullException(nameof(options), CSConstants.OAuthOptionsRequired);

return new OAuthHandler(this, options);
}
Expand Down Expand Up @@ -519,10 +519,10 @@ public OAuthHandler OAuth()
internal void SetOAuthTokens(OAuthTokens tokens)
{
if (tokens == null)
throw new ArgumentNullException(nameof(tokens), "OAuth tokens cannot be null.");
throw new ArgumentNullException(nameof(tokens), CSConstants.OAuthTokensRequired);

if (string.IsNullOrEmpty(tokens.AccessToken))
throw new ArgumentException("Access token cannot be null or empty.", nameof(tokens));
throw new ArgumentException(CSConstants.AccessTokenRequired, nameof(tokens));

// Store the access token in the client options for use in HTTP requests
// This will be used by the HTTP pipeline to inject the Bearer token
Expand All @@ -541,7 +541,7 @@ internal void SetOAuthTokens(OAuthTokens tokens)
public OAuthTokens GetOAuthTokens(string clientId)
{
if (string.IsNullOrEmpty(clientId))
throw new ArgumentException("Client ID cannot be null or empty.", nameof(clientId));
throw new ArgumentException(CSConstants.ClientIDRequired, nameof(clientId));

return GetStoredOAuthTokens(clientId);
}
Expand Down Expand Up @@ -607,7 +607,7 @@ public void ClearOAuthTokens(string clientId = null)
internal void StoreOAuthTokens(string clientId, OAuthTokens tokens)
{
if (string.IsNullOrEmpty(clientId))
throw new ArgumentException("Client ID cannot be null or empty.", nameof(clientId));
throw new ArgumentException(CSConstants.ClientIDRequired, nameof(clientId));

if (tokens == null)
throw new ArgumentNullException(nameof(tokens));
Expand Down
5 changes: 3 additions & 2 deletions Contentstack.Management.Core/Models/Asset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Contentstack.Management.Core.Queryable;
using Contentstack.Management.Core.Services.Models;
using Contentstack.Management.Core.Utils;

namespace Contentstack.Management.Core.Models
{
Expand Down Expand Up @@ -359,15 +360,15 @@ internal void ThrowIfUidNotEmpty()
{
if (!string.IsNullOrEmpty(this.Uid))
{
throw new InvalidOperationException("Operation not allowed.");
throw new InvalidOperationException(CSConstants.AssetAlreadyExists);
}
}

internal void ThrowIfUidEmpty()
{
if (string.IsNullOrEmpty(this.Uid))
{
throw new InvalidOperationException("Uid can not be empty.");
throw new InvalidOperationException(CSConstants.AssetUIDRequired);
}
}
#endregion
Expand Down
5 changes: 3 additions & 2 deletions Contentstack.Management.Core/Models/AssetModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using System.Net.Http;
using Contentstack.Management.Core.Abstractions;
using Contentstack.Management.Core.Utils;

namespace Contentstack.Management.Core.Models
{
Expand Down Expand Up @@ -29,11 +30,11 @@ public AssetModel(string fileName, ByteArrayContent byteArray, string contentTyp
{
if (fileName == null)
{
throw new ArgumentNullException("fileName", "File name can not be null.");
throw new ArgumentNullException("fileName", CSConstants.FileNameRequired);
}
if (byteArray == null)
{
throw new ArgumentNullException("byteArray", "Uploading content can not be null.");
throw new ArgumentNullException("byteArray", CSConstants.UploadContentRequired);
}
FileName = fileName;
Title = title;
Expand Down
5 changes: 3 additions & 2 deletions Contentstack.Management.Core/Models/AuditLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Contentstack.Management.Core.Queryable;
using Contentstack.Management.Core.Services.Models;
using Contentstack.Management.Core.Utils;

namespace Contentstack.Management.Core.Models
{
Expand Down Expand Up @@ -107,15 +108,15 @@ internal void ThrowIfUidNotEmpty()
{
if (!string.IsNullOrEmpty(this.Uid))
{
throw new InvalidOperationException("Operation not allowed.");
throw new InvalidOperationException(CSConstants.OperationNotAllowedOnAuditLogs);
}
}

internal void ThrowIfUidEmpty()
{
if (string.IsNullOrEmpty(this.Uid))
{
throw new InvalidOperationException("Uid can not be empty.");
throw new InvalidOperationException(CSConstants.AuditLogUIDRequired);
}
}
#endregion
Expand Down
7 changes: 4 additions & 3 deletions Contentstack.Management.Core/Models/BaseModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Contentstack.Management.Core.Queryable;
using Contentstack.Management.Core.Services.Models;
using Contentstack.Management.Core.Utils;

namespace Contentstack.Management.Core.Models
{
Expand All @@ -19,7 +20,7 @@ public BaseModel(Stack stack, string fieldName, string uid = null)
stack.ThrowIfAPIKeyEmpty();
if (fieldName == null)
{
throw new ArgumentNullException("fieldName", "Field name mandatory for service");
throw new ArgumentNullException("fieldName", CSConstants.FieldNameRequired);
}
this.stack = stack;
this.fieldName = fieldName;
Expand Down Expand Up @@ -105,15 +106,15 @@ internal void ThrowIfUidNotEmpty()
{
if (!string.IsNullOrEmpty(this.Uid))
{
throw new InvalidOperationException("Operation not allowed.");
throw new InvalidOperationException(CSConstants.OperationNotAllowedOnModel);
}
}

internal void ThrowIfUidEmpty()
{
if (string.IsNullOrEmpty(this.Uid))
{
throw new InvalidOperationException("Uid can not be empty.");
throw new InvalidOperationException(CSConstants.MissingUID);
}
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using System.Net.Http;
using Contentstack.Management.Core.Abstractions;
using Contentstack.Management.Core.Utils;

namespace Contentstack.Management.Core.Models.CustomExtension
{
Expand Down Expand Up @@ -32,11 +33,11 @@ public CustomFieldModel(ByteArrayContent byteArray, string contentType, string t

if (byteArray == null)
{
throw new ArgumentNullException("byteArray", "Uploading content can not be null.");
throw new ArgumentNullException("byteArray", CSConstants.UploadContentRequired);
}
if (title == null)
{
throw new ArgumentNullException("title", "Title for widget is required.");
throw new ArgumentNullException("title", CSConstants.WidgetTitleRequired);
}
Title = title;
DataType = dataType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Net.Http;
using System.Net.Http.Headers;
using Contentstack.Management.Core.Abstractions;
using Contentstack.Management.Core.Utils;
using Newtonsoft.Json;

namespace Contentstack.Management.Core.Models.CustomExtension
Expand Down Expand Up @@ -33,11 +34,11 @@ public CustomWidgetModel(ByteArrayContent byteArray, string contentType, string
{
if (byteArray == null)
{
throw new ArgumentNullException("byteArray", "Uploading content can not be null.");
throw new ArgumentNullException("byteArray", CSConstants.UploadContentRequired);
}
if (title == null)
{
throw new ArgumentNullException("title", "Title for widget is required.");
throw new ArgumentNullException("title", CSConstants.WidgetTitleRequired);
}
Title = title;
Tags = tags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using System.Net.Http;
using Contentstack.Management.Core.Abstractions;
using Contentstack.Management.Core.Utils;

namespace Contentstack.Management.Core.Models.CustomExtension
{
Expand Down Expand Up @@ -32,11 +33,11 @@ public DashboardWidgetModel(ByteArrayContent byteArray, string contentType, stri

if (byteArray == null)
{
throw new ArgumentNullException("byteArray", "Uploading content can not be null.");
throw new ArgumentNullException("byteArray", CSConstants.UploadContentRequired);
}
if (title == null)
{
throw new ArgumentNullException("title", "Title for widget is required.");
throw new ArgumentNullException("title", CSConstants.WidgetTitleRequired);
}
Title = title;
Tags = tags;
Expand Down
5 changes: 3 additions & 2 deletions Contentstack.Management.Core/Models/Extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Contentstack.Management.Core.Abstractions;
using Contentstack.Management.Core.Queryable;
using Contentstack.Management.Core.Services.Models;
using Contentstack.Management.Core.Utils;

namespace Contentstack.Management.Core.Models
{
Expand Down Expand Up @@ -246,15 +247,15 @@ internal void ThrowIfUidNotEmpty()
{
if (!string.IsNullOrEmpty(this.Uid))
{
throw new InvalidOperationException("Operation not allowed.");
throw new InvalidOperationException(CSConstants.OperationNotAllowedOnExtension);
}
}

internal void ThrowIfUidEmpty()
{
if (string.IsNullOrEmpty(this.Uid))
{
throw new InvalidOperationException("Uid can not be empty.");
throw new InvalidOperationException(CSConstants.ExtensionUIDRequired);
}
}
#endregion
Expand Down
5 changes: 3 additions & 2 deletions Contentstack.Management.Core/Models/Folder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Contentstack.Management.Core.Queryable;
using Contentstack.Management.Core.Services.Models;
using Contentstack.Management.Core.Utils;

namespace Contentstack.Management.Core.Models
{
Expand Down Expand Up @@ -190,15 +191,15 @@ internal void ThrowIfUidNotEmpty()
{
if (!string.IsNullOrEmpty(this.Uid))
{
throw new InvalidOperationException("Operation not allowed.");
throw new InvalidOperationException(CSConstants.OperationNotAllowedOnFolder);
}
}

internal void ThrowIfUidEmpty()
{
if (string.IsNullOrEmpty(this.Uid))
{
throw new InvalidOperationException("Uid can not be empty.");
throw new InvalidOperationException(CSConstants.FolderUIDRequired);
}
}
#endregion
Expand Down
6 changes: 3 additions & 3 deletions Contentstack.Management.Core/Models/Organization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public ContentstackResponse RemoveUser(List<string> emails)
this.ThrowIfOrganizationUidNull();
if (emails == null)
{
throw new ArgumentNullException("emails");
throw new ArgumentNullException("emails", CSConstants.EmailsRequired);
}
var userInviteService = new UserInvitationService(_client.serializer, this.Uid, "DELETE");
userInviteService.RemoveUsers(emails);
Expand All @@ -240,7 +240,7 @@ public Task<ContentstackResponse> RemoveUserAsync(List<string> emails)
this.ThrowIfOrganizationUidNull();
if (emails == null)
{
throw new ArgumentNullException("emails");
throw new ArgumentNullException("emails", CSConstants.EmailsRequired);
}
var userInviteService = new UserInvitationService(_client.serializer, this.Uid, "DELETE");
userInviteService.RemoveUsers(emails);
Expand Down Expand Up @@ -429,7 +429,7 @@ private void ThrowIfOrganizationUidNull()
{
if (string.IsNullOrEmpty(this.Uid))
{
throw new InvalidOperationException(CSConstants.MissingUID);
throw new InvalidOperationException(CSConstants.OrganizationUIDRequired);
}
}
#endregion
Expand Down
5 changes: 3 additions & 2 deletions Contentstack.Management.Core/Models/PublishQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Contentstack.Management.Core.Queryable;
using Contentstack.Management.Core.Services.Models;
using Contentstack.Management.Core.Utils;

namespace Contentstack.Management.Core.Models
{
Expand Down Expand Up @@ -151,15 +152,15 @@ internal void ThrowIfUidNotEmpty()
{
if (!string.IsNullOrEmpty(this.Uid))
{
throw new InvalidOperationException("Operation not allowed.");
throw new InvalidOperationException(CSConstants.OperationNotAllowedOnPublishQueue);
}
}

internal void ThrowIfUidEmpty()
{
if (string.IsNullOrEmpty(this.Uid))
{
throw new InvalidOperationException("Uid can not be empty.");
throw new InvalidOperationException(CSConstants.PublishQueueUIDRequired);
}
}
#endregion
Expand Down
5 changes: 3 additions & 2 deletions Contentstack.Management.Core/Models/Release.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using Contentstack.Management.Core.Queryable;
using Contentstack.Management.Core.Services.Models;
using Contentstack.Management.Core.Utils;

namespace Contentstack.Management.Core.Models
{
Expand Down Expand Up @@ -236,7 +237,7 @@ public ContentstackResponse Clone(string name, string description)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException("name", "Invalide name.");
throw new ArgumentNullException("name", CSConstants.ReleaseNameInvalid);
}
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();
Expand Down Expand Up @@ -267,7 +268,7 @@ public Task<ContentstackResponse> CloneAsync(string name, string description)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException("name", "Invalide name.");
throw new ArgumentNullException("name", CSConstants.ReleaseNameInvalid);
}
stack.ThrowIfNotLoggedIn();
ThrowIfUidEmpty();
Expand Down
3 changes: 2 additions & 1 deletion Contentstack.Management.Core/Models/ReleaseItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using Contentstack.Management.Core.Queryable;
using Contentstack.Management.Core.Services.Models;
using Contentstack.Management.Core.Utils;

namespace Contentstack.Management.Core.Models
{
Expand Down Expand Up @@ -258,7 +259,7 @@ internal void ThrowIfUidEmpty()
{
if (string.IsNullOrEmpty(this.releaseUID))
{
throw new InvalidOperationException("Uid can not be empty.");
throw new InvalidOperationException(CSConstants.ReleaseItemUIDRequired);
}
}
#endregion
Expand Down
Loading
Loading