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.V1.RequestModel.Request
            {
                Username = _mainForm.txtUsername.Text,
                Password = _mainForm.txtPassword.Text
            };

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

            rtbCurrentBalanceResponse.Text = response.SerializeToJsonWithFormatIndented();

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