viniciussanchez/RESTRequest4Delphi

Parametros dinamicos

stonestecnologia opened this issue · 2 comments

Grande Vini !
Existe uma possibilidade de passar paramentos dinâmicos ?
Algo do tipo :

var
  LResponse: IResponse;
begin
  LResponse := TRequest.New.BaseURL('http://localhost:8888/users')
     if A.Text <> EmptyStr then
    .AddParam('A', A.Text)
     if B.Text <> EmptyStr then
    .AddParam('B', B.Text)
     if C.Text <> EmptyStr then
    .AddParam('C', C.Text)
    .Accept('application/json')
    .Get;
  if LResponse.StatusCode = 200 then
    ShowMessage(LResponse.Content);
end;

Os if's foi so pra vc entender a necessidade, rsrsrs.
Valeu Mestre!!

var
  LResponse: IResponse;
  LRequest: IRequest;
begin
  LRequest := TRequest.New
    .BaseURL('http://localhost:8888/users')
    .Accept('application/json');
  if A.Text <> EmptyStr then
    LRequest.AddParam('A', A.Text);
  if B.Text <> EmptyStr then
    LRequest.AddParam('B', B.Text);
  if C.Text <> EmptyStr then
    LRequest.AddParam('C', C.Text);
  LResponse := LRequest.Get;
  if LResponse.StatusCode = 200 then
    ShowMessage(LResponse.Content);
end;

Obrigado.
Eu imaginei q teria algo parecido com o LINQ.
Sucesso.