"Metadata":{"type":"object","additionalProperties":{"maxLength":500,"type":"string"}}
TsgcOpenAPI_Metadata_Class = class(TsgcOpenAPIClass)
private
public
class function Read(const aValue: string): TsgcOpenAPI_Metadata_Class;
public
end;
{
"_id": "5b8cb290-0901-4435-9131-576695fab511",
"metadata": {
"KdNr": "10001",
"AdGuid": "420739B4-3B2F-4DD1-BCB2-48997EEE930C"
}
}
TsgcOpenAPI_Metadata_Class = class(TsgcOpenAPI_AdditionalProperties)
public
class function Read(const aValue: string): TsgcOpenAPI_Metadata_Class;
end;
TsgcOpenAPI_OrganizationResponse_Class = class(TsgcOpenAPIClass)
private
F_id: string;
[sgcAdditionalProperties]
Fmetadata: TsgcOpenAPI_Metadata_Class;
public
class function Read(const aValue: string): TsgcOpenAPI_OrganizationResponse_Class;
public
property _id: string read F_id write F_id;
property Metadata: TsgcOpenAPI_Metadata_Class read Fmetadata write Fmetadata;
end;
var
i: Integer;
oResponse: TsgcOpenAPI_OrganizationResponse_Class;
begin
oResponse := TsgcOpenAPI_OrganizationResponse_Class.Read(
' {"_id": "5b8cb290-0901-4435-9131-576695fab511", "metadata": {"KdNr": "10001", "AdGuid": "420739B4-3B2F-4DD1-BCB2-48997EEE930C"}}');
for i := 0 to oResponse.Metadata.Dictionary.Count - 1 do
begin
ShowMessage(oResponse.Metadata.Dictionary.ToArray[i].Key + '=' + oResponse.Metadata.Dictionary.ToArray[i].Value);
end;
procedure TsgcAdditionalPropertiesInterceptor.ObjectReverter(Data: TObject;
Field: string; Arg: TObject);
begin
inherited ObjectReverter(Data, Field, Arg);
end;
{
"_id": "5b8cb290-0901-4435-9131-576695fab511",
"_type": "MANAGED_ORGANIZATION",
"_envs": [
"TEST"
],
"name": "Autogenerated-1",
"display_name": "Autogenerated-Kunde Nr. 1",
"address_line1": "Maingosse 1a",
"zip": "12345",
"town": "Berlin",
"country_code": "DEU",
"billing_options": {
"withhold_billing": true,
"bill_to_organization": "87fe7d03-7e90-4e5c-860f-21cc7e5bf436"
},
"metadata": {
"KdNr": "10001",
"AdGuid": "420739B4-3B2F-4DD1-BCB2-48997EEE930C"
},
"managed_by_organization_id": "87fe7d03-7e90-4e5c-860f-21cc7e5bf436",
"created_by_user": "d1e2fe75-6abe-4466-8690-3078b1c4285b"
}
function TFiskalyManagementOpenApi.retrieveOrganization(aOrganization_id: string): TsgcOpenAPI_retrieveOrganization_Response;
begin;
result := TsgcOpenAPI_retrieveOrganization_Response.Create;
_retrieveOrganization(aOrganization_id, result);
if result.IsSuccessful then
result.Successful := TsgcOpenAPI_OrganizationResponse_Class.Read(result.ResponseText)
else
begin
case result.ResponseCode of
401: result.Error401 := TsgcOpenAPI_retrieveOrganization_ResponseError401_Class.Read(result.ResponseError);
403: result.Error403 := TsgcOpenAPI_retrieveOrganization_ResponseError403_Class.Read(result.ResponseError);
404: result.Error404 := TsgcOpenAPI_retrieveOrganization_ResponseError404_Class.Read(result.ResponseError);
end;
end;
end;
function TFiskalyManagementOpenApi._retrieveOrganization(aOrganization_id: string; const aResponse: TsgcOpenAPIResponse = nil): string;
var
oRequest: TsgcOpenAPIRequest;
begin
oRequest := TsgcOpenAPIRequest.Create;
Try
oRequest.Method := oapiHttpGET;
oRequest.Endpoint := '/organizations/{organization_id}';
oRequest.Security := oapiSecurityToken;
oRequest.Parameters.Add('organization_id', aOrganization_id, oapiInPath, true);
result := DoHTTP_REQUEST(oRequest, aResponse);
Finally
sgcFree(oRequest);
end;
end;
class function TsgcOpenAPI_OrganizationResponse_Class.Read(const aValue: string): TsgcOpenAPI_OrganizationResponse_Class;
begin
result := TJson.JsonToObject<TsgcOpenAPI_OrganizationResponse_Class>(aValue);
result.SetRawText(aValue);
if not Assigned(result.metadata) then
result.metadata := TsgcOpenAPI_Metadata_Class.Create;
result.metadata.DoLoadDictionary('metadata', aValue);
end;
procedure TsgcAdditionalPropertiesInterceptor.ObjectReverter(Data: TObject; Field: string; Arg: TObject);
var
ctx: TRTTIContext;
begin
if Arg is TsgcOpenAPI_AdditionalProperties then
ctx.GetType(Data.ClassType).GetField(Field).SetValue(Data,Arg);
end;