コード例 #1
0
        /// <summary>
        /// Supply the path to your zuliprc file containing email, key and site URL.
        /// </summary>
        /// <param name="ZulipRCPath"></param>
        public ZulipClient(string ZulipRCPath)
        {
            var AuthHelper = new ZulipRCAuth(ZulipRCPath);

            this.Server         = AuthHelper.Server;
            this.Authentication = AuthHelper.ZulipAuth;
        }
コード例 #2
0
        private void LoadZulipRCasString(string ZulipRCPath)
        {
            string line = "";

            if (File.Exists(ZulipRCPath))
            {
                using (var zuliprc = new StreamReader(ZulipRCPath)) {
                    if (ZulipRCIsValid(ZulipRCPath))
                    {
                        while ((line = zuliprc.ReadLine()) != null)
                        {
                            if (line.Contains("="))
                            {
                                var KeyValPair = line.Split('=');
                                switch (KeyValPair[0])
                                {
                                case "email":
                                    Username = KeyValPair[1];
                                    break;

                                case "key":
                                    UserSecret = KeyValPair[1];
                                    break;

                                case "site":
                                    ServerURL = KeyValPair[1];
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new InvalidZulipRCFileException("Invalid .zuliprc file.");
                    }
                }
            }
            else
            {
                throw new FileNotFoundException(ZulipRCPath + "could not be found.");
            }

            Server    = new ZulipServer(ServerURL);
            ZulipAuth = new ZulipAuthentication(Username, UserSecret);
        }
コード例 #3
0
 /// <summary>
 /// Requires two objects that together enable the API user authentication.
 /// </summary>
 /// <param name="Server"></param>
 /// <param name="ZulipAuth"></param>
 public ZulipClient(ZulipServer Server, ZulipAuthentication ZulipAuth)
 {
     this.Server         = Server;
     this.Authentication = ZulipAuth;
 }
コード例 #4
0
 public ZulipClient(string serverUrl, string userEmail, string password)
 {
     Server         = new ZulipServer(serverUrl);
     Authentication = new ZulipAuthentication(userEmail, password, true);
 }