Home

Awesome

CSV Adapter for RESTRequest4Delphi

This is the adapter for generating CSV files for RESTRequest4Delphi. Allows you to generate a text or CSV file with the content of a request.

📞 Contacts

<p align="left"> <a href="https://t.me/Code4Delphi" target="_blank"> <img src="https://img.shields.io/badge/Telegram:-Join%20Channel-blue?logo=telegram"> </a> &nbsp; <a href="https://code4delphi.com.br/blog" target="_blank"> <img src="https://img.shields.io/badge/Blog:-Access-731211?logo=readdotcv&logoColor=731211"> </a> &nbsp; <a href="https://www.youtube.com/@code4delphi" target="_blank"> <img src="https://img.shields.io/badge/YouTube:-Join%20Channel-red?logo=youtube&logoColor=red"> </a> &nbsp; <a href="mailto:contato@code4delphi.com.br" target="_blank"> <img src="https://img.shields.io/badge/E--mail-contato%40code4delphi.com.br-yellowgreen?logo=maildotru&logoColor=yellowgreen"> </a> </p>

✳ Prerequisites

This adapter must be used together with RESTRequest4Delphi

⚡ Installation

boss install github.com/Code4Delphi/csv-adapter-restrequest4delphi
csv-adapter-restrequest4delphi\Src

🚀 Quickstart

uses
  CSV.Adapter.RESTRequest4D;
begin
  TRequest.New.BaseURL('http://localhost:9050/clients')
    .Adapters(TCSVAdapterRESTRequest4D.New(Memo1.Lines, 'optional-root-element'))
    .Accept('application/json')
    .Get;
end;
begin
  TRequest.New.BaseURL('http://localhost:9050/clients')
    .Adapters(TCSVAdapterRESTRequest4D.New('C:\Temp\MyFile.csv', 'optional-root-element'))
    .Accept('application/json')
    .Get;
end;

⚙ Configurations

You can customize resources through the TCSVAdapterRESTRequest4DConfig class:

TRequest.New.BaseURL('http://localhost:9050/clients')
    .Adapters(TCSVAdapterRESTRequest4D.New('C:\Temp\MyFile.csv', 'optional-root-element', TCSVAdapterRESTRequest4DConfig.New.Separator('|')))
    .Accept('application/json')
    .Get;
procedure TViewMain.Button1Click(Sender: TObject);
var
  LResponse: IResponse;
  LConfig: ICSVAdapterRESTRequest4DConfig;
begin
  LConfig := TCSVAdapterRESTRequest4DConfig.New.Separator(cBoxSeparator.Text);

  LResponse := TRequest.New
    .BaseURL(edtBaseURL.Text)
    .Resource(edtResource.Text)
    .Adapters(TCSVAdapterRESTRequest4D.New('C:\Temp\MyFile.csv', 'optional-root-element', LConfig))
    .Accept('application/json')
    .Get;
end;

⌨️ Demo

csv-adapter-restrequest4delphi\Samples\API
csv-adapter-restrequest4delphi\Client

image

💬 Contributions / Ideas / Bug Fixes

To submit a pull request, follow these steps:

  1. Fork the project
  2. Create a new branch (git checkout -b minha-nova-funcionalidade)
  3. Make your changes
  4. Make the commit (git commit -am 'Functionality or adjustment message')
  5. Push the branch (git push origin Message about functionality or adjustment)
  6. Open a pull request