using System;
using System.Windows.Forms;
using SepehrFlightApiSampleClient.BuiltinTypeExtensions;
using SepehrFlightApiSampleClient.Generic.WebApi;

namespace SepehrFlightApiSampleClient.Generic.WinForms
{
    public partial class CurrentBalanceForm : Form
    {
        private readonly MainForm _mainForm;

        public CurrentBalanceForm(MainForm mainForm)
        {
            _mainForm = mainForm;
            InitializeComponent();
        }

        private void btnCurrentBalance_Click(object sender, EventArgs e)
        {
            var request = new Sepehr.ApiGateway.Partners.Contracts.Generic.CurrentBalance.V3.RequestModel.Request
            {
                Username = _mainForm.txtUsername.Text,
                Password = _mainForm.txtPassword.Text
            };

            var response = CurrentBalanaceApi.Post(_mainForm.txtUrl.Text, request);

            txtResponse.Text = response.SerializeToJsonWithFormatIndented();
            txtResponse.Visible = true;

            MessageBox.Show("Done :)");
        }
    }
}
