APIClient
Index
Properties
optionalreadonlyadditionalHttpHeaders
Any additional headers that should be added to all requests sent through this client.
Type declaration
[index string]: string
readonlybaseURL
The base URL requests are performed against.
This is used when request types may define their path as relative, and can inherit the URL they should be sent to through the client.
readonlynetwork
The network instance requests are sent through.
optionalreadonlyrequestIdHeader
The name of the HTTP response header where unique request IDs can be found.
readonlyuserAgent
The User-Agent string to be sent along with all outgoing requests.
Methods
didSend
Invoked when a request fails.
Parameters
request: HTTPRequest
receivedError: Error
optionalrequestId: String
optionalrateLimit: APIRateLimit
Returns void
optionalerror
Parses HTTP response body data when a request fails.
- Returns: Error instance, if any, described within the data.
Parameters
fromData: string
Returns Error
send
Send the given request.
Type parameters
- T
The response model type expected.
Parameters
request: HTTPRequest
optionalparsingContext: APIParsingContext
Returns Promise<APIResponse<T>>
- T
shouldRetry
Provides the APIClient.Retry configurations from the delegate in response to a retry request.
Parameters
request: HTTPRequest
rateLimit: APIRateLimit
Returns APIRetry
willSend
Invoked immediately prior to a URLRequest being converted to a DataTask.
Parameters
request: HTTPRequest
Returns void
Protocol defining the interfaces and capabilities that API clients can conform to.
This provides a common pattern for network operations to be performed, and to centralize boilerplate handling of URL requests, provide customization extensions, and normalize response processing and argument handling.
The intent for this is to:
While it would be ideal for implementors to follow the same naming and patterns for these interfaces, it's understood that different languages and environments tend to follow different patterns.
Depending on the language this SDK is being built for, these interfaces should provide inspiration about the sorts of capabilities the SDK should enable.