getAdCode method

Future<AdCode> getAdCode(
  1. String accountId,
  2. String adClientId,
  3. String adUnitId, {
  4. List<String>? hostCustomChannelId,
  5. String? $fields,
})

Get ad code for the specified ad unit, attaching the specified host custom channels.

Request parameters:

accountId - Account which contains the ad client.

adClientId - Ad client with contains the ad unit.

adUnitId - Ad unit to get the code for.

hostCustomChannelId - Host custom channel to attach to the ad code.

$fields - Selector specifying which fields to include in a partial response.

Completes with a AdCode.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<AdCode> getAdCode(
  core.String accountId,
  core.String adClientId,
  core.String adUnitId, {
  core.List<core.String>? hostCustomChannelId,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    if (hostCustomChannelId != null)
      'hostCustomChannelId': hostCustomChannelId,
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'accounts/' +
      commons.escapeVariable('$accountId') +
      '/adclients/' +
      commons.escapeVariable('$adClientId') +
      '/adunits/' +
      commons.escapeVariable('$adUnitId') +
      '/adcode';

  final response_ = await _requester.request(
    url_,
    'GET',
    queryParams: queryParams_,
  );
  return AdCode.fromJson(response_ as core.Map<core.String, core.dynamic>);
}