Skip to main content

iOS Managed API Service

Functions

syncManagedAPIs

public func syncManagedAPIs(
onSuccess: @escaping () -> Void,
onError: ((Error) -> Void)? = nil
)

Synchronizes Managed APIs metadata with the Orchestrator and updates local storage.

Parameters:

  • onSuccess: () -> Void — Called when the sync operation completes successfully.
  • onError: ((Error) -> Void)? — Called if the sync operation fails.

getManagedAPIs

public func getManagedAPIs(
onSuccess: @escaping ([DataMap]) -> Void,
onError: ((Error) -> Void)? = nil
)

Returns all Managed API definitions currently stored on the device.

Parameters:

  • onSuccess: ([DataMap]) -> Void — Called with the full list of Managed APIs.
  • onError: ((Error) -> Void)? — Called if the operation fails.

getManagedAPI

public func getManagedAPI(
name: String,
onSuccess: @escaping (DataMap?) -> Void,
onError: ((Error) -> Void)? = nil
)

Retrieves a single Managed API definition by its name. Returns nil if it does not exist.

Parameters:

  • name: String — Programmatic name of the Managed API.
  • onSuccess: (DataMap?) -> Void — Called with the Managed API definition or nil.
  • onError: ((Error) -> Void)? — Called if the operation fails.

startOAuth

public func startOAuth(
authUrl: String,
redirectUri: String,
queryName: String,
onSuccess: ((String) -> Void)? = nil,
onError: ((Error) -> Void)? = nil
)

Starts an OAuth authentication flow using an in-app browser and returns the authorization code extracted from the redirect URL.

Parameters:

  • authUrl: String — Authorization endpoint URL.
  • redirectUri: String — Redirect URI that will receive the authorization code.
  • queryName: String — Query parameter name that contains the authorization code.
  • onSuccess: (String) -> Void — Called with the extracted authorization code.
  • onError: ((Error) -> Void)? — Called if the flow fails or is cancelled.

fetchTokenFromCode

public func fetchTokenFromCode(
tokenUrl: String,
httpMethod: String,
onSuccess: ((String) -> Void)? = nil,
onError: ((Error) -> Void)? = nil
)

Exchanges an OAuth authorization code for an access token using the given token endpoint.

Parameters:

  • tokenUrl: String — Token endpoint URL.
  • httpMethod: String — HTTP method to use (must be GET or POST).
  • onSuccess: (String) -> Void — Called with the raw token response or access token string.
  • onError: ((Error) -> Void)? — Called if the token request fails.

Classes

DataMap

public typealias DataMap = [String: String]