ForceClient

Create authentication network requests by using the ForceClient class. ForceClient uses ForceAuthenticator, which is a protocol that defines the required methods to handle access tokens in Salesforce API.
Use this signature to define the ForceClient class.
1public class ForceClient

Define Authentication

Handle the authentication process and encapsulate the logic to obtain and refresh the access token. Use this resource and signature to define the auth variable.

1auth
1public var auth: ForceAuthenticator

Define the Network Manager

Make HTTP requests to the Salesforce server and manage the responses. Use this resource and signature to define the forceNetworkManager variable.

ForceNetworkManager

1public var forceNetworkManager: NetworkManagerProtocol

Create an Instance from Force Authenticator

Create an instance from the ForceAuthenticator, and defines the required methods to handle access tokens in Salesforce API. Use this resource and signature to define the public initializer for the ForceClient class.

init(auth:forceNetworkManager:)
1public init(auth: ForceAuthenticator, forceNetworkManager: NetworkManagerProtocol = NetworkManager.shared

Use the parameters in this table to define an authentication instance.

Parameters Description
auth A ForceAuthenticator instance that defines the required methods to handle access tokens in Salesforce API.
forceNetworkManager A NetworkManagerProtocol instance that defines the requirements of a network manager.

Fetch Authentication Requests

Get all the REST requests for authentication. This request returns a decoded JSON response result. Use this resource and signature to define the fetch request.

fetch(type:with:urlSession:)

1func fetch<T>(type: T.Type, with request: URLRequest, urlSession: URLSession = .shared) async throws -> T where T : Decodable

Use the parameters in this table to create a fetch request.

Parameters Description
type A type or model of data that you want to decode from the JSON format.
request A URLRequest, which is executed by URLSession.