setBaseApiUrl method

CoffeeRequest setBaseApiUrl(
  1. String newApiBaseUrl
)

Sets the base URL for the API requests.

This method allows changing the base URL of the API requests. If a non-empty string is provided as the new base URL, it updates the internal _apiUrl variable with the new value. If an empty string is provided, the base URL is not changed.

This method utilizes the 'fluent interface' pattern by returning the instance of the class it belongs to, allowing for method chaining.

Example:

.setBaseApiUrl('https://newapi.example.com');

newApiBaseUrl The new base URL to be set for the API requests. If this is empty, the current base URL is not changed.

Returns the current instance of CoffeeRequest with the updated base URL.

Implementation

CoffeeRequest setBaseApiUrl(String newApiBaseUrl) {
  if(newApiBaseUrl.isEmpty) {
    return this;
  }

  baseUrl = newApiBaseUrl;
  return this;
}