コード例 #1
0
ファイル: BaseFixture.cs プロジェクト: neilortoo/FreeAgent
        public virtual void SetupClient()
        {
            Configure();

            FreeAgentClient.UseSandbox = KeyStorage.UseSandbox;
            if (KeyStorage.UseProxy) FreeAgentClient.Proxy = new WebProxy("127.0.0.1", 8888);

            Client = new FreeAgentClient(KeyStorage.AppKey, KeyStorage.AppSecret);

            var sandbox_bttest_token = new AccessToken
            {
                access_token = "",
                refresh_token = KeyStorage.RefreshToken,
                token_type = "bearer"
            };

            Client.CurrentAccessToken = sandbox_bttest_token;

            Token = Client.RefreshAccessToken();

            if (Token == null || string.IsNullOrEmpty(Token.access_token) || string.IsNullOrEmpty(Token.refresh_token))
            {
                throw new Exception("Could not setup the Token");
            }
        }
コード例 #2
0
        public void CanGetList()
        {
            FreeAgentClient.UseSandbox = true;
            //FreeAgentClient.Proxy = new WebProxy("127.0.0.1", 8888);
            var sandbox_bttest_token = new AccessToken
            {
                access_token = "",
                refresh_token = KeyStorage.RefreshToken,
                token_type = "bearer"
            };

            {

                var Client = new FreeAgentClient(KeyStorage.AppKey, KeyStorage.AppSecret);

                Client.CurrentAccessToken = sandbox_bttest_token;

                try
                {
                    var co = Client.Company.Single();
                } catch
                {

                }

            }

            FreeAgentClient.UseSandbox = false;

                var LiveClient = new FreeAgentClient(KeyStorage.AppKey, KeyStorage.AppSecret);

                LiveClient.CurrentAccessToken = sandbox_bttest_token;

                try
                {
                    var co = LiveClient.Company.Single();
                } catch
                {

                }

            Assert.IsTrue(true);
        }