示例#1
0
        /// <summary>
        ///     Factory method that creates and returns the <see cref="LeanKitIntegration" /> implementation using the
        ///     LeanKitClient created with the default <see cref="IRestCommandProcessor" />.
        /// </summary>
        /// <remarks>
        ///     The default implementation of the <see cref="IRestCommandProcessor" /> uses RestSharp.
        /// </remarks>
        /// <param name="boardId">The Identity of the Board that will be watched and modified.</param>
        /// <param name="accountAuth">The account authentication information used to connect to the LeanKit API.</param>
        /// <returns>The <see cref="ILeanKitIntegration" /> used to monitor and modify the specified board. </returns>
        public ILeanKitIntegration Create(long boardId, LeanKitAccountAuth accountAuth)
        {
            var clientFactory = new LeanKitClientFactory();
            var apiClient     = clientFactory.Create(accountAuth);

            return(new LeanKitIntegration(boardId, apiClient));
        }
		public bool Initialize(string accountName, string emailAddress, string password)
		{
			try
			{
				var lkFactory = new LeanKitClientFactory();
				var lkAuth = new LeanKitBasicAuth
				{
					Hostname = accountName,
					Username = emailAddress,
					Password = password
				};
				_api = lkFactory.Create(lkAuth);
				// Test authentication
				var boards = _api.GetBoards();
				if (boards == null) return false;
				_cache.Set("boards", boards.ToArray(), DateTimeOffset.Now.AddMinutes(5));
				return true;
			}
			catch (Exception)
			{
				_api = null;
				return false;
			}
		}
		/// <summary>
		///     Factory method that creates and returns the <see cref="LeanKitIntegration" /> implementation using the
		///     LeanKitClient created with the default <see cref="IRestCommandProcessor" />.
		/// </summary>
		/// <remarks>
		///     The default implementation of the <see cref="IRestCommandProcessor" /> uses RestSharp.
		/// </remarks>
		/// <param name="boardId">The Identity of the Board that will be watched and modified.</param>
		/// <param name="accountAuth">The account authentication information used to connect to the LeanKit API.</param>
		/// <returns>The <see cref="ILeanKitIntegration" /> used to monitor and modify the specified board. </returns>
		public ILeanKitIntegration Create(long boardId, LeanKitAccountAuth accountAuth)
		{
			var clientFactory = new LeanKitClientFactory();
			var apiClient = clientFactory.Create(accountAuth);
			return new LeanKitIntegration(boardId, apiClient);
		}