ConstructorIO.ConstructorIOAPI.VerifyAsync C# (CSharp) Method

VerifyAsync() public method

Verify that the API key is valid.
public VerifyAsync ( ) : Task
return Task
        public async Task<bool> VerifyAsync()
        {
            var verifyRequest = new ConstructorIORequest(APIRequestType.V1_Verify, "GET");

            var verifyResponse = await Requestor.MakeRequest(verifyRequest);

            if (verifyResponse.Item2.IndexOf("successful authentication") != -1)
            {
                //TODO: beter way to do this?
                return true;
            }
            return false;
        }

Usage Example

        private async void btnVerify_Click(object sender, EventArgs e)
        {
            m_constructorClient = new ConstructorIOAPI(txtAPI.Text, txtKey.Text);

            try
            {
                bool success = await m_constructorClient.VerifyAsync();
                if(success)
                {
                    MessageBox.Show("Valid Credentials");
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString());
            }
        }