Skip to content

TWebRESTClient

Description

This is a REST client component. TWebRESTClient descends from a TWebHTTPRequest. It implements that OAuth2 flow and it will use the obtained access token in HTTP requests performed to the REST API endpoint.

Properties for TWebRESTClient

Property Description
AccessExpiry: TDateTime Holds the time when the access token will expire
AccessToken: string Holds the access token
RefreshExpiry: TDateTime Holds the time when the refresh token will expire
RefreshToken: string Holds the refresh token
App: TRESTApp Sets the REST client application settings
LoginWidth Sets the width of the dialog used to show the REST service login form
LoginHeight Sets the height of the dialog used to show the REST service login form
Methods Description
HttpsCommand(Command, URL, Data, ContentType: string; headers: TCoreCloudHeaders); Performs a HTTP request Command to URL
HttpsDelete(URL: string); Performs a HTTP DELETE request to URL
HttpsDelete(URL: string; headers: TCoreCloudHeaders); Overload of HTTP DELETE request with headers
HttpsGet(URL: string); Performs a HTTP GET request
HttpsGet(URL: string; headers: TCoreCloudHeaders); Overload of HTTP GET request with headers
HttpsPost(URL: string; Data: string); Performs a HTTP POST request with data
HttpsPost(URL: string; ContentType, Data: string); Performs a HTTP POST request with content-type and data
HttpsPost(URL: string; ContentType, Data: string; headers: TCoreCloudHeaders); Overload of HTTP POST request with headers
HttpsPost(URL: string; headers: TCoreCloudHeaders; Data: string); Overload of HTTP POST request with headers
HttpsUpdate(URL: string; headers: TCoreCloudHeaders; Data: string); Performs a HTTP UPDATE request with headers
HttpsPut(URL: string; ContentType, Data: string); Performs a HTTP PUT request with content-type and data
HttpRequest(Command, URL: string; Data: string = ''; ContentType: string = ''; headers: TCoreCloudHeaders = nil): TJSPromise; Promise based function to perform generic HTTP request
class function URLEncode(URI: string): string; Performs URL encoding of URL as string parameter
class function JSONEscape(s: string): string; Performs JSON escaping on string parameter
class function IsoToDateTime(const s: string): TDateTime; Converts ISO date/time as string to TDateTime
class function IsoToDateTime(const s: string; IsUTC: Boolean): TDateTime; Converts ISO date/time in UTC format as string to TDateTime
class function IsoToDate(const s: string): TDateTime; Converts ISO date as string to TDateTime
class function IsIsoDateTime(const s: string): boolean; Converts ISO time as string to TDateTime
class function DateTimeToWL(dt: TDateTime): string;
class function DateTimeToDaylightSavings(dt: TDateTime): TDateTime; Converts date/time to TDateTime taking day light savings in account
class function GetJSONProp(O: TJSONOBject; ID: string): string; Get JSON property value from JSON object as string
class function GetJSONInt(O: TJSONOBject; ID: string): integer; Get JSON property value from JSON object as integer
function Authenticate: TJSPromise; Promise based start of OAuth2 based authentication flow
procedure DoAuth; Perform authenication on service
procedure ClearTokens; Resets the access and refresh tokens to empty strings
procedure Connect; Connects to OAUTH2 service
procedure ReadTokens; Reads previously saved access & refresh tokens from local storage
procedure SaveTokens; Saves access & refresh tokens to local storage

Properties for TRESTApp

Property Description
AuthURL: string URL that opens the login dialog of the API endpoint
Key: string Sets the application key or client ID obtained from the API endpoint
Secret: string Sets the application secret obtained from the API endpoint
CallbackURL: string Sets the callback URL the endpoint will call after a succesfull login