protected void BtnSave_OnClick(object sender, EventArgs e)
        {
            _credentialsStore = GcDynamicUtilities.RetrieveStore <GcDynamicCredentials>();
            var apiKey       = txtApiKey.Text;
            var emailAddress = txtEmailAddress.Text;

            _client = new GcConnectClient(apiKey, emailAddress);

            if (!_client.GetAccounts().IsNullOrEmpty())
            {
                var selectedAccount = Request.Form["ddlGcAccounts"];
                if (selectedAccount.IsNullOrEmpty())
                {
                    selectedAccount = _client.GetAccounts().ToList().First().Id;
                }
                _credentials = new GcDynamicCredentials(emailAddress, apiKey, selectedAccount);
                GcDynamicUtilities.SaveStore(_credentials);
                Response.Write($"<script>alert('Hello {_client.GetMe().FirstName}! You have successfully connected to" +
                               " the GatherContent API')</script>");
            }
            else
            {
                Response.Write("<script>alert('Invalid Email Address or ApiKey! Try again!')</script>");
                //txtPlatformUrl.Text = "";
                GcDynamicUtilities.ClearStore <GcDynamicCredentials>();
            }
            PopulateForm();
        }
        private void PopulateForm()
        {
            _credentialsStore = GcDynamicUtilities.RetrieveStore <GcDynamicCredentials>();
            ddlGcAccounts.Items.Clear();
            txtApiKey.Text       = string.Empty;
            txtEmailAddress.Text = string.Empty;
            if (_credentialsStore.IsNullOrEmpty())
            {
                return;
            }
            var email  = _credentialsStore.ToList().First().Email;
            var apiKey = _credentialsStore.ToList().First().ApiKey;

            txtEmailAddress.Text = email;
            txtApiKey.Text       = apiKey;
            _client = new GcConnectClient(apiKey, email);
            var accounts = _client.GetAccounts();

            accounts.ToList().ForEach(i => ddlGcAccounts.Items.Add(new ListItem(i.Name, i.Id)));
            if (!_credentialsStore.ToList().First().AccountId.IsNullOrEmpty())
            {
                ddlGcAccounts.SelectedValue = _credentialsStore.ToList().First().AccountId;
                //txtPlatformUrl.Text = $"https://{_client.GetAccountById(Convert.ToInt32(credentialsStore.ToList().First().AccountId)).Slug}.gathercontent.com";
            }
            else
            {
                ddlGcAccounts.SelectedIndex = 0;
                //txtPlatformUrl.Text = $"https://{_client.GetAccountById(Convert.ToInt32(ddlGcAccounts.SelectedValue)).Slug}.gathercontent.com";
            }
        }
Пример #3
0
        public void GetAccountsTest()
        {
            var accountObject = _clientObject.GetAccounts();

            Assert.IsNotNull(accountObject);
            CollectionAssert.AllItemsAreUnique(accountObject.ToList());
            CollectionAssert.AllItemsAreNotNull(accountObject.ToList());
        }
Пример #4
0
        public void GetAccounts_InvalidCredential()
        {
            var invalidCredential = new GcConnectClient("abc",
                                                        _configData.Email);
            var accountObject = invalidCredential.GetAccounts();

            Assert.IsNull(accountObject);
        }