Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Lightspeed - Delete a Product
See more Lightspeed Examples
Remove an existing product based on the unique identifierChilkat Pascal (Lazarus/Delphi) Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.HttpResponse,
Chilkat.Http;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
http: THttp;
resp: THttpResponse;
respStatusCode: Integer;
begin
success := False;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := THttp.Create;
// Implements the following CURL command:
// curl -X DELETE https://api.webshopapp.com/en/products/PRODUCT_ID.json \
// -u API_KEY:API_SECRET
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
http.Login := 'API_KEY';
http.Password := 'API_SECRET';
// Use the correct cluster for your shop. Here are the choices:
// eu1 https://api.webshopapp.com/en/
// us1 https://api.shoplightspeed.com/en/
resp := THttpResponse.Create;
success := http.HttpNoBody('DELETE','https://api.webshopapp.com/en/products/PRODUCT_ID.json',resp);
if (success = False) then
begin
WriteLn(http.LastErrorText);
Exit;
end;
respStatusCode := resp.StatusCode;
WriteLn('Response Status Code = ' + respStatusCode);
if (respStatusCode <> 204) then
begin
WriteLn('Response Header:');
WriteLn(resp.Header);
WriteLn('Response Body:');
WriteLn(resp.BodyStr);
WriteLn('Failed.');
Exit;
end;
WriteLn('Success.');
http.Free;
resp.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.