This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPanamahSDK.MiscTypes.pas
78 lines (64 loc) · 1.78 KB
/
PanamahSDK.MiscTypes.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{$M+}
unit PanamahSDK.MiscTypes;
interface
uses
Classes, SysUtils, PanamahSDK.Types, PanamahSDK.Models.Loja, PanamahSDK.Enums, Variants, uLkJSON;
type
IPanamahKeyResponse = interface(IJSONSerializable)
['{20D1BDAA-93B3-4428-833A-62C438EE8C74}']
function GetChave: string;
procedure SetChave(const AChave: string);
property Chave: string read GetChave write SetChave;
end;
TPanamahKeyResponse = class(TInterfacedObject, IPanamahKeyResponse)
private
FChave: string;
function GetChave: string;
procedure SetChave(const AChave: string);
public
function SerializeToJSON: string;
procedure DeserializeFromJSON(const AJSON: string);
class function FromJSON(const AJSON: string): IPanamahKeyResponse;
property Chave: string read GetChave write SetChave;
end;
implementation
uses
PanamahSDK.JsonUtils, PanamahSDK.ValidationUtils;
{ TPanamahKeyResponse }
class function TPanamahKeyResponse.FromJSON(const AJSON: string): IPanamahKeyResponse;
begin
Result := TPanamahKeyResponse.Create;
Result.DeserializeFromJSON(AJSON);
end;
function TPanamahKeyResponse.GetChave: string;
begin
Result := FChave;
end;
procedure TPanamahKeyResponse.SetChave(const AChave: string);
begin
FChave := AChave;
end;
procedure TPanamahKeyResponse.DeserializeFromJSON(const AJSON: string);
var
JSONObject: TlkJSONobject;
begin
JSONObject := TlkJSON.ParseText(AJSON) as TlkJSONobject;
try
FChave := GetFieldValueAsString(JSONObject, 'chave');
finally
JSONObject.Free;
end;
end;
function TPanamahKeyResponse.SerializeToJSON: string;
var
JSONObject: TlkJSONobject;
begin
JSONObject := TlkJSONobject.Create;
try
SetFieldValue(JSONObject, 'chave', FChave);
Result := TlkJSON.GenerateText(JSONObject);
finally
JSONObject.Free;
end;
end;
end.