Skip to content

Commit 9ee8c87

Browse files
committed
small refactor
1 parent 42fd1de commit 9ee8c87

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

yookassa_api.pas

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,20 @@ TYookassaRequest = class
7474
function Execute: TYookassaResponse;
7575
end;
7676

77+
TYookassaAPIObject = class
78+
public
79+
function ToJSON: TJSONObject; virtual; abstract;
80+
end;
81+
7782
{ TYookassaSupplier }
78-
TYookassaSupplier = class
83+
TYookassaSupplier = class(TYookassaAPIObject)
7984
private
8085
FName: string;
8186
FPhone: string;
8287
FInn: string;
8388
public
8489
constructor Create(const AName, APhone, AInn: string); overload;
85-
function ToJSON: TJSONObject;
90+
function ToJSON: TJSONObject; override;
8691
property Name: string read FName write FName;
8792
{ Телефон поставщика (тег в 54 ФЗ — 1171). Указывается в формате ITU-T E.164, например 79000000000.
8893
Параметр предусмотрен форматом фискальных документов (ФФД) и является обязательным, начиная с версии 1.1. }
@@ -103,7 +108,7 @@ TYookassaSupplier = class
103108
);
104109

105110
{ TYookassaReceiptItem }
106-
TYookassaReceiptItem = class
111+
TYookassaReceiptItem = class(TYookassaAPIObject)
107112
private
108113
FAgentType: TYookassaAgentType;
109114
FSupplier: TYookassaSupplier;
@@ -122,15 +127,15 @@ TYookassaReceiptItem = class
122127
Measure: string;
123128
constructor Create;
124129
destructor Destroy; override;
125-
function ToJSON: TJSONObject;
130+
function ToJSON: TJSONObject; override;
126131
property AgentType: TYookassaAgentType read FAgentType write FAgentType;
127132
property Supplier: TYookassaSupplier read GetSupplier;
128133
end;
129134

130135
TReceiptItems = specialize TFPGObjectList<TYookassaReceiptItem>;
131136

132137
{ TYookassaReceipt }
133-
TYookassaReceipt = class
138+
TYookassaReceipt = class(TYookassaAPIObject)
134139
private
135140
FCustomerEmail: string;
136141
FCustomerPhone: string;
@@ -140,7 +145,7 @@ TYookassaReceipt = class
140145
constructor Create;
141146
destructor Destroy; override;
142147
procedure AddItem(aItem: TYookassaReceiptItem);
143-
function ToJSON: TJSONObject; // to create a receipt separately
148+
function ToJSON: TJSONObject; override;
144149
procedure AppendJSON(aJSON: TJSONObject);
145150
property CustomerEmail: String read FCustomerEmail write FCustomerEmail;
146151
property CustomerPhone: String read FCustomerPhone write FCustomerPhone;
@@ -149,15 +154,15 @@ TYookassaReceipt = class
149154
end;
150155

151156
{ TYookassaSettlement }
152-
TYookassaSettlement = class
157+
TYookassaSettlement = class(TYookassaAPIObject)
153158
private
154159
FType: string; // 'cash' or 'bank_card'
155160
FAmountValue: Currency;
156161
FAmountCurrency: string;
157162
public
158163
constructor Create; overload;
159164
constructor Create(const aType: string; aAmount: Currency; const aCurrency: string); overload;
160-
function ToJSON: TJSONObject;
165+
function ToJSON: TJSONObject; override;
161166
property SettlementType: string read FType write FType;
162167
property Amount: Currency read FAmountValue write FAmountValue;
163168
property Currency: string read FAmountCurrency write FAmountCurrency;

0 commit comments

Comments
 (0)