Constructs an instance of the class with a unique transaction ID, username, and password.
The username for the instance.
The password for the instance.
Protected
Optional
_access_Optional variable _access_token_data
which holds the access token information.
This variable may contain the data structure defined by the AccessTokenData
type
in the Types
namespace. It is used to store the details of an access token,
which typically includes properties such as the token value, expiry time, and possibly
other metadata related to authentication and authorization.
Protected
_debug_A boolean flag that indicates whether debug logging is enabled. When set to true, the application will output additional debug information to the logs. This can be useful for troubleshooting and development purposes. Default value is false.
Protected
Optional
_parent_Represents the unique identifier of the parent log entry. This variable is optional, meaning it might be undefined. If present, it denotes the ID of the log entry that is the parent in a hierarchical log structure, aiding in tracking relational log data.
Protected
_passwordRepresents the password of a user. This string is used for authenticating the user. It should be kept confidential and secured.
Protected
Optional
_propertiesRepresents the properties associated with the service, retrieved at instantiation time from service_properties_uri.
A unique identifier for a transaction. This ID is used to track and reference individual transactions within the system. It ensures that each transaction can be distinctly identified.
Protected
_usernameRepresents the username of a user in the system. This is a string that uniquely identifies a user.
Readonly
access_The number of seconds that an access token remains valid.
This value determines the time-to-live (TTL) for access tokens, ensuring they expire after a certain period of inactivity or usage. Typically used to control session timeouts and enhance security.
Protected
Readonly
api_The client's API identifier used for making requests. This string is typically configured to represent the name or key associated with the API client in use.
Protected
Readonly
api_A string representing the tenant identifier for the API. This tenant id differentiates the API usage context and allows the system to apply the appropriate configurations and access controls.
Example: "VESALES"
Readonly
api_The version number of the API that the application is currently using. This variable helps in managing and differentiating between different iterations or releases of the API.
Readonly
service_The URI that points to the properties configuration file for the Vattenfall service. This URI is used to fetch various properties and settings required for the service's operation.
Retrieves the access token data.
The access token data, or undefined if not set.
Retrieves the current password.
The current password.
Retrieves the service properties.
The service properties if available, otherwise undefined.
Gets the current username.
The current username.
Protected
_processProtected
_requestMakes an HTTP request to the specified URI with the given method and data. This is an internal method that returns a Response object.
The endpoint URI to which the request is made.
The HTTP method to be used for the request (e.g., GET, POST).
Optional
data: DThe data to be sent with the request, if applicable.
A promise that resolves to the response of the request.
Protected
debugRetrieves an access token for the user. If the current access token is expired
and the force
parameter is set to false
, it refreshes the access token.
Whether to forcefully obtain a new access token even if the current one is not expired.
A promise that resolves to the access token string.
Retrieves contract data based on the provided contract ID.
The ID of the contract to retrieve.
A promise that resolves with the contract data.
Fetches the list of contracts for the user.
A promise that resolves to the contract data.
Fetches the meter readings for a given contract ID.
The ID of the contract for which meter readings are being requested.
A promise that resolves to the meter reading response.
Fetches and returns the service properties. If the service properties have been previously fetched and stored, it returns the stored properties. Otherwise, it fetches the properties from a predefined URL, stores them, and then returns them. In case of an error during fetching, it logs the error message.
A promise that resolves to the service properties.
Logs the user out by invalidating the current access token.
This method checks if the user is authenticated before attempting to log out. If authenticated, it sends a request to the server to delete the current token. If the server response indicates a token expiry error, the error is not thrown. Otherwise, any other errors encountered during the logout process are thrown.
A promise that resolves when the logout operation is complete.
Sends an HTTP POST request to the specified URI with the given request data and returns the response.
The URI to send the POST request to.
The data to be sent with the POST request.
A promise that resolves to the response data.
Sends an HTTP PUT request to the specified URI with the given data.
The URI to which the PUT request is sent.
The data to be sent in the body of the PUT request.
A promise that resolves to the response of the PUT request.
Checks the given API response and throws an error if the response status is not "OK".
The API response to check for an error status.
Returns nothing if the response is "OK"; otherwise, throws a VattenfallApiError.
Refreshes the access token using the refresh token.
This method checks if the current access token data is available. If not, it triggers a fresh retrieval of the access token. Otherwise, it attempts to refresh the current access token using the refresh token. In case of any error that indicates token expiry, it retrieves a new access token.
A promise that resolves once the access token is refreshed or a new one is retrieved.
Protected
requestMakes an HTTP request to the specified URI with the provided method and data, and returns a promise that resolves to the response.
The URI to send the request to.
The HTTP method to use for the request. Defaults to GET.
Optional
data: DThe data to send with the request. Optional.
A promise that resolves to the response of the HTTP request.
Resets the transaction ID for the current session.
Optional
id: stringOptional parameter to set a specific transaction ID. If not provided, a new UUID will be generated and used.
Represents the Vattenfall Service, providing methods to interact with the service's API.