Example #1
0
        public void Should_Throw_EnvironmentVariableNotSetException_When_Trying_To_Get_A_Mandatory_Env_Variable_That_Is_Not_Set()
        {
            var exception = Assert.Throws <EnvironmentVariableNotSetException>(
                () => environmentConfigProvider.Get("NON_EXISTING_VAR_KEY", true));

            Assert.AreEqual("Env variable NON_EXISTING_VAR_KEY is not set", exception.Message);
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Client"/> class.
        /// <para>  In order for this an instance to be successfully created, the following env variables must be set:</para>
        /// <para>  SFMC_AUTH_BASE_URL - Your tenant-specific Authentication Base URI.</para>
        /// <para>  SFMC_CLIENT_ID - Client ID issued when you create the API integration in Installed Packages.</para>
        /// <para>  SFMC_CLIENT_SECRET - Client secret issued when you create the API integration in Installed Packages.</para>
        /// <para>  SFMC_ACCOUNT_ID - Account identifier, or MID, of the target business unit. Use to switch between business units.</para>
        /// <para>  Optional - SFMC_SCOPE - Space-separated list of data-access permissions for your application.</para>
        /// </summary>
        public Client()
        {
            EnvironmentConfigProvider configProvider = new EnvironmentConfigProvider();

            this.authBaseUrl  = configProvider.Get(EnvVariableName.AUTH_BASE_URL);
            this.clientId     = configProvider.Get(EnvVariableName.CLIENT_ID);
            this.clientSecret = configProvider.Get(EnvVariableName.CLIENT_SECRET);
            this.accountId    = configProvider.Get(EnvVariableName.ACCOUNT_ID);
            this.scope        = configProvider.Get(EnvVariableName.SCOPE, false);
        }
Example #3
0
        static ClientFactory()
        {
            var configProvider = new EnvironmentConfigProvider();

            authBasePath = configProvider.Get(EnvVariableName.AUTH_BASE_URL);
            clientId     = configProvider.Get(EnvVariableName.CLIENT_ID);
            clientSecret = configProvider.Get(EnvVariableName.CLIENT_SECRET);
            accountId    = configProvider.Get(EnvVariableName.ACCOUNT_ID);
            scope        = configProvider.Get(EnvVariableName.SCOPE, false);
        }
        private SmsDefinition CreateSmsDefinitionObject()
        {
            var smsDefinitionKey  = $"{Guid.NewGuid()}";
            var smsDefinitionName = $"{Guid.NewGuid()}";

            var shortCode   = configProvider.Get(EnvVariableName.SHORT_CODE);
            var keyword     = configProvider.Get(EnvVariableName.KEYWORD);
            var countryCode = "US";

            var subscriptions = new SmsDefinitionSubscriptions(shortCode, countryCode, keyword);
            var content       = new SmsDefinitionContent("Content message");

            var smsDefinition = new SmsDefinition(smsDefinitionKey, smsDefinitionName, content, subscriptions: subscriptions);

            return(smsDefinition);
        }