insert method

Future<CreativeAssetMetadata> insert(
  1. CreativeAssetMetadata request,
  2. String profileId,
  3. String advertiserId, {
  4. String? $fields,
  5. Media? uploadMedia,
})

Inserts a new creative asset.

request - The metadata request object.

Request parameters:

profileId - User profile ID associated with this request. Value must have pattern ^\[^/\]+$.

advertiserId - Advertiser ID of this creative. This is a required field. Value must have pattern ^\[^/\]+$.

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

uploadMedia - The media to upload.

Completes with a CreativeAssetMetadata.

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<CreativeAssetMetadata> insert(
  CreativeAssetMetadata request,
  core.String profileId,
  core.String advertiserId, {
  core.String? $fields,
  commons.Media? uploadMedia,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  core.String url_;
  if (uploadMedia == null) {
    url_ = 'userprofiles/' +
        core.Uri.encodeFull('$profileId') +
        '/creativeAssets/' +
        core.Uri.encodeFull('$advertiserId') +
        '/creativeAssets';
  } else {
    url_ = '/upload/dfareporting/v4/userprofiles/' +
        core.Uri.encodeFull('$profileId') +
        '/creativeAssets/' +
        core.Uri.encodeFull('$advertiserId') +
        '/creativeAssets';
  }

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
    uploadMedia: uploadMedia,
    uploadOptions: commons.UploadOptions.defaultOptions,
  );
  return CreativeAssetMetadata.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}