@hydra-cg/heracles.ts > HydraClient
HydraClient, also known as Heracles.ts, is a generic client for Hydra-powered Web APIs.
To learn more about Hydra please refer to https://www.hydra-cg.com/spec/latest/core/
HydraClient
⊕ new HydraClient(hypermediaProcessors: Iterable<IHypermediaProcessor>, iriTemplateExpansionStrategy: IIriTemplateExpansionStrategy, linksPolicy?: LinksPolicy, httpCall: HttpCallFacility): HydraClient
Defined in HydraClient.ts:36
Initializes a new instance of the HydraClient class.
Parameters:
| Name | Type | Default value | Description |
|---|---|---|---|
| hypermediaProcessors | Iterable<IHypermediaProcessor> |
- | Hypermedia processors used for response hypermedia controls extraction. |
| iriTemplateExpansionStrategy | IIriTemplateExpansionStrategy | - | IRI template variable expansion strategy. |
Default value linksPolicy |
LinksPolicy | LinksPolicy.Strict | Policy defining what is a considered a link. |
| httpCall | HttpCallFacility | - | HTTP facility used to call remote server. |
Returns: HydraClient
<Private> httpCall● httpCall: function
Defined in HydraClient.ts:36
▸(url: string, options?: RequestInit): Promise<Response>
Parameters:
| Name | Type |
|---|---|
| url | string |
Optional options |
RequestInit |
Returns: Promise<Response>
<Private> hypermediaProcessors● hypermediaProcessors: IHypermediaProcessor[]
Defined in HydraClient.ts:33
<Private> iriTemplateExpansionStrategy● iriTemplateExpansionStrategy: IIriTemplateExpansionStrategy
Defined in HydraClient.ts:34
<Private> linksPolicy● linksPolicy: LinksPolicy
Defined in HydraClient.ts:35
<Static> apiDocumentationNotProvided● apiDocumentationNotProvided: string = “API documentation not provided.”
Defined in HydraClient.ts:25
<Static> invalidResponse● invalidResponse: string = “Remote server responded with a status of “
Defined in HydraClient.ts:28
<Static> noEntryPointDefined● noEntryPointDefined: string = “API documentation has no entry point defined.”
Defined in HydraClient.ts:26
<Static> noHttpFacility● noHttpFacility: string = “No HTTP facility provided.”
Defined in HydraClient.ts:31
<Static> noHypermediaProcessors● noHypermediaProcessors: string = “No valid hypermedia processor instances were provided.”
Defined in HydraClient.ts:27
<Static> noIriTemplateExpansionStrategy● noIriTemplateExpansionStrategy: string = “No IRI template expansion strategy was provided.”
Defined in HydraClient.ts:30
<Static> noOperationProvided● noOperationProvided: string = “There was no operation provided.”
Defined in HydraClient.ts:23
<Static> noUrlProvided● noUrlProvided: string = “There was no Url provided.”
Defined in HydraClient.ts:24
<Static> responseFormatNotSupported● responseFormatNotSupported: string = “Response format is not supported.”
Defined in HydraClient.ts:29
▸ getApiDocumentation(urlOrResource: string | IResource): Promise<IApiDocumentation>
Implementation of IHydraClient.getApiDocumentation
Defined in HydraClient.ts:85
Obtains an API documentation.
Parameters:
| Name | Type |
|---|---|
| urlOrResource | string | IResource |
Returns: Promise<IApiDocumentation>
<Private> getApiDocumentationUrl▸ getApiDocumentationUrl(url: string): Promise<object>
Defined in HydraClient.ts:138
Parameters:
| Name | Type |
|---|---|
| url | string |
Returns: Promise<object>
▸ getHypermediaProcessor(response: Response): IHypermediaProcessor
Implementation of IHydraClient.getHypermediaProcessor
Defined in HydraClient.ts:71
Gets a hypermedia provider suitable for a given response.
Parameters:
| Name | Type |
|---|---|
| response | Response |
Returns: IHypermediaProcessor
▸ getResource(urlOrResource: string | IResource | ILink): Promise<IWebResource>
Implementation of IHydraClient.getResource
Defined in HydraClient.ts:99
Obtains a representation of a resource.
Parameters:
| Name | Type |
|---|---|
| urlOrResource | string | IResource | ILink |
Returns: Promise<IWebResource>
<Private> getResourceFrom▸ getResourceFrom(url: string, options: any): Promise<IWebResource>
Defined in HydraClient.ts:119
Parameters:
| Name | Type |
|---|---|
| url | string |
| options | any |
Returns: Promise<IWebResource>
▸ invoke(operation: IOperation, body?: IWebResource, parameters?: object): Promise<Response>
Implementation of IHydraClient.invoke
Defined in HydraClient.ts:104
Invokes a given operation.
Parameters:
| Name | Type |
|---|---|
| operation | IOperation |
Optional body |
IWebResource |
Optional parameters |
object |
Returns: Promise<Response>
<Private> makeRequestTo▸ makeRequestTo(url: string, options?: RequestInit): Promise<Response>
Defined in HydraClient.ts:169
Parameters:
| Name | Type |
|---|---|
| url | string |
Optional options |
RequestInit |
Returns: Promise<Response>
<Static><Private> getUrl▸ getUrl(urlOrResource: string | IResource | ILink): string
Defined in HydraClient.ts:156
Parameters:
| Name | Type |
|---|---|
| urlOrResource | string | IResource | ILink |
Returns: string