Skip to content

Commit

Permalink
Token no BindRest
Browse files Browse the repository at this point in the history
  • Loading branch information
bittencourtthulio committed May 6, 2021
1 parent 7d17431 commit 399b1c4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/Bind4D.Interfaces.pas
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ interface
end;
iBind4DRest = interface
['{DF7F5AF6-E03D-44A2-9358-CD4729741A30}']
function Accept ( aValue : String ) : iBind4DRest;
function AddHeader ( aKey : String; aValue : String ) : iBind4DRest;
function AddParam ( aKey : String; aValue : String ) : iBind4DRest;
function Accept ( aValue : String ) : iBind4DRest;
function BaseURL ( aValue : String ) : iBind4DRest;
function DataSet : TDataSet;
function Get (aEndPoint : String = '') : iBind4DRest; overload;
function Post (aEndPoint : String; aBody : TJsonObject) : iBind4DRest;
function DataSet : TDataSet;
function Token ( aValue : String ) : iBind4DRest;
function &End : iBind4D;
end;

Expand Down
27 changes: 19 additions & 8 deletions src/Bind4D.Rest.pas
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@ TBind4DRest = class(TInterfacedObject, iBind4DRest)
FResquest : IRequest;
FBaseURL : String;
FDataSet : TFDMemTable;
FToken : String;
FParam : TDictionary<string, string>;
public
constructor Create(aParent : iBind4D);
destructor Destroy; override;
class function New(aParent : iBind4D) : iBind4DRest;
function &End : iBind4D;
function BaseURL ( aValue : String ) : iBind4DRest;
function Accept ( aValue : String ) : iBind4DRest;
function AddHeader ( aKey : String; aValue : String ) : iBind4DRest;
function AddParam ( aKey : String; aValue : String ) : iBind4DRest;
function Accept ( aValue : String ) : iBind4DRest;
function BaseURL ( aValue : String ) : iBind4DRest;
function DataSet : TDataSet;
function Get (aEndPoint : String = '') : iBind4DRest; overload;
function Post (aEndPoint : String; aBody : TJsonObject) : iBind4DRest;
function DataSet : TDataSet;
function Token ( aValue : String ) : iBind4DRest;
function &End : iBind4D;
end;

implementation
Expand Down Expand Up @@ -75,6 +77,7 @@ function TBind4DRest.Get(aEndPoint : String = '') : iBind4DRest;
TRequest.New
.BaseURL(aURL)
.Accept('application/json')
.Token(FToken)
.DataSetAdapter(FDataSet)
.Get;

Expand Down Expand Up @@ -135,11 +138,19 @@ class function TBind4DRest.New(aParent : iBind4D): iBind4DRest;

function TBind4DRest.Post(aEndPoint: String; aBody: TJsonObject): iBind4DRest;
begin
TRequest.New
.BaseURL(FBaseURL + aEndPoint)
.Accept('application/json')
.AddBody(aBody.ToString)
TRequest
.New
.BaseURL(FBaseURL + aEndPoint)
.Accept('application/json')
.Token(FToken)
.AddBody(aBody.ToString)
.Post;
end;

function TBind4DRest.Token(aValue: String): iBind4DRest;
begin
Result := Self;
FToken := aValue;
end;

end.

0 comments on commit 399b1c4

Please sign in to comment.