Skip to content

Commit 73b4583

Browse files
committedJun 11, 2024
load sparepartlist
1 parent 0296ac5 commit 73b4583

File tree

1 file changed

+116
-9
lines changed

1 file changed

+116
-9
lines changed
 

‎intf.OpenMasterdata.Types.pas

+116-9
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ TOpenMasterdataAPI_LinkedHistoricProduct = class(TObject)
135135
FmanufacturerIdType: String;
136136
FconstructionFrom: String;
137137
FimageLink: String;
138+
FmanufacturerId: String;
138139
public
140+
property manufacturerId : String read FmanufacturerId write FmanufacturerId;
139141
property manufacturerIdType : String read FmanufacturerIdType write FmanufacturerIdType;
140142
property historicProduct : String read FhistoricProduct write FhistoricProduct;
141143
property constructionFrom : String read FconstructionFrom write FconstructionFrom;
@@ -422,8 +424,17 @@ TOpenMasterdataAPI_ArticleRow = class
422424
Ftext: String;
423425
Fposition: String;
424426
public
427+
/// <summary>
428+
/// Position
429+
/// </summary>
425430
property position : String read Fposition write Fposition;
431+
/// <summary>
432+
/// Preisgruppe
433+
/// </summary>
426434
property pricegroup : String read Fpricegroup write Fpricegroup;
435+
/// <summary>
436+
/// Text
437+
/// </summary>
427438
property text : String read Ftext write Ftext;
428439
property linkedProduct : TOpenMasterdataAPI_LinkedProduct read FlinkedProduct write FlinkedProduct;
429440
property linkedHistoricProduct : TOpenMasterdataAPI_LinkedHistoricProduct read FlinkedHistoricProduct write FlinkedHistoricProduct;
@@ -821,6 +832,8 @@ procedure TOpenMasterdataAPI_ResultHelper.LoadFromJson(const _JsonValue: String)
821832
jsonBool : TJSONBool;
822833
jsonValue,jsonValue2,jsonValue3 : TJSONValue;
823834

835+
itemSparepartlistRow : TOpenMasterdataAPI_SparepartlistRow;
836+
824837
procedure LoadMeasureUnitFromJson(_Val : TJSONValue; _Result : TOpenMasterdataAPI_LogisticsMeasure);
825838
var jsonString2 : TJSONString;
826839
begin
@@ -845,6 +858,82 @@ procedure TOpenMasterdataAPI_ResultHelper.LoadFromJson(const _JsonValue: String)
845858
_Result.unit_ := jsonString2.Value;
846859
end;
847860

861+
procedure LoadTextRowFromJson(_Val : TJSONValue; _Result : TOpenMasterdataAPI_TextRow);
862+
var jsonString2 : TJSONString;
863+
begin
864+
if _Val = nil then exit;
865+
if _Result = nil then exit;
866+
867+
if _Val.TryGetValue<TJSONString>('position',jsonString2) then
868+
_Result.position := jsonString2.Value;
869+
if _Val.TryGetValue<TJSONString>('text',jsonString2) then
870+
_Result.text := jsonString2.Value;
871+
end;
872+
873+
procedure LoadLinkedProductFromJson(_Val : TJSONValue; _Result : TOpenMasterdataAPI_LinkedProduct);
874+
var jsonString2 : TJSONString;
875+
begin
876+
if _Val = nil then exit;
877+
if _Result = nil then exit;
878+
879+
if _Val.TryGetValue<TJSONString>('supplierPid',jsonString2) then
880+
_Result.supplierPid := jsonString2.Value;
881+
if _Val.TryGetValue<TJSONString>('manufacturerId',jsonString2) then
882+
_Result.manufacturerId := jsonString2.Value;
883+
if _Val.TryGetValue<TJSONString>('manufacturerIdType',jsonString2) then
884+
_Result.manufacturerIdType := jsonString2.Value;
885+
if _Val.TryGetValue<TJSONString>('manufacturerPid',jsonString2) then
886+
_Result.manufacturerPid := jsonString2.Value;
887+
if _Val.TryGetValue<TJSONString>('gtin',jsonString2) then
888+
_Result.gtin := jsonString2.Value;
889+
if _Val.TryGetValue<TJSONString>('productShortDescr',jsonString2) then
890+
_Result.productShortDescr := jsonString2.Value;
891+
if _Val.TryGetValue<TJSONString>('imageLink',jsonString2) then
892+
_Result.imageLink := jsonString2.Value;
893+
if _Val.TryGetValue<TJSONString>('thumbnailUrl',jsonString2) then
894+
_Result.thumbnailUrl := jsonString2.Value;
895+
end;
896+
897+
procedure LoadLinkedHistoricProductFromJson(_Val : TJSONValue; _Result : TOpenMasterdataAPI_LinkedHistoricProduct);
898+
var jsonString2 : TJSONString;
899+
begin
900+
if _Val = nil then exit;
901+
if _Result = nil then exit;
902+
903+
if _Val.TryGetValue<TJSONString>('manufacturerId',jsonString2) then
904+
_Result.manufacturerId := jsonString2.Value;
905+
if _Val.TryGetValue<TJSONString>('manufacturerIdType',jsonString2) then
906+
_Result.manufacturerIdType := jsonString2.Value;
907+
if _Val.TryGetValue<TJSONString>('historicProduct',jsonString2) then
908+
_Result.historicProduct := jsonString2.Value;
909+
if _Val.TryGetValue<TJSONString>('constructionFrom',jsonString2) then
910+
_Result.constructionFrom := jsonString2.Value;
911+
if _Val.TryGetValue<TJSONString>('productShortDescr',jsonString2) then
912+
_Result.productShortDescr := jsonString2.Value;
913+
if _Val.TryGetValue<TJSONString>('imageLink',jsonString2) then
914+
_Result.imageLink := jsonString2.Value;
915+
end;
916+
917+
procedure LoadArticleRowFromJson(_Val : TJSONValue; _Result : TOpenMasterdataAPI_ArticleRow);
918+
var jsonString2 : TJSONString;
919+
jsonValue : TJSONValue;
920+
begin
921+
if _Val = nil then exit;
922+
if _Result = nil then exit;
923+
924+
if _Val.TryGetValue<TJSONString>('position',jsonString2) then
925+
_Result.position := jsonString2.Value;
926+
if _Val.TryGetValue<TJSONString>('pricegroup',jsonString2) then
927+
_Result.pricegroup := jsonString2.Value;
928+
if _Val.TryGetValue<TJSONString>('text',jsonString2) then
929+
_Result.text := jsonString2.Value;
930+
931+
if _Val.TryGetValue<TJSONValue>('linkedProduct',jsonValue) then
932+
LoadLinkedProductFromJson(jsonValue,_Result.linkedProduct);
933+
if _Val.TryGetValue<TJSONValue>('linkedHistoricProduct',jsonValue) then
934+
LoadLinkedHistoricProductFromJson(jsonValue,_Result.linkedHistoricProduct);
935+
end;
936+
848937
begin
849938
messageJson := TJSONObject.ParseJSONValue(
850939
TOpenMasterdataHelper.FixJson(_JsonValue),
@@ -1210,15 +1299,33 @@ procedure TOpenMasterdataAPI_ResultHelper.LoadFromJson(const _JsonValue: String)
12101299
if jsonValue.TryGetValue<TJSONString>('listNumber',jsonString) then
12111300
sparepartlist.listNumber := jsonString.Value;
12121301

1213-
// if jsonValue.TryGetValue<TJSONArray>('sparepartlistRow',jsonArray) then
1214-
// for jsonValue2 in jsonArray do
1215-
// begin
1216-
// var itemSparepartlistRow : TOpenMasterdataAPI_SparepartlistRow := TOpenMasterdataAPI_SparepartlistRow.Create;
1217-
// sparepartlist.sparepartlistRow.Add(itemSparepartlistRow);
1218-
// TODO
1219-
// if jsonValue2.TryGetValue<TJSONString>('gtin',jsonString) then
1220-
// itemPackagingUnit.gtin := jsonString.Value;
1221-
// end;
1302+
jsonValue3 := jsonValue.FindValue('sparepartlistRow');
1303+
if jsonValue3 <> nil then
1304+
begin
1305+
if jsonValue3 is TJSONObject then
1306+
begin
1307+
itemSparepartlistRow := TOpenMasterdataAPI_SparepartlistRow.Create;
1308+
sparepartlist.sparepartlistRow.Add(itemSparepartlistRow);
1309+
if jsonValue3.TryGetValue<TJSONValue>('textRow',jsonValue2) then
1310+
LoadTextRowFromJson(jsonValue2,itemSparepartlistRow.textRow);
1311+
if jsonValue3.TryGetValue<TJSONValue>('articleRow',jsonValue2) then
1312+
LoadArticleRowFromJson(jsonValue2,itemSparepartlistRow.articleRow);
1313+
end
1314+
else
1315+
if jsonValue3 is TJSONArray then
1316+
begin
1317+
if jsonValue.TryGetValue<TJSONArray>('sparepartlistRow',jsonArray) then
1318+
for jsonValue2 in jsonArray do
1319+
begin
1320+
itemSparepartlistRow := TOpenMasterdataAPI_SparepartlistRow.Create;
1321+
sparepartlist.sparepartlistRow.Add(itemSparepartlistRow);
1322+
if jsonValue2.TryGetValue<TJSONValue>('textRow',jsonValue3) then
1323+
LoadTextRowFromJson(jsonValue3,itemSparepartlistRow.textRow);
1324+
if jsonValue2.TryGetValue<TJSONValue>('articleRow',jsonValue3) then
1325+
LoadArticleRowFromJson(jsonValue3,itemSparepartlistRow.articleRow);
1326+
end;
1327+
end;
1328+
end;
12221329
end;
12231330
if messageJson.TryGetValue<TJSONArray>('pictures',jsonArray) then
12241331
for jsonValue in jsonArray do

0 commit comments

Comments
 (0)
Please sign in to comment.