public Builder Environment(Dc.DataCenter.Environment environment) { Utility.AssertNotNull(environment, errorMessage, Constants.ENVIRONMENT_ERROR_MESSAGE); this.environment = environment; return(this); }
/// <summary> /// This method to initialize the SDK. /// </summary> /// <param name="user">A User class instance represents the CRM user.</param> /// <param name="environment">A Environment class instance containing the CRM API base URL and Accounts URL.</param> /// <param name="token">A Token class instance containing the OAuth client application information.</param> /// <param name="store">A TokenStore class instance containing the token store information.</param> /// <param name="sdkConfig">A SDKConfig class instance containing the configuration.</param> /// <param name="sdkConfig">A SDKConfig class instance containing the configuration.</param> /// <param name="logger">A Logger class instance containing the log file path and Logger type.</param> /// <param name="proxy">An RequestProxy class instance containing the proxy properties of the user.</param> private static void Initialize(UserSignature user, Dc.DataCenter.Environment environment, Token token, TokenStore store, SDKConfig sdkConfig, string resourcePath, Logger.Logger logger, RequestProxy proxy) { try { SDKLogger.Initialize(logger); try { string result = ""; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(Constants.JSON_DETAILS_FILE_PATH)) { using (StreamReader reader = new StreamReader(stream)) { result = reader.ReadToEnd(); } } jsonDetails = JObject.Parse(result); } catch (System.Exception e) { throw new SDKException(Constants.JSON_DETAILS_ERROR, e); } initializer = new Initializer(); initializer.user = user; initializer.environment = environment; initializer.token = token; initializer.store = store; initializer.sdkConfig = sdkConfig; initializer.resourcePath = resourcePath; initializer.requestProxy = proxy; SDKLogger.LogInfo(Constants.INITIALIZATION_SUCCESSFUL + initializer.ToString()); } catch (SDKException e) { throw e; } catch (Exception e) { throw new SDKException(Constants.INITIALIZATION_EXCEPTION, e); } }
public Builder() { if (Initializer.initializer != null) { user = Initializer.initializer.User; environment = Initializer.initializer.Environment; token = Initializer.initializer.Token; sdkConfig = Initializer.initializer.SDKConfig; } }
/// <summary> /// The method to switch the different user in SDK environment. /// </summary> /// <param name="user">A User class instance represents the CRM user.</param> /// <param name="environment">A Environment class instance containing the CRM API base URL and Accounts URL.</param> /// <param name="token">A Token class instance containing the OAuth client application information.</param> /// <param name="sdkConfig">A SDKConfig class instance containing the configuration.</param> /// <param name="proxy">An RequestProxy class instance containing the proxy properties of the user. public static void SwitchUser(UserSignature user, Dc.DataCenter.Environment environment, Token token, SDKConfig sdkConfig, RequestProxy proxy) { if (user == null) { throw new SDKException(Constants.SWITCH_USER_ERROR, Constants.USERSIGNATURE_ERROR_MESSAGE); } if (environment == null) { throw new SDKException(Constants.SWITCH_USER_ERROR, Constants.ENVIRONMENT_ERROR_MESSAGE); } if (token == null) { throw new SDKException(Constants.SWITCH_USER_ERROR, Constants.TOKEN_ERROR_MESSAGE); } if (sdkConfig == null) { throw new SDKException(Constants.SWITCH_USER_ERROR, Constants.SDK_CONFIG_ERROR_MESSAGE); } Initializer initializer = new Initializer(); initializer.user = user; initializer.environment = environment; initializer.token = token; initializer.store = Initializer.initializer.store; initializer.sdkConfig = sdkConfig; initializer.resourcePath = Initializer.initializer.resourcePath; initializer.requestProxy = proxy; LOCAL.Value = initializer; SDKLogger.LogInfo(Constants.INITIALIZATION_SWITCHED + initializer.ToString()); }
/// <summary> /// The method to switch the different user in SDK environment. /// </summary> /// <param name="user">A User class instance represents the CRM user.</param> /// <param name="environment">A Environment class instance containing the CRM API base URL and Accounts URL.</param> /// <param name="token">A Token class instance containing the OAuth client application information.</param> /// <param name="sdkConfig">A SDKConfig class instance containing the configuration.</param> /// <param name="proxy">An RequestProxy class instance containing the proxy properties of the user. private static void SwitchUser(UserSignature user, Dc.DataCenter.Environment environment, Token token, SDKConfig sdkConfig, RequestProxy proxy) { Initializer initializer = new Initializer(); initializer.user = user; initializer.environment = environment; initializer.token = token; initializer.store = Initializer.initializer.store; initializer.sdkConfig = sdkConfig; initializer.requestProxy = proxy; initializer.resourcePath = Initializer.initializer.resourcePath; LOCAL.Value = initializer; SDKLogger.LogInfo(Constants.INITIALIZATION_SWITCHED + initializer.ToString()); }
/// <summary> /// This method to initialize the SDK. /// </summary> /// <param name="user">A User class instance represents the CRM user.</param> /// <param name="environment">A Environment class instance containing the CRM API base URL and Accounts URL.</param> /// <param name="token">A Token class instance containing the OAuth client application information.</param> /// <param name="store">A TokenStore class instance containing the token store information.</param> /// <param name="sdkConfig">A SDKConfig class instance containing the configuration.</param> /// <param name="resourcePath">A String containing the absolute directory path to store user specific JSON files containing module fields information.</param> /// <param name="logger">A Logger class instance containing the log file path and Logger type.</param> public static void Initialize(UserSignature user, Dc.DataCenter.Environment environment, Token token, TokenStore store, SDKConfig sdkConfig, string resourcePath, Logger.Logger logger) { Initializer.Initialize(user, environment, token, store, sdkConfig, resourcePath, logger, null); }
/// <summary> /// This method to initialize the SDK. /// </summary> /// <param name="user">A User class instance represents the CRM user.</param> /// <param name="environment">A Environment class instance containing the CRM API base URL and Accounts URL.</param> /// <param name="token">A Token class instance containing the OAuth client application information.</param> /// <param name="store">A TokenStore class instance containing the token store information.</param> /// <param name="sdkConfig">A SDKConfig class instance containing the configuration.</param> /// <param name="resourcePath">A String containing the absolute directory path to store user specific JSON files containing module fields information.</param> /// <param name="proxy">An RequestProxy class instance containing the proxy properties of the user.</param> public static void Initialize(UserSignature user, Dc.DataCenter.Environment environment, Token token, TokenStore store, SDKConfig sdkConfig, string resourcePath, RequestProxy proxy) { Initializer.Initialize(user, environment, token, store, sdkConfig, resourcePath, null, proxy); }
/// <summary> /// The method to switch the different user in SDK environment. /// </summary> /// <param name="user">A User class instance represents the CRM user.</param> /// <param name="environment">A Environment class instance containing the CRM API base URL and Accounts URL.</param> /// <param name="token">A Token class instance containing the OAuth client application information.</param> /// <param name="sdkConfig">A SDKConfig class instance containing the configuration.</param> public static void SwitchUser(UserSignature user, Dc.DataCenter.Environment environment, Token token, SDKConfig sdkConfig) { Initializer.SwitchUser(user, environment, token, sdkConfig, null); }
/// <summary> /// This method to initialize the SDK. /// </summary> /// <param name="user">A User class instance represents the CRM user.</param> /// <param name="environment">A Environment class instance containing the CRM API base URL and Accounts URL.</param> /// <param name="token">A Token class instance containing the OAuth client application information.</param> /// <param name="store">A TokenStore class instance containing the token store information.</param> /// <param name="sdkConfig">A SDKConfig class instance containing the configuration.</param> /// <param name="sdkConfig">A SDKConfig class instance containing the configuration.</param> /// <param name="logger">A Logger class instance containing the log file path and Logger type.</param> /// <param name="proxy">An RequestProxy class instance containing the proxy properties of the user.</param> public static void Initialize(UserSignature user, Dc.DataCenter.Environment environment, Token token, TokenStore store, SDKConfig sdkConfig, string resourcePath, Logger.Logger logger, RequestProxy proxy) { try { if (user == null) { throw new SDKException(Constants.INITIALIZATION_ERROR, Constants.USERSIGNATURE_ERROR_MESSAGE); } if (environment == null) { throw new SDKException(Constants.INITIALIZATION_ERROR, Constants.ENVIRONMENT_ERROR_MESSAGE); } if (token == null) { throw new SDKException(Constants.INITIALIZATION_ERROR, Constants.TOKEN_ERROR_MESSAGE); } if (store == null) { throw new SDKException(Constants.INITIALIZATION_ERROR, Constants.STORE_ERROR_MESSAGE); } if (sdkConfig == null) { throw new SDKException(Constants.INITIALIZATION_ERROR, Constants.SDK_CONFIG_ERROR_MESSAGE); } if (string.IsNullOrEmpty(resourcePath) || string.IsNullOrWhiteSpace(resourcePath)) { throw new SDKException(Constants.INITIALIZATION_ERROR, Constants.RESOURCE_PATH_ERROR_MESSAGE); } if (!Directory.Exists(resourcePath)) { throw new SDKException(Constants.INITIALIZATION_ERROR, Constants.RESOURCE_PATH_INVALID_ERROR_MESSAGE); } if (logger == null) { logger = Logger.Logger.GetInstance(Logger.Logger.Levels.INFO, Path.GetDirectoryName(Assembly.GetCallingAssembly().Location) + Path.DirectorySeparatorChar + Constants.LOG_FILE_NAME); } SDKLogger.Initialize(logger); try { string result = ""; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(Constants.JSON_DETAILS_FILE_PATH)) { using (StreamReader reader = new StreamReader(stream)) { result = reader.ReadToEnd(); } } jsonDetails = JObject.Parse(result); } catch (System.Exception e) { throw new SDKException(Constants.JSON_DETAILS_ERROR, e); } initializer = new Initializer(); initializer.user = user; initializer.environment = environment; initializer.token = token; initializer.store = store; initializer.sdkConfig = sdkConfig; initializer.resourcePath = resourcePath; initializer.requestProxy = proxy; SDKLogger.LogInfo(Constants.INITIALIZATION_SUCCESSFUL + initializer.ToString()); } catch (SDKException e) { throw e; } catch (Exception e) { throw new SDKException(Constants.INITIALIZATION_EXCEPTION, e); } }