Skip to content

Commit 88d2474

Browse files
mariferswmartinfnswrgomezc
authored
Feature/ss879 (#22) (#23)
* Removed unnecessary units from the uses clauses, and moved what was possible to the uses inside the implementation section This to avoid issues when generating C++Builder compatible code, as the extra includes generate compiling problems with big projects * Cleanup of unused variable * Added an internal field to store the original JSON string This is used instead of the conversion from objecto->json when using the method ToJsonString. There is an important issue with this class: the uuid field on the cancellation response is not being correctly parsed, because the field is a dynamic value (the UUID) so the RTTI can't map it to the object. Adding the original JSON string allows the user of this class to parse the JSON directly and extract those values if needed. * Removed the storing of the CFDI into a "temporary" file Storing the CFDI XML into a file on the current directory is not adequate in a lot of cases: if the user doesn't have privileges to modify that folder, or there are several concurrent users that might need to use this service, and so on. It's not needed to do that file, in the first place: you can pass the XML directly using a TStringStream. * Improved response handling to retrieve UUID statuses * Improve form to receive response attributes from cancellation methods * Improve form to receive response attributes from cancellation methods * Added attribute invocation specifications and precision to support libraries for TLS 1.2 compatibility * add LICENSE file for Luna Soft project (GPL v3) * add dll files to configuration * remove comments * update version --------- Co-authored-by: martinfnsw <88680430+martinfnsw@users.noreply.github.com> Co-authored-by: Rodrigo Gómez <rgomez@trafficsystem.com.mx>
1 parent 557c46d commit 88d2474

39 files changed

+1393
-588
lines changed

AccountBalance/Balance.pas

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,15 @@
33
interface
44

55
uses
6-
System.SysUtils,
7-
System.Variants,
8-
System.Classes,
9-
System.JSON,
10-
System.JSON.Builders,
11-
System.JSON.Writers,
12-
System.JSON.Readers,
13-
System.JSON.BSON,
14-
IdHTTP, IdGlobal,
15-
IdCoder,
16-
IdCoder3to4,
17-
IdCoderMIME,
18-
IdMultipartFormData,
19-
IdGlobalProtocols,
20-
Vcl.Controls,
21-
Vcl.Forms,
22-
Vcl.Dialogs,
23-
IPPeerClient,
24-
Vcl.StdCtrls,
25-
REST.Client,
26-
Data.Bind.Components,
27-
Data.Bind.ObjectScope,
28-
REST.Types,
29-
Vcl.ComCtrls,
30-
BalanceRequest,
316
BalanceResponse;
327

338
function AccountBalance(URL, Token: String): TBalanceResponse;
349

3510
implementation
3611

12+
uses
13+
BalanceRequest;
14+
3715
function AccountBalance(URL, Token: String): TBalanceResponse;
3816
begin
3917
Result := TBalanceResponse.FromJsonString

AccountBalance/BalanceRequest.pas

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
interface
44

5+
function GetBalance(URL, Token: String): String;
6+
7+
implementation
8+
59
uses
610
System.SysUtils,
711
System.Classes,
812
System.JSON,
913
SWHTTPClient;
1014

11-
function GetBalance(URL, Token: String): String;
12-
13-
implementation
14-
1515
function GetBalance(URL, Token: String): String;
1616
var
1717
HTTPClient: TSWHTTPClient;

AccountBalance/BalanceResponse.pas

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
interface
44

5-
uses Generics.Collections, Rest.Json;
6-
75
type
86

97
TDataClass = class
@@ -52,6 +50,10 @@ TBalanceResponse = class
5250

5351
implementation
5452

53+
uses
54+
Generics.Collections,
55+
Rest.Json;
56+
5557
{ TDataClass }
5658

5759
constructor TDataClass.Create;

Authentication/Authentication.pas

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22

33
interface
44

5+
uses
6+
System.Classes,
7+
AuthenticationResponse;
8+
9+
function AuthenticationService(URL, User, Password: String): TResponse;
10+
11+
implementation
12+
513
uses
614
Winapi.Windows,
715
Winapi.Messages,
816
System.SysUtils,
917
System.Variants,
10-
System.Classes,
1118
System.JSON,
1219
System.JSON.Builders,
1320
System.JSON.Writers,
@@ -19,14 +26,9 @@ interface
1926
IdCoderMIME,
2027
IdMultipartFormData,
2128
IdGlobalProtocols,
22-
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IPPeerClient, Vcl.StdCtrls, REST.Client,
29+
IPPeerClient, REST.Client,
2330
Data.Bind.Components, Data.Bind.ObjectScope, REST.Types,
24-
Vcl.ComCtrls, Helper, AuthenticationRequest,
25-
AuthenticationResponse;
26-
27-
function AuthenticationService(URL, User, Password: String): TResponse;
28-
29-
implementation
31+
Vcl.ComCtrls, Helper, AuthenticationRequest;
3032

3133
function AuthenticationService(URL, User, Password: String): TResponse;
3234
begin

Authentication/AuthenticationRequest.pas

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@
22

33
interface
44

5+
uses
6+
System.Classes;
7+
8+
function AuthRequest(URL, User, Password: String): String;
9+
10+
implementation
11+
512
uses
613
Winapi.Windows,
714
Winapi.Messages,
815
System.SysUtils,
9-
System.Classes,
1016
System.JSON,
1117
SWHTTPClient,
1218
IdHTTP;
1319

14-
function AuthRequest(URL, User, Password: String): String;
15-
16-
implementation
17-
1820
function AuthRequest(URL, User, Password: String): String;
1921
var
2022
HTTPClient: TSWHTTPClient;
2123
RequestBody: TStream;
2224
JSONBody: TJSONObject;
23-
ErrorResponse: TJSONObject;
2425
begin
2526
HTTPClient := TSWHTTPClient.Create;
2627
try

Authentication/AuthenticationResponse.pas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
interface
44

5-
uses Generics.Collections, Rest.Json;
65

76
type
87

@@ -38,6 +37,8 @@ TResponse = class
3837

3938
implementation
4039

40+
uses Generics.Collections, Rest.Json;
41+
4142
{TData}
4243

4344

Cancelation/AcceptReject/CancelationAcceptReject.pas

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,6 @@
33
interface
44

55
uses
6-
System.SysUtils,
7-
System.Variants,
8-
System.Classes,
9-
System.JSON,
10-
System.JSON.Builders,
11-
System.JSON.Writers,
12-
System.JSON.Readers,
13-
System.JSON.BSON,
14-
IdHTTP, IdGlobal,
15-
IdCoder,
16-
IdCoder3to4,
17-
IdCoderMIME,
18-
IdMultipartFormData,
19-
IdGlobalProtocols,
20-
Vcl.Controls,
21-
Vcl.Forms,
22-
Vcl.Dialogs,
23-
IPPeerClient,
24-
Vcl.StdCtrls,
25-
REST.Client,
26-
Data.Bind.Components,
27-
Data.Bind.ObjectScope,
28-
REST.Types,
29-
Vcl.ComCtrls,
30-
StampRequest,
31-
CancelationResponse,
32-
CancelationRequest,
336
CancelationRelationsResponse,
347
CancelationAcceptRejectResponse;
358

@@ -42,6 +15,11 @@ function CancelationAcceptRejectByUuid(URL, Token, RFCEmisor, Uuid, Accion: Stri
4215

4316
implementation
4417

18+
uses
19+
StampRequest,
20+
CancelationResponse,
21+
CancelationRequest;
22+
4523
function CancelationAcceptRejectByCsd(URL, Token, RFCEmisor, Uuid, Accion,
4624
b64Key, b64Cer, PasswordKey: String): TCancelationAcceptRejectResponse;
4725
begin

Cancelation/AcceptReject/CancelationAcceptRejectResponse.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
interface
44

5-
uses Generics.Collections, Rest.Json;
6-
75
type
86

97
TFoliosClass = class
@@ -52,8 +50,10 @@ TCancelationAcceptRejectResponse = class
5250

5351
implementation
5452

55-
{TFoliosClass}
53+
uses
54+
Generics.Collections, Rest.Json;
5655

56+
{TFoliosClass}
5757

5858
function TFoliosClass.ToJsonString: string;
5959
begin

Cancelation/Cancelation.pas

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,11 @@
33
interface
44

55
uses
6-
System.SysUtils,
7-
System.Variants,
8-
System.Classes,
9-
System.JSON,
10-
System.JSON.Builders,
11-
System.JSON.Writers,
12-
System.JSON.Readers,
13-
System.JSON.BSON,
14-
IdHTTP, IdGlobal,
15-
IdCoder,
16-
IdCoder3to4,
17-
IdCoderMIME,
18-
IdMultipartFormData,
19-
IdGlobalProtocols,
20-
Vcl.Controls,
21-
Vcl.Forms,
22-
Vcl.Dialogs,
23-
IPPeerClient,
24-
Vcl.StdCtrls,
25-
REST.Client,
26-
Data.Bind.Components,
27-
Data.Bind.ObjectScope,
28-
REST.Types,
29-
Vcl.ComCtrls,
306
StampRequest,
317
CancelationResponse,
328
CancelationRequest;
339

34-
function CancelationByXml(url, token, xml: String): TCancelationResponse;
10+
function CancelationByXml(url, token, xml: String): TCancelationResponse;
3511
function CancelationByCsd(url, token, rfcEmisor, uuid, motivo, folioSustitucion,
3612
b64Cer, b64Key, passwordKey: String): TCancelationResponse;
3713
function CancelationByPfx(url, token, rfcEmisor, uuid, motivo, folioSustitucion, b64Pfx,

Cancelation/CancelationRequest.pas

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,6 @@
22

33
interface
44

5-
uses
6-
System.SysUtils,
7-
System.Variants,
8-
System.Classes,
9-
Vcl.Graphics,
10-
StrUtils,
11-
System.JSON,
12-
System.JSON.Builders,
13-
System.JSON.Writers,
14-
System.JSON.Readers,
15-
System.JSON.BSON,
16-
IPPeerClient,
17-
REST.Client,
18-
Data.Bind.Components,
19-
Data.Bind.ObjectScope,
20-
REST.Types,
21-
SWHTTPClient, IdHTTP;
22-
235
function RequestJson(url, token, body, path: String): String;
246
function RequestUrl(url, token, rfcEmisor, uuid, pathReq: String): String; overload;
257
function RequestUrl(url, token, rfcEmisor, uuid, motivo, folioSustitucion, pathReq: String): String; overload;
@@ -35,6 +17,17 @@ function RemoveCrLf(const S: string): string;
3517

3618
implementation
3719

20+
uses
21+
System.SysUtils,
22+
System.Variants,
23+
System.Classes,
24+
StrUtils,
25+
System.JSON,
26+
Data.Bind.Components,
27+
REST.Types,
28+
SWHTTPClient,
29+
IdHTTP;
30+
3831
function RequestJson(url, token, body, path: String): String;
3932
var
4033
HTTPClient: TSWHTTPClient;

0 commit comments

Comments
 (0)