unit ViewPixSend;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, BodyPixClass, XSuperJSON, XSuperObject;

type
  TViewPixSend = class(TForm)
    GroupBox3: TGroupBox;
    btnConfirmRequest: TButton;
    btnCancelRequest: TButton;
    GroupBox1: TGroupBox;
    txtValue: TEdit;
    Label3: TLabel;
    GroupBox2: TGroupBox;
    txtKeyFav: TEdit;
    Label4: TLabel;
    GroupBox4: TGroupBox;
    Label5: TLabel;
    txtKeyPag: TEdit;
    txtPayerInfo: TEdit;
    Label6: TLabel;
    procedure btnConfirmRequestClick(Sender: TObject);
    procedure btnCancelRequestClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
//    function GetE2eid: String;
  //  function GetId: String;
    function GetBody: String;
  public
    //property e2eid: String read GetE2eid;
    //property id:    String read GetId;
    property Body:    String read GetBody;
    procedure ClearRequestfields;
  end;

implementation

{$R *.dfm}
        
procedure TViewPixSend.btnCancelRequestClick(Sender: TObject);
begin
  ModalResult := mrCancel;
end;

procedure TViewPixSend.btnConfirmRequestClick(Sender: TObject);
begin
  ModalResult := mrOk
end;

procedure TViewPixSend.FormCreate(Sender: TObject);
begin
  Self.Position := poScreenCenter;
end;


function TViewPixSend.GetBody: String;
var
  BodyRequest : TBodyPixClass;
  FFavored    : TFavored;
  FPayer      : TPayer;
  FValue      : String;
begin
  BodyRequest := TBodyPixClass.Create;

  FFavored.Key := txtKeyFav.Text;
  BodyRequest.Favored := FFavored;

  FPayer.key := txtKeyPag.Text;
  FPayer.PayingInfo := txtPayerInfo.Text;
  BodyRequest.Payer := FPayer;

  BodyRequest.Value := FValue;

  Result := BodyRequest.AsJSON;
end;

procedure TViewPixSend.ClearRequestfields;
begin
  //txtE2eid.Text := '';
  //txtId.Text := '';
  txtValue.Text := '';
  txtKeyFav.Text := '';
  txtKeyPag.Text := '';
  txtPayerInfo.Text := '';
end;


end.
