/// <summary> /// Initializes a new instance of the <see cref="WebexClientWrapper"/> class. /// Creates a Webex Client Wrapper. See <see cref="WebexAdapterOptions"/> for a full definition of the allowed parameters. /// </summary> /// <param name="options">An object containing API credentials, a webhook verification token and other options.</param> public WebexClientWrapper(WebexAdapterOptions options) { Options = options ?? throw new ArgumentNullException(nameof(options)); if (string.IsNullOrWhiteSpace(Options.WebexAccessToken)) { throw new ArgumentException(nameof(options.WebexAccessToken)); } if (Options.WebexPublicAddress == null) { throw new ArgumentException(nameof(options.WebexPublicAddress)); } _api = TeamsAPI.CreateVersion1Client(Options.WebexAccessToken); }
/// <summary> /// Initializes a new instance of the <see cref="WebexClientWrapper"/> class. /// Creates a Webex Client Wrapper. See <see cref="WebexAdapterOptions"/> for a full definition of the allowed parameters. /// </summary> /// <param name="config">An object containing API credentials, a webhook verification token and other options.</param> public WebexClientWrapper(WebexAdapterOptions config) { _config = config ?? throw new ArgumentNullException(nameof(config)); if (string.IsNullOrWhiteSpace(_config.AccessToken)) { throw new ArgumentException(nameof(config.AccessToken)); } if (_config.PublicAddress == null) { throw new ArgumentException(nameof(config.PublicAddress)); } _api = TeamsAPI.CreateVersion1Client(_config.AccessToken); }
/// <summary> /// Initializes a new instance of the <see cref="WebexAdapter"/> class. /// Creates a Webex adapter. /// </summary> /// <param name="webexClient">A Webex API interface.</param> /// <param name="options">An instance of <see cref="WebexAdapterOptions"/>.</param> /// <param name="logger">The ILogger implementation this adapter should use.</param> public WebexAdapter(WebexClientWrapper webexClient, WebexAdapterOptions options, ILogger logger = null) { _webexClient = webexClient ?? throw new ArgumentNullException(nameof(webexClient)); _options = options ?? new WebexAdapterOptions(); _logger = logger ?? NullLogger.Instance; }
/// <summary> /// Initializes a new instance of the <see cref="WebexAdapter"/> class using configuration settings. /// </summary> /// <param name="configuration">An <see cref="IConfiguration"/> instance.</param> /// <remarks> /// The configuration keys are: /// WebexAccessToken: An access token for the bot. /// WebexPublicAddress: The root URL of the bot application. /// WebexSecret: The secret used to validate incoming webhooks. /// WebexWebhookName: A name for the webhook subscription. /// </remarks> /// <param name="options">An instance of <see cref="WebexAdapterOptions"/>.</param> /// <param name="logger">The ILogger implementation this adapter should use.</param> public WebexAdapter(IConfiguration configuration, WebexAdapterOptions options = null, ILogger logger = null) : this(new WebexClientWrapper(new WebexClientWrapperOptions(configuration[WebexAccessTokenKey], new Uri(configuration[WebexPublicAddressKey]), configuration[WebexSecretKey], configuration[WebexWebhookNameKey])), options, logger) { }