Skip to content

API_CallCurrentOrg

Class · Group: Web Services

apex
global virtual inherited sharing class API_CallCurrentOrg extends API_Outbound

Extends: API_Outbound

Base API class for all handlers that call the current Org standard APIs. Uses session-ID-based authentication and resolves the org base URL dynamically via URL.getOrgDomainURL(). Subscribers must add a Remote Site Setting for their My Domain URL.

Since: 1.0

Example:

apex
global class API_OrgMetadata extends API_CallCurrentOrg
{
    global override void configure()
    {
        super.configure();
        requestPayload = new DTO_Request();
        responsePayload = new DTO_Response();
    }
}

Methods

MethodDescription
global virtual override void configure()Initialises the handler and sets the base URL to the current org domain.
global virtual override String getAuthorisationToken()Will return the current session Id as authorisation token.
global virtual override String getWebServiceEndPoint()Constructs the full endpoint URL by combining the current org domain URL with the endpoint path from ApiSetting__mdt configuration.

Method Details

configure

apex
global virtual override void configure()

Initialises the handler and sets the base URL to the current org domain.

Since: 1.0

Example:

apex
global override void configure()
{
    super.configure();
    requestPayload = new DTO_Request();
}

getAuthorisationToken

apex
global virtual override String getAuthorisationToken()

Will return the current session Id as authorisation token.

Returns: String - Authorisation Header value

Since: 1.0

Example:

apex
global class API_OrgMetadata extends API_CallCurrentOrg
{
    // Uses inherited getAuthorisationToken() which returns 'Bearer <sessionId>'
    // to authenticate against the current org's REST API
}

getWebServiceEndPoint

apex
global virtual override String getWebServiceEndPoint()

Constructs the full endpoint URL by combining the current org domain URL with the endpoint path from ApiSetting__mdt configuration.

Returns: String - The full URL endpoint for the web service

Since: 1.0

Example:

apex
// With EndpointPath__c = '/services/data/v{0}/sobjects/StreamingChannel/{1}/push'
// Returns: 'https://myorg.my.salesforce.com/services/data/v{0}/sobjects/StreamingChannel/{1}/push'