private void btnPair_Click(object sender, EventArgs e) { Latch latch = new Latch(tbApplicationID.Text, tbSecret.Text); LatchResponse response = latch.Pair(tbToken.Text); if (response.Data != null) { if (response.Data["accountId"] != null) { tbAccountID.Text = response.Data["accountId"].ToString(); lblLog.Text = "Pairing successful!"; StoreCredentials(); } } else { MessageBox.Show(response.Error.Message + " (" + response.Error.Code + ")"); } }
protected override void ProcessRecord() { try { if (String.IsNullOrEmpty(AppId)) { AppId = InputHelper.GetUserInput(this, "AppId"); } if (String.IsNullOrEmpty(SecretKey)) { SecretKey = InputHelper.GetUserInput(this, "SecretKey"); } if (String.IsNullOrEmpty(Token)) { Token = InputHelper.GetUserInput(this, "Token"); } Latch latch = new Latch(AppId, SecretKey); WriteObject(latch.Pair(Token), true); } catch (Exception ex) { InvokeCommand.InvokeScript(String.Format("Write-Host Error: \"{0}\"", ex.Message)); } }