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

namespace SepehrHotelApiSampleClient.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);

            rtbCurrentBalanceResponse.Text = response.SerializeToJsonWithFormatIndented();

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