Static
getExtracts the value of a specific query parameter from a given URL.
The name of the parameter to retrieve.
The URL string to parse for the parameter.
The value of the parameter if found, otherwise null
.
Static
preparePrepares an API request by encoding data, generating hashes, and constructing the request URL and payload.
The API action or endpoint being invoked.
The payload to be sent with the request as key-value pairs.
Configuration object containing keys, user information, and other API settings.
config.webapi.key
- The API key.config.webapi.version
- The API version.config.uber.authTstamp
- The authentication timestamp.config.uber.authHash
- The authentication hash.config.userId
- The ID of the authenticated user.config.trackingSource
- The source of the tracking data.config.websiteURL
- The base URL for the API.An object containing:
url
: The constructed request URL.postData
: The encoded payload to send with the request.type
: The HTTP method to use (always "POST").const action = "getUserDetails";
const data = { userID: 12345 };
const config = {
webapi: { key: "apiKey", version: "1.0" },
uber: { authTstamp: "1276123139", authHash: "secureHash" },
userId: "user123",
trackingSource: "web",
websiteURL: "https://supremacy1914.com/",
};
const requestDetails = RequestBuilder.prepare(action, data, config);
console.log(requestDetails);
// Outputs:
// {
// url: "https://supremacy1914.com/index.php?eID=api&key=apiKey&action=getUserDetails&hash=...",
// postData: "data=...",
// type: "POST",
// }
A utility class for constructing and preparing API requests.