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> <a href="https://code4delphi.com.br/blog" target="_blank"> <img src="https://img.shields.io/badge/Blog:-Access-731211?logo=readdotcv&logoColor=731211"> </a> <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> <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
- Installation using the Boss:
boss install github.com/Code4Delphi/csv-adapter-restrequest4delphi
- Manual installation: Open your Delphi and add the following folder to your project, under Project > Options > Building > Delphi Compiler > Search path
csv-adapter-restrequest4delphi\Src
🚀 Quickstart
- Add uses to your system:
uses
CSV.Adapter.RESTRequest4D;
- Getting the CSV for a TString:
begin
TRequest.New.BaseURL('http://localhost:9050/clients')
.Adapters(TCSVAdapterRESTRequest4D.New(Memo1.Lines, 'optional-root-element'))
.Accept('application/json')
.Get;
end;
- Automatically saving CSV to a file:
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:
- With Inline Settings
TRequest.New.BaseURL('http://localhost:9050/clients')
.Adapters(TCSVAdapterRESTRequest4D.New('C:\Temp\MyFile.csv', 'optional-root-element', TCSVAdapterRESTRequest4DConfig.New.Separator('|')))
.Accept('application/json')
.Get;
- With Settings in variable
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
- Along with the project sources, you will find test projects. The API and Client project are respectively in the folders:
csv-adapter-restrequest4delphi\Samples\API
csv-adapter-restrequest4delphi\Client
💬 Contributions / Ideas / Bug Fixes
To submit a pull request, follow these steps:
- Fork the project
- Create a new branch (
git checkout -b minha-nova-funcionalidade
) - Make your changes
- Make the commit (
git commit -am 'Functionality or adjustment message'
) - Push the branch (
git push origin Message about functionality or adjustment
) - Open a pull request