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

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

            rtbCurrentBalanceResponse.Text = response.SerializeToJson();

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