getThemeStylesheetRaw method

  1. @experimental
DynamiteRawResponse<String, void> getThemeStylesheetRaw({
  1. required String themeId,
  2. ThemingGetThemeStylesheetPlain? plain,
  3. ThemingGetThemeStylesheetWithCustomCss? withCustomCss,
})

Get the CSS stylesheet for a theme.

This method and the response it returns is experimental. The API might change without a major version bump.

Returns a Future containing a DynamiteRawResponse with the raw HttpClientResponse and serialization helpers. Throws a DynamiteApiException if the API call does not return an expected status code.

Parameters:

  • plain Let the browser decide the CSS priority. Defaults to 0.
  • withCustomCss Include custom CSS. Defaults to 0.
  • themeId ID of the theme.

Status codes:

  • 200: Stylesheet returned
  • 404: Theme not found

See:

Implementation

@_i4.experimental
_i1.DynamiteRawResponse<String, void> getThemeStylesheetRaw({
  required String themeId,
  ThemingGetThemeStylesheetPlain? plain,
  ThemingGetThemeStylesheetWithCustomCss? withCustomCss,
}) {
  final _parameters = <String, dynamic>{};
  final _headers = <String, String>{'Accept': 'text/css'};

// coverage:ignore-start
  final authentication = _rootClient.authentications?.firstWhereOrNull(
    (auth) => switch (auth) {
      _i1.DynamiteHttpBearerAuthentication() || _i1.DynamiteHttpBasicAuthentication() => true,
      _ => false,
    },
  );

  if (authentication != null) {
    _headers.addAll(
      authentication.headers,
    );
  }

// coverage:ignore-end
  final $themeId = _$jsonSerializers.serialize(themeId, specifiedType: const FullType(String));
  _parameters['themeId'] = $themeId;

  var $plain = _$jsonSerializers.serialize(plain, specifiedType: const FullType(ThemingGetThemeStylesheetPlain));
  $plain ??= 0;
  _parameters['plain'] = $plain;

  var $withCustomCss = _$jsonSerializers.serialize(
    withCustomCss,
    specifiedType: const FullType(ThemingGetThemeStylesheetWithCustomCss),
  );
  $withCustomCss ??= 0;
  _parameters['withCustomCss'] = $withCustomCss;

  final _path =
      _i2.UriTemplate('/index.php/apps/theming/theme/{themeId}.css{?plain*,withCustomCss*}').expand(_parameters);
  return _i1.DynamiteRawResponse<String, void>(
    response: _rootClient.executeRequest(
      'get',
      _path,
      headers: _headers,
      validStatuses: const {200},
    ),
    bodyType: const FullType(String),
    headersType: null,
    serializers: _$jsonSerializers,
  );
}