create method

Future<Creative> create(
  1. Creative request,
  2. String accountId, {
  3. String? duplicateIdMode,
  4. String? $fields,
})

Creates a creative.

request - The metadata request object.

Request parameters:

accountId - The account that this creative belongs to. Can be used to filter the response of the creatives.list method.

duplicateIdMode - Indicates if multiple creatives can share an ID or not. Default is NO_DUPLICATES (one ID per creative). Possible string values are:

  • "NO_DUPLICATES" : Recommended. This means that an ID will be unique to a single creative. Multiple creatives will not share an ID.
  • "FORCE_ENABLE_DUPLICATE_IDS" : Not recommended. Using this option will allow multiple creatives to share the same ID. Get and Update requests will not be possible for any ID that has more than one creative associated. (List will still function.) This is only intended for backwards compatibility in cases where a single ID is already shared by multiple creatives from previous APIs.

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

Completes with a Creative.

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<Creative> create(
  Creative request,
  core.String accountId, {
  core.String? duplicateIdMode,
  core.String? $fields,
}) async {
  final _body = convert.json.encode(request.toJson());
  final _queryParams = <core.String, core.List<core.String>>{
    if (duplicateIdMode != null) 'duplicateIdMode': [duplicateIdMode],
    if ($fields != null) 'fields': [$fields],
  };

  final _url = 'v2beta1/accounts/' +
      commons.escapeVariable('$accountId') +
      '/creatives';

  final _response = await _requester.request(
    _url,
    'POST',
    body: _body,
    queryParams: _queryParams,
  );
  return Creative.fromJson(_response as core.Map<core.String, core.dynamic>);
}