Quickly Consume The Firebase REST API With The Open Source Firebase4Delphi Library
procedure TFirebaseDatabase.SetBaseURI(const ABaseURI: string);
begin
FBaseURI := ABaseURI;
end;
procedure TFirebaseDatabase.SetToken(const AToken: string);
begin
FToken := AToken;
end;
function TFirebaseDatabase.Get(const AParams: array of string;
AQueryParams: TDictionary<string, string> = nil): IFirebaseResponse;
var
ARequest: IFirebaseRequest;
begin
ARequest := TFirebaseRequest.Create(BaseURI, Token);
Result := ARequest.SendData(AParams, TFirebaseCommand.fcGet, nil,
AQueryParams);
end;
function TFirebaseDatabase.Post(const AParams: array of string;
AData: TJSONValue = nil; AQueryParams: TDictionary<string, string> = nil;
ADataOwner: boolean = true): IFirebaseResponse;
var
ARequest: IFirebaseRequest;
begin
ARequest := TFirebaseRequest.Create(BaseURI, Token);
Result := ARequest.SendData(AParams, TFirebaseCommand.fcPost, AData,
AQueryParams, ADataOwner);
end;
function TFirebaseDatabase.Put(const AParams: array of string;
AData: TJSONValue = nil; AQueryParams: TDictionary<string, string> = nil;
ADataOwner: boolean = true): IFirebaseResponse;
var
ARequest: IFirebaseRequest;
begin
ARequest := TFirebaseRequest.Create(BaseURI, Token);
Result := ARequest.SendData(AParams, TFirebaseCommand.fcPut, AData,
AQueryParams, ADataOwner);
end;
function TFirebaseDatabase.Patch(const AParams: array of string;
AData: TJSONValue = nil; AQueryParams: TDictionary<string, string> = nil;
ADataOwner: boolean = true): IFirebaseResponse;
var
ARequest: IFirebaseRequest;
begin
ARequest := TFirebaseRequest.Create(BaseURI, Token);
Result := ARequest.SendData(AParams, TFirebaseCommand.fcPatch, AData,
AQueryParams, ADataOwner);
end;
function TFirebaseDatabase.Delete(const AParams: array of string;
AQueryParams: TDictionary<string, string> = nil): IFirebaseResponse;
var
ARequest: IFirebaseRequest;
begin
ARequest := TFirebaseRequest.Create(BaseURI, Token);
Result := ARequest.SendData(AParams, TFirebaseCommand.fcRemove, nil,
AQueryParams);
end;