/// <summary> /// Get instance of content creator /// </summary> /// <param name="context"> /// Commerce context /// </param> /// <returns> /// Instnace of content creator /// </returns> public static INotificationContentCreator NotificationContentCreator(CommerceContext context) { if (context == null) { throw new ArgumentNullException("context", "Parameter config cannot be null."); } if (notificationContentCreator == null) { if (context.Config.UseMockPartnerDependencies) { //TODO: create mock notificationContentCreator = LateBinding.BuildObjectFromLateBoundAssembly <INotificationContentCreator>("MockNotificationContentCreator", LateBoundMocksAssemblyTypes); } else { notificationContentCreator = new NotificationContentCreator() { TemplateServiceBaseAddress = CloudConfigurationManager.GetSetting("Lomo.Commerce.TemplateServiceUri"), Logger = context.Log }; } } return(notificationContentCreator); }
/// <summary> /// Gets the object to use to process Visa rebater transactions. /// </summary> /// <returns> /// The ISettlementProcessor object to use. /// </returns> public static ISettlementProcessor VisaRebateProcessor() { ISettlementProcessor result = new VisaRebaterProcessor(); if (CommerceWorkerConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <ISettlementProcessor>("MockVisaRebaterProcessor", LateBoundMocksAssemblyTypes); } return(result); }
/// <summary> /// Creates an instance of the rebate confirmation file FTP client. /// </summary> /// <param name="log"> /// The CommerceLog object through which log entries can be made. /// </param> /// <returns> /// An instance of the rebate confirmation file FTP client. /// </returns> public static IFtpClient RebateConfirmationFtpClient(CommerceLog log) { IFtpClient result = new RebateConfirmationFtpClient(log); if (CommerceWorkerConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <IFtpClient>("MockMasterCardFtpClient", LateBoundMocksAssemblyTypes); } return(result); }
/// <summary> /// Creates instance of FDC Pts FTP Client /// </summary> /// <param name="log"> /// Commerce Logger /// </param> /// <returns> /// Instance of ftp client /// </returns> public static IFtpClient FirstDataPtsFtpClient(CommerceLog log) { IFtpClient result = new FirstDataPtsFtpClient(log); if (CommerceWorkerConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <IFtpClient>("MockFirstDataFtpClient", LateBoundMocksAssemblyTypes); } return(result); }
/// <summary> /// Gets the object to use to perform user services client operations. /// </summary> /// <param name="onRewardsPtsBuild"> /// Action to be performed once we have pts file contents built in memory /// </param> public static RewardsPtsProcessor RewardsPtsProcessor(Func <string, Task> onRewardsPtsBuild) { RewardsPtsProcessor result = new RewardsPtsProcessor() { OnRewardsPtsBuild = onRewardsPtsBuild, }; if (CommerceWorkerConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <RewardsPtsProcessor>("MockRewardsPtsProcessor", LateBoundMocksAssemblyTypes); } return(result); }
/// <summary> /// Gets the Rewards Pts Blob Client /// </summary> /// <param name="connectionString"> /// Storage connection string /// </param> /// <param name="log"> /// Commerce Logger /// </param> /// <returns> /// Instace of Rewards Pts Blob Client /// </returns> public static RewardsPtsBlobClient RewardsPtsBlobClient(string connectionString, CommerceLog log) { RewardsPtsBlobClient result = null; if (CommerceWorkerConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <RewardsPtsBlobClient>("MockRewardsPtsBlobClient", LateBoundMocksAssemblyTypes); } else { result = new RewardsPtsBlobClient(connectionString, log); } return(result); }
/// <summary> /// Get the object to request simple web tokens. /// </summary> /// <returns> /// The ISimpleWebTokenRequestor instance to use. /// </returns> public static ISimpleWebTokenRequestor SimpleWebTokenRequestor() { if (simpleWebTokenRequestor == null) { simpleWebTokenRequestor = new SimpleWebTokenRequestor(); if (CommerceWorkerConfig.Instance.UseMockPartnerDependencies == true) { simpleWebTokenRequestor = LateBinding.BuildObjectFromLateBoundAssembly <ISimpleWebTokenRequestor>("MockSimpleWebTokenRequestor", LateBoundMocksAssemblyTypes); } } return(simpleWebTokenRequestor); }
/// <summary> /// Gets the object to use to process MasterCard rebate files. /// </summary> /// <param name="uploadRebateFile"> /// The delegate to call to upload the file to its various destinations. /// </param> /// <returns> /// The ISettlementFileProcessor object to use. /// </returns> public static ISettlementFileProcessor MasterCardRebateProcessor(Func <string, Task> uploadRebateFile) { ISettlementFileProcessor result = new MasterCardRebateProcessor() { UploadRebateFile = uploadRebateFile }; if (CommerceWorkerConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <ISettlementFileProcessor>("MockMasterCardRebateProcessor", LateBoundMocksAssemblyTypes); } return(result); }
/// <summary> /// Creates an instance of a MasterCard Rebate blob client. /// </summary> /// <param name="log"> /// The CommerceLog object within which to place log entries. /// </param> /// <returns> /// And instace of the MasterCard Rebate blob client. /// </returns> public static MasterCardRebateBlobClient MasterCardRebateBlobClient(CommerceLog log) { MasterCardRebateBlobClient result = null; if (CommerceWorkerConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <MasterCardRebateBlobClient>("MockMasterCardRebateBlobClient", LateBoundMocksAssemblyTypes); } else { result = new MasterCardRebateBlobClient(log); } return(result); }
/// <summary> /// Gets the object to use to perform user services client operations. /// </summary> /// <param name="acknowledgmentFileName"> /// Name of the ack file /// </param> /// <param name="acknowledgmentFileStream"> /// Ack file data stream /// </param> public static ISettlementFileProcessor FirstDataAcknowledgmentProcessor(string acknowledgmentFileName, Stream acknowledgmentFileStream) { ISettlementFileProcessor result = new FirstDataAcknowledgmentProcessor() { AcknowledgmentFileName = acknowledgmentFileName, AcknowledgmentFileStream = acknowledgmentFileStream }; if (CommerceWorkerConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <ISettlementFileProcessor>("MockFirstDataAcknowledgmentProcessor", LateBoundMocksAssemblyTypes); } return(result); }
/// <summary> /// Gets the object to use to process MasterCard clearing files. /// </summary> /// <param name="stream"> /// The stream containing clearing file contents. /// </param> /// <param name="fileName"> /// The name of the clearing file. /// </param> /// <returns> /// The ISettlementFileProcessor object to use. /// </returns> public static ISettlementFileProcessor MasterCardClearingProcessor(Stream stream, string fileName) { ISettlementFileProcessor result = new MasterCardClearingProcessor() { Stream = stream, FileName = fileName }; if (CommerceWorkerConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <ISettlementFileProcessor>("MockMasterCardClearingProcessor", LateBoundMocksAssemblyTypes); } return(result); }
/// <summary> /// Offer Registration Record Blob Client Factory Method /// </summary> /// <param name="connectionString"> /// Storage account connection string /// </param> /// <param name="log"> /// Commerce Logger /// </param> /// <returns> /// Instance of OfferRegistrationRecordBlobClient /// </returns> public static OfferRegistrationRecordBlobClient OfferRegistrationRecordBlobClient(string connectionString, CommerceLog log) { OfferRegistrationRecordBlobClient result = null; if (CommerceWorkerConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <OfferRegistrationRecordBlobClient>("MockAmexOfferRegistrationRecordBlobClient", LateBoundMocksAssemblyTypes); } else { result = new OfferRegistrationRecordBlobClient(connectionString, log); } return(result); }
/// <summary> /// Gets the FDC Ack Blob Client /// </summary> /// <param name="connectionString"> /// Storage connection string /// </param> /// <param name="log"> /// Commerce Logger /// </param> /// <returns> /// Instace of FDC Ack Blob Client /// </returns> public static FirstDataAcknowledgmentBlobClient FirstDataAcknowledgmentBlobClient(string connectionString, CommerceLog log) { FirstDataAcknowledgmentBlobClient result = null; if (CommerceWorkerConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <FirstDataAcknowledgmentBlobClient>("MockFirstDataAcknowledgmentBlobClient", LateBoundMocksAssemblyTypes); } else { result = new FirstDataAcknowledgmentBlobClient(connectionString, log); } return(result); }
/// <summary> /// Gets the object to use to perform operations on deals. /// </summary> /// <param name="context"> /// The context in which operations will be performed. /// </param> /// <returns> /// The IDealOperations instance to use. /// </returns> public static IDealOperations DealOperations(CommerceContext context) { ValidateContext(context); IDealOperations result = new DealOperations(); if (context.Config.DataStoreMockLevel != CommerceDataStoreMockLevel.None) { result = LateBinding.BuildObjectFromLateBoundAssembly <IDealOperations>("MockDealOperations", LateBoundMocksAssemblyTypes); } result.Context = context; return(result); }
/// <summary> /// Gets the object to use to perform user services client operations. /// </summary> /// <param name="commerceConfig"> /// The CommerceConfig object to use to determine if mock partner dependencies are being used. /// </param> /// <param name="userServicesUri"> /// The Uri at which the User Services can be found. /// </param> /// <returns> /// The IUserServicesClient instance to use. /// </returns> /// <exception cref="ArgumentNullException"> /// Parameter commerceConfig cannot be null. /// </exception> public static IUserServicesClient UserServicesClient(Uri userServicesUri, CommerceConfig commerceConfig) { if (commerceConfig == null) { throw new ArgumentNullException("commerceConfig", "Parameter commerceConfig cannot be null."); } IUserServicesClient result = new UserServiceClient(userServicesUri); if (commerceConfig.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <IUserServicesClient>("MockUserServicesClient", LateBoundMocksAssemblyTypes); } return(result); }
/// <summary> /// Initializes a new instance of the SimpleWebTokenAuthAttribute class. /// </summary> public SimpleWebTokenAuthAttribute() { // If configuration app settings do not include an assembly from which to create a mock SimpleWebTokenAuthAttribute // instance, use this object. Otherwise, create an instance of the mock class. string mockApiAuthAssembly = ConfigurationManager.AppSettings["mockApiAuth"]; if (string.IsNullOrWhiteSpace(mockApiAuthAssembly)) { this.simpleWebTokenAuthAttributeInstance = this; } else { this.simpleWebTokenAuthAttributeInstance = LateBinding.BuildObjectFromLateBoundAssembly <IApiAuthAttribute>( "SimpleWebTokenAuthAttribute", LateBinding.GetLateBoundAssemblyTypes(mockApiAuthAssembly)); } }
/// <summary> /// Amex Transaction Log File Blob Client Factory Method /// </summary> /// <param name="connectionString"> /// Storage account connection string /// </param> /// <param name="log"> /// Commerce Logger /// </param> /// <returns> /// Instance of AmexTransactionLogFileBlobClient /// </returns> public static AmexTransactionLogFileBlobClient TransactionLogBlobClient(string connectionString, CommerceLog log) { AmexTransactionLogFileBlobClient result = null; if (CommerceWorkerConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <AmexTransactionLogFileBlobClient>( "MockAmexTransactionLogFileBlobClient", LateBoundMocksAssemblyTypes); } else { result = new AmexTransactionLogFileBlobClient(connectionString, log); } return(result); }
public static ISftpClient SftpClient(string username, string password, string uri, CommerceConfig config) { if (config == null) { throw new ArgumentNullException("config", "Parameter config cannot be null."); } if (sftpClient == null) { sftpClient = new DefaultSftpClient(username, password, uri); if (config.UseMockPartnerDependencies) { sftpClient = LateBinding.BuildObjectFromLateBoundAssembly <ISftpClient>("MockSftpClient", LateBoundMocksAssemblyTypes); } } return(sftpClient); }
/// <summary> /// Gets the object to use to perform user services client operations. /// </summary> /// <param name="onPtsBuild"> /// Action to be performed once we have pts file contents built in memory /// </param> public static ISettlementFileProcessor FirstDataPtsProcessor(Func <string, Task> onPtsBuild) { ISettlementFileProcessor result = new FirstDataPtsProcessor() { OnPtsBuild = onPtsBuild, TransactionPublisher = new FirstDataTransactionPublisher { Queue = new AzureQueueClient(UserServicesStorageConnectionString, TransactionQueueName) } }; if (CommerceWorkerConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <ISettlementFileProcessor>("MockFirstDataPtsProcessor", LateBoundMocksAssemblyTypes); } return(result); }
/// <summary> /// Get the object to add analytics data /// </summary> /// <param name="commerceConfig"> /// The CommerceConfig object to use to determine if mock partner dependencies are being used. /// </param> /// <returns> /// The IAnalytics client instance to use. /// </returns> /// <exception cref="ArgumentNullException"> /// Parameter commerceConfig cannot be null. /// </exception> public static IAnalyticsClient AnalyticsClient(CommerceConfig commerceConfig) { if (commerceConfig == null) { throw new ArgumentNullException("commerceConfig", "Parameter commerceConfig cannot be null."); } if (analyticsClient == null) { analyticsClient = new AnalyticsClient(); if (commerceConfig.UseMockPartnerDependencies == true) { analyticsClient = LateBinding.BuildObjectFromLateBoundAssembly <IAnalyticsClient>("MockAnalyticsClient", LateBoundMocksAssemblyTypes); } } return(analyticsClient); }
/// <summary> /// Gets the object to use to perform operations on users. /// </summary> /// <param name="commerceConfig"> /// The CommerceConfig object to use to determine if mock partner dependencies are being used. /// </param> public static IUsersDal UsersDal(CommerceConfig commerceConfig) { if (commerceConfig == null) { throw new ArgumentNullException("commerceConfig", "Parameter commerceConfig cannot be null."); } if (usersDal == null) { usersDal = new UsersDal(); if (commerceConfig.UseMockPartnerDependencies == true) { usersDal = LateBinding.BuildObjectFromLateBoundAssembly <IUsersDal>("MockUsersDal", LateBoundMocksAssemblyTypes); } } return(usersDal); }
/// <summary> /// Gets the object for azure table to add certain warnings /// </summary> /// <param name="config"> /// The configuration to use to get settings. /// </param> /// <returns> /// The IAzureTable instance to use. /// </returns> /// <exception cref="ArgumentNullException"> /// Parameter config cannot be null. /// </exception> public static IAzureTable AzureTable(CommerceConfig config) { if (config == null) { throw new ArgumentNullException("config", "Parameter config cannot be null."); } if (azureTable == null) { azureTable = new AzureTable(); if (config.UseMockPartnerDependencies == true) { azureTable = LateBinding.BuildObjectFromLateBoundAssembly <IAzureTable>("MockAzureTable", LateBoundMocksAssemblyTypes); } } return(azureTable); }
/// <summary> /// Gets the object to use to perform operations on users. /// </summary> /// <param name="performanceInformation"> /// The object through which performance information can be added and obtained. /// </param> /// <param name="firstDataInvokerOverride"> /// The specific FirstDataInvoker object to return, if not null. /// </param> public static IFirstDataInvoker BuildFirstDataInvoker(PerformanceInformation performanceInformation, IFirstDataInvoker firstDataInvokerOverride) { IFirstDataInvoker result = new FirstDataInvoker(); result.PerformanceInformation = performanceInformation; if (CommerceServiceConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <IFirstDataInvoker>("MockFirstDataInvoker", LateBoundMocksAssemblyTypes); } // If the override object is not null, return it instead. if (firstDataInvokerOverride != null) { result = firstDataInvokerOverride; } return(result); }
/// <summary> /// Gets the object to use to perform operations on users. /// </summary> /// <param name="performanceInformation"> /// The object through which performance information can be added and obtained. /// </param> /// <param name="masterCardInvokerOverride"> /// The specific MasterCardInvoker object to return, if not null. /// </param> public static IMasterCardInvoker BuildMasterCardInvoker(PerformanceInformation performanceInformation, IMasterCardInvoker masterCardInvokerOverride) { IMasterCardInvoker result = new MasterCardInvoker(); result.PerformanceInformation = performanceInformation; if (UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <IMasterCardInvoker>("MockMasterCardInvoker", LateBoundMocksAssemblyTypes); } // If the override object is not null, return it instead. if (masterCardInvokerOverride != null) { result = masterCardInvokerOverride; } return(result); }
/// <summary> /// Gets the object to use to perform operations on users. /// </summary> /// <param name="performanceInformation"> /// The object through which performance information can be added and obtained. /// </param> /// <param name="visaInvokerOverride"> /// The specific VisaInvoker object to return, if not null. /// </param> /// <param name="config"> /// The config object. /// </param> public static IVisaInvoker BuildVisaInvoker(PerformanceInformation performanceInformation, IVisaInvoker visaInvokerOverride, CommerceConfig config) { IVisaInvoker result = new VisaInvoker(); result.PerformanceInformation = performanceInformation; if (config.UseMockPartnerDependencies) { result = LateBinding.BuildObjectFromLateBoundAssembly <IVisaInvoker>("MockVisaInvoker", LateBoundMocksAssemblyTypes); } // If the override object is not null, return it instead. if (visaInvokerOverride != null) { result = visaInvokerOverride; } return(result); }
/// <summary> /// Initializes a new instance of the ApiAuthAttribute class. /// </summary> /// <param name="roles"> /// The roles for which the user must be authorized. /// </param> /// <param name="flags"> /// The flags. /// </param> public ApiAuthAttribute(string[] roles = null, string[] flags = null) { this.Roles = roles; this.Flags = flags == null ? new HashSet <string>() : new HashSet <string>(flags); // If configuration app settings do not include an assembly from which to create a mock ApiAuthAttribute instance, // use this object. Otherwise, create an instance of the mock class. string mockApiAuthAssembly = ConfigurationManager.AppSettings["mockApiAuth"]; if (string.IsNullOrWhiteSpace(mockApiAuthAssembly)) { this.apiAuthAttributeInstance = this; } else { this.apiAuthAttributeInstance = LateBinding.BuildObjectFromLateBoundAssembly <IApiAuthAttribute>( "ApiAuthAttribute", LateBinding.GetLateBoundAssemblyTypes(mockApiAuthAssembly)); } }
/// <summary> /// Gets the Mock Scheduler /// </summary> /// <param name="queueName"> /// Queue Name /// </param> /// <param name="tableName"> /// Table Name /// </param> /// <returns> /// The IScheduler instance to use. /// </returns> /// <exception cref="ArgumentNullException"> /// Parameter config cannot be null. /// </exception> public static IScheduler Scheduler(string queueName, string tableName, CommerceConfig config) { if (config == null) { throw new ArgumentNullException("config", "Parameter config cannot be null."); } if (scheduler == null) { scheduler = SchedulerFactory.GetScheduler(CloudConfigurationManager.GetSetting("Lomo.Commerce.Scheduler.ConnectionString"), queueName, tableName); if (config.UseMockPartnerDependencies == true) { scheduler = LateBinding.BuildObjectFromLateBoundAssembly <IScheduler>("MockScheduler", LateBoundMocksAssemblyTypes); } } return(scheduler); }
/// <summary> /// Gets the object to use to perform operations on users. /// </summary> /// <param name="performanceInformation"> /// The object through which performance information can be added and obtained. /// </param> /// <param name="amexInvokerOverride"> /// The specific AmexInvoker object to return, if not null. /// </param> public static IAmexInvoker BuildAmexInvoker(PerformanceInformation performanceInformation, CommerceLog commerceLog, IAmexInvoker amexInvokerOverride) { IAmexInvoker result = new AmexInvoker(); result.PerformanceInformation = performanceInformation; result.CommerceLog = commerceLog; if (CommerceServiceConfig.Instance.UseMockPartnerDependencies == true) { result = LateBinding.BuildObjectFromLateBoundAssembly <IAmexInvoker>("MockAmexInvoker", LateBoundMocksAssemblyTypes); } // If the override object is not null, return it instead. if (amexInvokerOverride != null) { result = amexInvokerOverride; } return(result); }